1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #include "light.hh"
|
---|
10 | #include "saver_id.hh"
|
---|
11 | #include "saver.hh"
|
---|
12 | #include "map.hh"
|
---|
13 |
|
---|
14 | g1_light_info g1_lights;
|
---|
15 |
|
---|
16 |
|
---|
17 | void g1_light_info::recalc_shadow_intensity()
|
---|
18 | {
|
---|
19 | for (int i=0; i<256; i++)
|
---|
20 | shadow_intensity[i]=1.0 - i4_float(i)/256.0;
|
---|
21 | }
|
---|
22 |
|
---|
23 |
|
---|
24 | void g1_light_info::set_ambient_intensity(float v)
|
---|
25 | {
|
---|
26 | ambient_intensity=v;
|
---|
27 | recalc_shadow_intensity();
|
---|
28 |
|
---|
29 | }
|
---|
30 |
|
---|
31 | void g1_light_info::set_directional_intensity(float v)
|
---|
32 | {
|
---|
33 | directional_intensity=v;
|
---|
34 | recalc_shadow_intensity();
|
---|
35 | }
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 | void g1_light_info::save(i4_saver_class *fp)
|
---|
41 | {
|
---|
42 | fp->mark_section("Map Lights V2");
|
---|
43 | fp->write_format("fffff",
|
---|
44 | &directional_intensity,
|
---|
45 | &direction.x, &direction.y, &direction.z,
|
---|
46 | &ambient_intensity);
|
---|
47 | }
|
---|
48 |
|
---|
49 | i4_bool g1_light_info::load(i4_loader_class *fp)
|
---|
50 | {
|
---|
51 | if (fp && fp->goto_section("Map Lights V2"))
|
---|
52 | {
|
---|
53 | fp->read_format("fffff",
|
---|
54 | &directional_intensity,
|
---|
55 | &direction.x, &direction.y, &direction.z,
|
---|
56 | &ambient_intensity);
|
---|
57 |
|
---|
58 | recalc_shadow_intensity();
|
---|
59 | return i4_T;
|
---|
60 | }
|
---|
61 |
|
---|
62 | return i4_F;
|
---|
63 | }
|
---|
64 |
|
---|
65 | void g1_light_info::defaults()
|
---|
66 | {
|
---|
67 | directional_intensity=0.3;
|
---|
68 | direction=i4_3d_vector(1, 0.0, -0.1);
|
---|
69 | direction.normalize();
|
---|
70 | ambient_intensity=0.05;
|
---|
71 | }
|
---|
72 |
|
---|
73 | g1_light_info::g1_light_info()
|
---|
74 | {
|
---|
75 | defaults();
|
---|
76 | }
|
---|