38 static double base_time = 0;
39 static WORD oldcw = 0;
45 fpcw = oldcw | 0x0300;
84 base_time = clock_seconds;
93 double sdate = gtime + base_time +
epoch;
100 static const double GRAV = 6.673e-11;
106 : name(sys_name), affiliation(iff), sky_stars(0), sky_dust(0), loc(l), seq(s),
107 active_region(0), instantiated(false), ambient(0,0,0),
108 sun_color(255,255,255), sun_scale(1), point_stars(0), poly_stars(0),
119 Print(
" Destroying Star System %s\n", (
const char*)
name);
171 if (!file_type || file_type->
value() !=
"STARSYSTEM") {
196 else if (def->
name()->
value() ==
"sky") {
214 if (pdef->
name()->
value() ==
"poly_stars")
217 else if (pdef->
name()->
value() ==
"nebula")
220 else if (pdef->
name()->
value() ==
"haze")
236 else if (def->
name()->
value() ==
"stars") {
240 else if (def->
name()->
value() ==
"ambient") {
247 else if (def->
name()->
value() ==
"dust") {
251 else if (def->
name()->
value() ==
"star") {
261 else if (def->
name()->
value() ==
"planet") {
271 else if (def->
name()->
value() ==
"moon") {
281 else if (def->
name()->
value() ==
"region") {
291 else if (def->
name()->
value() ==
"terrain") {
293 Print(
"WARNING: terrain struct missing in '%s'\n",
filename);
336 else if (pdef->
name()->
value() ==
"image")
339 else if (pdef->
name()->
value() ==
"mass")
342 else if (pdef->
name()->
value() ==
"orbit")
345 else if (pdef->
name()->
value() ==
"radius")
348 else if (pdef->
name()->
value() ==
"rotation")
351 else if (pdef->
name()->
value() ==
"tscale")
354 else if (pdef->
name()->
value() ==
"light")
357 else if (pdef->
name()->
value() ==
"retro")
360 else if (pdef->
name()->
value() ==
"color") {
363 color =
Color((BYTE) a.
x, (BYTE) a.
y, (BYTE) a.
z);
369 back =
Color((BYTE) a.
x, (BYTE) a.
y, (BYTE) a.
z);
429 ZeroMemory(glo_hi_name,
NAMELEN);
430 ZeroMemory(gloss_name,
NAMELEN);
442 else if (pdef->
name()->
value() ==
"image")
445 else if (pdef->
name()->
value() ==
"image_west")
448 else if (pdef->
name()->
value() ==
"image_east")
451 else if (pdef->
name()->
value() ==
"glow")
454 else if (pdef->
name()->
value() ==
"gloss")
457 else if (pdef->
name()->
value() ==
"high_res")
460 else if (pdef->
name()->
value() ==
"high_res_west")
463 else if (pdef->
name()->
value() ==
"high_res_east")
466 else if (pdef->
name()->
value() ==
"glow_high_res")
469 else if (pdef->
name()->
value() ==
"mass")
472 else if (pdef->
name()->
value() ==
"orbit")
475 else if (pdef->
name()->
value() ==
"retro")
478 else if (pdef->
name()->
value() ==
"luminous")
481 else if (pdef->
name()->
value() ==
"rotation")
484 else if (pdef->
name()->
value() ==
"radius")
487 else if (pdef->
name()->
value() ==
"ring")
490 else if (pdef->
name()->
value() ==
"minrad")
493 else if (pdef->
name()->
value() ==
"maxrad")
496 else if (pdef->
name()->
value() ==
"tscale")
499 else if (pdef->
name()->
value() ==
"tilt")
502 else if (pdef->
name()->
value() ==
"atmosphere") {
505 atmos =
Color((BYTE) a.
x, (BYTE) a.
y, (BYTE) a.
z);
522 planet->
retro = retro;
532 primary_planet = planet;
571 ZeroMemory(glo_hi_name,
NAMELEN);
572 ZeroMemory(gloss_name,
NAMELEN);
583 else if (pdef->
name()->
value() ==
"image")
586 else if (pdef->
name()->
value() ==
"glow")
589 else if (pdef->
name()->
value() ==
"high_res")
592 else if (pdef->
name()->
value() ==
"glow_high_res")
595 else if (pdef->
name()->
value() ==
"gloss")
598 else if (pdef->
name()->
value() ==
"mass")
601 else if (pdef->
name()->
value() ==
"orbit")
604 else if (pdef->
name()->
value() ==
"rotation")
607 else if (pdef->
name()->
value() ==
"retro")
610 else if (pdef->
name()->
value() ==
"radius")
613 else if (pdef->
name()->
value() ==
"tscale")
616 else if (pdef->
name()->
value() ==
"inclination")
619 else if (pdef->
name()->
value() ==
"atmosphere") {
622 atmos =
Color((BYTE) a.
x, (BYTE) a.
y, (BYTE) a.
z);
643 Print(
"WARNING: no planet for moon %s in '%s', deleted.\n", pln_name,
filename);
666 double inclination = 0.0;
677 else if (pdef->
name()->
value() ==
"link") {
680 links.
append(
new(__FILE__,__LINE__)
Text(lnk_name));
684 else if (pdef->
name()->
value() ==
"orbit")
687 else if (pdef->
name()->
value() ==
"size")
690 else if (pdef->
name()->
value() ==
"radius")
693 else if (pdef->
name()->
value() ==
"grid")
696 else if (pdef->
name()->
value() ==
"inclination")
699 else if (pdef->
name()->
value() ==
"asteroids")
704 Orbital* primary = primary_moon;
705 if (!primary) primary = primary_planet;
706 if (!primary) primary = primary_star;
730 Orbital* primary = primary_moon;
731 if (!primary) primary = primary_planet;
734 Print(
"WARNING: Terrain region with no primary ignored in '%s'\n",
filename);
748 Text env_texture_positive_x;
749 Text env_texture_negative_x;
750 Text env_texture_positive_y;
751 Text env_texture_negative_y;
752 Text env_texture_positive_z;
753 Text env_texture_negative_z;
763 double inclination = 0.0;
765 double mtnscale = 1e3;
766 double fog_density = 0;
767 double fog_scale = 0;
768 double haze_fade = 0;
769 double clouds_alt_high= 0;
770 double clouds_alt_low= 0;
774 ZeroMemory(w_chances,
sizeof(w_chances));
782 else if (pdef->
name()->
value() ==
"patch")
785 else if (pdef->
name()->
value() ==
"patch_texture")
788 else if (pdef->
name()->
value() ==
"detail_texture_0")
791 else if (pdef->
name()->
value() ==
"detail_texture_1")
794 else if (pdef->
name()->
value() ==
"apron")
797 else if (pdef->
name()->
value() ==
"apron_texture")
800 else if (pdef->
name()->
value() ==
"water_texture")
803 else if (pdef->
name()->
value() ==
"env_texture_positive_x")
806 else if (pdef->
name()->
value() ==
"env_texture_negative_x")
809 else if (pdef->
name()->
value() ==
"env_texture_positive_y")
812 else if (pdef->
name()->
value() ==
"env_texture_negative_y")
815 else if (pdef->
name()->
value() ==
"env_texture_positive_z")
818 else if (pdef->
name()->
value() ==
"env_texture_negative_z")
821 else if (pdef->
name()->
value() ==
"clouds_high")
824 else if (pdef->
name()->
value() ==
"shades_high")
827 else if (pdef->
name()->
value() ==
"clouds_low")
830 else if (pdef->
name()->
value() ==
"shades_low")
833 else if (pdef->
name()->
value() ==
"haze")
836 else if (pdef->
name()->
value() ==
"sky_color")
839 else if (pdef->
name()->
value() ==
"size" ||
843 else if (pdef->
name()->
value() ==
"grid")
846 else if (pdef->
name()->
value() ==
"inclination")
849 else if (pdef->
name()->
value() ==
"scale")
852 else if (pdef->
name()->
value() ==
"mtnscale" ||
856 else if (pdef->
name()->
value() ==
"fog_density")
859 else if (pdef->
name()->
value() ==
"fog_scale")
862 else if (pdef->
name()->
value() ==
"haze_fade")
865 else if (pdef->
name()->
value() ==
"clouds_alt_high")
868 else if (pdef->
name()->
value() ==
"clouds_alt_low")
871 else if (pdef->
name()->
value() ==
"weather_period")
874 else if (pdef->
name()->
value() ==
"weather_clear")
876 else if (pdef->
name()->
value() ==
"weather_high_clouds")
878 else if (pdef->
name()->
value() ==
"weather_moderate_clouds")
880 else if (pdef->
name()->
value() ==
"weather_overcast")
882 else if (pdef->
name()->
value() ==
"weather_fog")
884 else if (pdef->
name()->
value() ==
"weather_storm")
887 else if (pdef->
name()->
value() ==
"layer") {
889 Print(
"WARNING: terrain layer struct missing in '%s'\n",
filename);
894 region =
new(__FILE__,__LINE__)
TerrainRegion(
this, rgn_name, size, primary);
904 region =
new(__FILE__,__LINE__)
TerrainRegion(
this, rgn_name, size, primary);
920 region->
scale = scale;
974 rgn->
AddLayer(height, tile_name, detail_name);
986 Print(
"Creating Star System %s\n", (
const char*)
name);
1028 Print(
"Atmospheric Haze '%s' loaded\n", (
const char*)
sky_haze);
1081 Light* sun_light =
new(__FILE__,__LINE__)
Light(1.1f);
1091 Light* back_light =
new(__FILE__,__LINE__)
Light(0.6f);
1145 if (body.
tilt != 0) {
1163 while (++star_iter) {
1226 while (++star_iter) {
1386 static BYTE max3(BYTE a, BYTE b, BYTE c)
1389 if (a > c)
return a;
1392 if (b > c)
return b;
1396 static BYTE min3(BYTE a, BYTE b, BYTE c)
1399 if (a < c)
return a;
1402 if (b < c)
return b;
1427 Matrix terrain_orientation;
1428 Matrix terrain_transformation;
1441 terrain_orientation.
Rotate(0,
PI/2, 0);
1448 BYTE sky_red = (BYTE) sky_color.
Red();
1449 BYTE sky_green = (BYTE) sky_color.
Green();
1450 BYTE sky_blue = (BYTE) sky_color.
Blue();
1452 BYTE Max = max3(sky_red, sky_green, sky_blue);
1453 BYTE Min = min3(sky_red, sky_green, sky_blue);
1455 BYTE lum = (BYTE) (240.0 * (Max + Min) / 510.0);
1472 scene = haze->GetScene();
1484 double star_alt = 0;
1487 while (++star_iter) {
1515 if (trgn && star->
rep) {
1546 while (++planet_iter) {
1573 while (++moon_iter) {
1609 if (!name || !name[0])
1615 return star.
value();
1618 while (++star_rgn) {
1619 if (!_stricmp(star_rgn->
Name(),
name))
1620 return star_rgn.
value();
1625 if (!_stricmp(planet->
Name(),
name))
1626 return planet.
value();
1629 while (++planet_rgn) {
1630 if (!_stricmp(planet_rgn->
Name(),
name))
1631 return planet_rgn.
value();
1637 return moon.
value();
1640 while (++moon_rgn) {
1641 if (!_stricmp(moon_rgn->
Name(),
name))
1642 return moon_rgn.
value();
1650 if (!_stricmp(region->
Name(),
name))
1651 return region.
value();
1662 if (!name || !name[0])
1667 if (!_stricmp(region->
Name(),
name))
1668 return region.
value();
1684 while (++lnk_iter) {
1704 result.
x = tmp *
tvrt;
1705 result.
z = tmp *
tvup;
1706 result.
y = tmp *
tvpn;
1722 result = result * 0.3;
1735 while (++sun_iter) {
1742 while (++back_iter) {
1752 while (++back_iter) {
1798 case O:
return Color(128,128,255);
break;
1799 case B:
return Color(192,192,255);
break;
1800 case A:
return Color(220,220,255);
break;
1801 case F:
return Color(255,255,255);
break;
1802 case G:
return Color(255,255,128);
break;
1803 case K:
return Color(255,192,100);
break;
1804 case M:
return Color(255,100,100);
break;
1818 case O:
return 4;
break;
1819 case B:
return 4;
break;
1820 case A:
return 3;
break;
1821 case F:
return 3;
break;
1822 case G:
return 2;
break;
1823 case K:
return 2;
break;
1824 case M:
return 1;
break;
1837 : name(n), type(t), subtype(0), radius(r), mass(m), orbit(o),
1838 phase(0), period(0), rotation(0), retro(false),
1839 system(s), primary(p), loc(0, 0, 0), rep(0), velocity(0)
1863 double grade = (
retro) ? -1 : 1;
1891 double grade = (
retro) ? -1 : 1;
1896 predicted_loc +=
Point((
double) (
orbit * cos(predicted_phase)),
1897 (
double) (
orbit * sin(predicted_phase)),
1901 return predicted_loc;
1917 :
Orbital(s, n, t, m, r, o, p), light(0), light_rep(0), back_light(0),
1918 ring_min(0), ring_max(0), tilt(0), luminous(false)
1964 :
Orbital(s, n, REGION, m, r, o, p), grid(25.0e3f), inclination(0)