108 { +0.000000, -0.850664, -0.525710 },
109 { +0.000000, -0.850664, +0.525710 },
110 { +0.000000, +0.850664, +0.525710 },
111 { +0.000000, +0.850664, -0.525710 },
112 { -0.525710, +0.000000, -0.850664 },
113 { +0.525710, +0.000000, -0.850664 },
114 { +0.525710, +0.000000, +0.850664 },
115 { -0.525710, +0.000000, +0.850664 },
116 { -0.850664, -0.525710, +0.000000 },
117 { -0.850664, +0.525710, +0.000000 },
118 { +0.850664, +0.525710, +0.000000 },
119 { +0.850664, -0.525710, +0.000000 }
124 { { 9, +0.600000, +0.666667 }, { 7, +0.800000, +0.666667 }, { 8, +0.800000, +0.333333 } },
125 { { 8, +0.800000, +0.333333 }, { 4, +0.600000, +0.333333 }, { 9, +0.600000, +0.666667 } },
126 { { 3, +0.400000, +0.666667 }, { 9, +0.600000, +0.666667 }, { 4, +0.600000, +0.333333 } },
127 { { 8, +0.800000, +0.333333 }, { 0, +0.500000, +0.000000 }, { 4, +0.600000, +0.333333 } },
128 { { 7, +0.800000, +0.666667 }, { 1, +1.000000, +0.333333 }, { 8, +0.800000, +0.333333 } },
129 { { 2, +0.500000, +1.000000 }, { 7, +0.800000, +0.666667 }, { 9, +0.600000, +0.666667 } },
130 { { 2, +0.500000, +1.000000 }, { 9, +0.600000, +0.666667 }, { 3, +0.400000, +0.666667 } },
131 { { 1, +1.000000, +0.333333 }, { 0, +0.500000, +0.000000 }, { 8, +0.800000, +0.333333 } },
132 { { 4, +0.600000, +0.333333 }, { 0, +0.500000, +0.000000 }, { 5, +0.400000, +0.333333 } },
133 { { 5, +0.400000, +0.333333 }, { 3, +0.400000, +0.666667 }, { 4, +0.600000, +0.333333 } },
134 { { 6, +1.000000, +0.666667 }, { 1, +1.000000, +0.333333 }, { 7, +0.800000, +0.666667 } },
135 { { 7, +0.800000, +0.666667 }, { 2, +0.500000, +1.000000 }, { 6, +1.000000, +0.666667 } },
136 { { 1, +0.000000, +0.333333 }, { 11, +0.200000, +0.333333 }, { 0, +0.500000, +0.000000 } },
137 { { 3, +0.400000, +0.666667 }, { 10, +0.200000, +0.666667 }, { 2, +0.500000, +1.000000 } },
138 { { 0, +0.500000, +0.000000 }, { 11, +0.200000, +0.333333 }, { 5, +0.400000, +0.333333 } },
139 { { 5, +0.400000, +0.333333 }, { 10, +0.200000, +0.666667 }, { 3, +0.400000, +0.666667 } },
140 { { 1, +0.000000, +0.333333 }, { 6, +0.000000, +0.666667 }, { 11, +0.200000, +0.333333 } },
141 { { 6, +0.000000, +0.666667 }, { 2, +0.500000, +1.000000 }, { 10, +0.200000, +0.666667 } },
142 { { 5, +0.400000, +0.333333 }, { 11, +0.200000, +0.333333 }, { 10, +0.200000, +0.666667 } },
143 { { 11, +0.200000, +0.333333 }, { 6, +0.000000, +0.666667 }, { 10, +0.200000, +0.666667 } }
149 { +0.525731, +0.000000, +0.850651 },
150 { -0.525731, +0.000000, +0.850651 },
151 { +0.525731, +0.000000, -0.850651 },
152 { -0.525731, +0.000000, -0.850651 },
153 { +0.000000, +0.850651, +0.525731 },
154 { +0.000000, +0.850651, -0.525731 },
155 { +0.000000, -0.850651, +0.525731 },
156 { +0.000000, -0.850651, -0.525731 },
157 { -0.850651, +0.525731, +0.000000 },
158 { +0.850651, +0.525731, +0.000000 },
159 { -0.850651, -0.525731, +0.000000 },
160 { +0.850651, -0.525731, +0.000000 },
161 { +0.000000, +0.850651, -0.525731 },
162 { +0.525731, +0.000000, -0.850651 }
167 { { 1, +0.400000, +0.666667 }, { 0, +0.600000, +0.666667 }, { 6, +0.500000, +0.333333 } },
168 { { 3, +0.100000, +0.333333 }, { 2, -0.100000, +0.333333 }, { 5, +0.000000, +0.666667 } },
169 { { 4, +0.500000, +1.000000 }, { 0, +0.600000, +0.666667 }, { 1, +0.400000, +0.666667 } },
170 { { 4, +0.500000, +1.000000 }, { 1, +0.400000, +0.666667 }, { 8, +0.200000, +0.666667 } },
171 { { 12, +1.000000, +0.666667 }, { 13, +0.900000, +0.333333 }, { 9, +0.800000, +0.666667 } },
172 { { 5, +0.000000, +0.666667 }, { 4, +0.500000, +1.000000 }, { 8, +0.200000, +0.666667 } },
173 { { 6, +0.500000, +0.333333 }, { 0, +0.600000, +0.666667 }, { 11, +0.700000, +0.333333 } },
174 { { 7, +0.500000, +0.000000 }, { 2, -0.100000, +0.333333 }, { 3, +0.100000, +0.333333 } },
175 { { 7, +0.500000, +0.000000 }, { 3, +0.100000, +0.333333 }, { 10, +0.300000, +0.333333 } },
176 { { 7, +0.500000, +0.000000 }, { 6, +0.500000, +0.333333 }, { 11, +0.700000, +0.333333 } },
177 { { 8, +0.200000, +0.666667 }, { 1, +0.400000, +0.666667 }, { 10, +0.300000, +0.333333 } },
178 { { 8, +0.200000, +0.666667 }, { 3, +0.100000, +0.333333 }, { 5, +0.000000, +0.666667 } },
179 { { 9, +0.800000, +0.666667 }, { 0, +0.600000, +0.666667 }, { 4, +0.500000, +1.000000 } },
180 { { 9, +0.800000, +0.666667 }, { 13, +0.900000, +0.333333 }, { 11, +0.700000, +0.333333 } },
181 { { 9, +0.800000, +0.666667 }, { 4, +0.500000, +1.000000 }, { 12, +1.000000, +0.666667 } },
182 { { 10, +0.300000, +0.333333 }, { 1, +0.400000, +0.666667 }, { 6, +0.500000, +0.333333 } },
183 { { 10, +0.300000, +0.333333 }, { 3, +0.100000, +0.333333 }, { 8, +0.200000, +0.666667 } },
184 { { 10, +0.300000, +0.333333 }, { 6, +0.500000, +0.333333 }, { 7, +0.500000, +0.000000 } },
185 { { 11, +0.700000, +0.333333 }, { 0, +0.600000, +0.666667 }, { 9, +0.800000, +0.666667 } },
186 { { 11, +0.700000, +0.333333 }, { 13, +0.900000, +0.333333 }, { 7, +0.500000, +0.000000 } }
200- (id) initAsAtmosphereForPlanet:(
PlanetEntity *)planet dictionary:(NSDictionary *)dict
202 BOOL procGen = [UNIVERSE doProcedurallyTexturedPlanets];
208 int percent_land = 100 - [
dict oo_intForKey:@"percent_cloud" defaultValue:100 - (3 + (gen_rnd_number() & 31)+(gen_rnd_number() & 31))];
210 polar_color_factor = 1.0;
212#define CLEAR_SKY_ALPHA 0.05
213#define CLOUD_ALPHA 0.50
214#define POLAR_CLEAR_SKY_ALPHA 0.34
215#define POLAR_CLOUD_ALPHA 0.75
246 cloudAlpha = OOClamp_0_1_f([dict oo_floatForKey:
@"cloud_alpha" defaultValue:1.0]);
248 if (clearSkyColor !=
nil)
253 if (cloudColor !=
nil)
258 if (polarClearSkyColor !=
nil)
262 else if (clearSkyColor !=
nil)
264 memmove(amb_polar_land, amb_land,
sizeof amb_polar_land);
268 if (polarCloudColor !=
nil)
272 else if (cloudColor !=
nil)
274 memmove(amb_polar_sea, amb_sea,
sizeof amb_polar_sea);
279 amb_sea[3] *= cloudAlpha;
280 amb_polar_land[3] *= cloudAlpha;
281 amb_polar_sea[3] *= cloudAlpha;
283 amb_sea[3] = OOClamp_0_1_f(amb_sea[3]);
284 amb_polar_sea[3] = OOClamp_0_1_f(amb_polar_sea[3]);
293 float cloud_bias = -0.01 * (float)percent_land;
294 float cloud_impress = 1.0 - cloud_bias;
306 OOLogERR(
@"planet.atmosphere.init.noPlanet",
@"planet entity initAsAtmosphereForPlanet: no planet found.");
320 shuttles_on_ground = 0;
321 last_launch_time = 0.0;
322 shuttle_launch_interval = 3600.0;
324 scanClass = CLASS_NO_DRAW;
341 [
self paintVertex:i :planet_seed];
347 rotational_velocity = [
dict oo_floatForKey:@"atmosphere_rotational_velocity" defaultValue:[
planet rotationalVelocity]*(0.9+(randf()*0.2))];
349 root_planet = planet;
378- (id) initFromDictionary:(NSDictionary*)dict withAtmosphere:(BOOL)atmo andSeed:(
Random_Seed)p_seed
380 BOOL procGen = [UNIVERSE doProcedurallyTexturedPlanets];
402 NSDictionary *textureSpec = [
dict oo_textureSpecifierForKey:@"texture" defaultName:nil];
403 if (textureSpec !=
nil)
415 NSString *seedStr = [
dict oo_stringForKey:@"seed"];
425 OOLogERR(
@"planet.fromDict",
@"could not interpret \"%@\
" as planet seed, using default.", seedStr);
432 NSMutableDictionary *planetInfo = [
NSMutableDictionary dictionaryWithDictionary:[UNIVERSE generateSystemData:p_seed]];
433 int radius_km = [
dict oo_intForKey:KEY_RADIUS
434 defaultValue:[
planetInfo oo_intForKey:KEY_RADIUS]];
435 int techlevel = [
dict oo_intForKey:KEY_TECHLEVEL
436 defaultValue:[
planetInfo oo_intForKey:KEY_TECHLEVEL]];
455 int percent_land = [
planetInfo oo_intForKey:@"percent_land" defaultValue:24 + (gen_rnd_number() % 48)];
465 [
planetInfo setObject:[
NSNumber numberWithFloat:0.01 * percent_land] forKey:@"land_fraction"];
469 Vector land_hsb, sea_hsb, land_polar_hsb, sea_polar_hsb;
474 land_hsb.x = 0.0; land_hsb.y = 0.0; land_hsb.z = 1.0;
475 sea_hsb.x = 0.0; sea_hsb.y = 1.0; sea_hsb.z = 1.0;
484 while (dot_product(land_hsb,sea_hsb) > .80)
494 land_polar_hsb.x = land_hsb.x; land_polar_hsb.y = (land_hsb.y / 4.0); land_polar_hsb.z = 1.0 - (land_hsb.z / 10.0);
495 sea_polar_hsb.x = sea_hsb.x; sea_polar_hsb.y = (sea_hsb.y / 4.0); sea_polar_hsb.z = 1.0 - (sea_hsb.z / 10.0);
519 [
planetInfo setObject:amb_land_color forKey:@"land_color"];
520 [
planetInfo setObject:amb_sea_color forKey:@"sea_color"];
521 [
planetInfo setObject:amb_polar_land_color forKey:@"polar_land_color"];
522 [
planetInfo setObject:amb_polar_sea_color forKey:@"polar_sea_color"];
537 [
self paintVertex:i :planet_seed];
542 if ([dict objectForKey:
@"rotational_velocity"])
553 NSDictionary *atmoDict = dict;
554 if (
_texture !=
nil) atmoDict = [
NSDictionary dictionaryWithObjectsAndKeys:@"0", @"percent_cloud", [
NSNumber numberWithFloat:[
planetInfo oo_floatForKey:@"cloud_alpha" defaultValue:1.0]], @"cloud_alpha", nil];
555 if (atmo)
atmosphere = [[PlanetEntity alloc] initAsAtmosphereForPlanet:
self dictionary:atmoDict];
569 int deltaT = floor(fmod([
PLAYER clockTimeAdjusted], 86400));
785 uint8_t subdivideLevel = 2;
787 double drawFactor = [[UNIVERSE gameView] viewSize].width / 100.0;
792 subdivideLevel = 2 + floor(drawRatio2);
793 if (subdivideLevel > 4) subdivideLevel = 4;
798 subdivideLevel = [UNIVERSE reducedDetail]? 3 : 4;
804 OOGL(glPushAttrib(GL_ENABLE_BIT));
808 GLfloat specular[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
809 OOGL(glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular));
810 OOGL(glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 0));
826 ignoreDepthBuffer |= YES;
839 OOGL(glEnable(GL_BLEND));
856 GLfloat mat1[] = { 1.0, 1.0, 1.0, 1.0 };
862#if OO_TEXTURE_CUBE_MAP
863 OOGL(glDisable(GL_TEXTURE_2D));
864 OOGL(glEnable(GL_TEXTURE_CUBE_MAP));
871 OOGL(glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, mat1));
876 OOGL(glDisable(GL_TEXTURE_2D));
880 OOGL(glShadeModel(GL_SMOOTH));
883 if (ignoreDepthBuffer)
885 OOGL(glDisable(GL_DEPTH_TEST));
888 OOGL(glColor4fv(mat1));
889 OOGL(glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat1));
891 OOGL(glEnableClientState(GL_COLOR_ARRAY));
900 OOGL(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
912 OOGL(glDisableClientState(GL_TEXTURE_COORD_ARRAY));
927 OOGL(glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE));
928 OOGL(glEnable(GL_COLOR_MATERIAL));
932 OOGL(glDisable(GL_COLOR_MATERIAL));
937#if OO_TEXTURE_CUBE_MAP
940 OOGL(glDisable(GL_TEXTURE_CUBE_MAP));
941 OOGL(glEnable(GL_TEXTURE_2D));
945 OOGL(glDisableClientState(GL_COLOR_ARRAY));
946 OOGL(glDisableClientState(GL_TEXTURE_COORD_ARRAY));
947 OOGL(glEnable(GL_DEPTH_TEST));
965 if (ignoreDepthBuffer)
967 OOGL(glEnable(GL_DEPTH_TEST));
969 OOGL(glEnable(GL_TEXTURE_2D));
971 OOGL(glDisable(GL_BLEND));
1438- (void) paintVertex:(
unsigned) vi :(
int) seed
1441 BOOL isTextured = _texture !=
nil;
1443 GLfloat paint_land[4] = { 0.2, 0.9, 0.0, 1.0};
1444 GLfloat paint_sea[4] = { 0.0, 0.2, 0.9, 1.0};
1445 GLfloat paint_color[4];
1449 double pole_blend = v.z * v.z * polar_color_factor;
1450 if (pole_blend < 0.0) pole_blend = 0.0;
1451 if (pole_blend > 1.0) pole_blend = 1.0;
1453 paint_land[0] = (1.0 - pole_blend)*amb_land[0] + pole_blend*amb_polar_land[0];
1454 paint_land[1] = (1.0 - pole_blend)*amb_land[1] + pole_blend*amb_polar_land[1];
1455 paint_land[2] = (1.0 - pole_blend)*amb_land[2] + pole_blend*amb_polar_land[2];
1456 paint_sea[0] = (1.0 - pole_blend)*amb_sea[0] + pole_blend*amb_polar_sea[0];
1457 paint_sea[1] = (1.0 - pole_blend)*amb_sea[1] + pole_blend*amb_polar_sea[1];
1458 paint_sea[2] = (1.0 - pole_blend)*amb_sea[2] + pole_blend*amb_polar_sea[2];
1461 paint_land[3] = (1.0 - pole_blend)*amb_land[3] + pole_blend*amb_polar_land[3];
1462 paint_sea[3] = (1.0 - pole_blend)*amb_sea[3] + pole_blend*amb_polar_sea[3];
1465 ranrot_srand((uint32_t)(seed+v.x*1000+v.y*100+v.z*10));
1467 for (i = 0; i < 3; i++)
1470 paint_land[
i] += (cv - 0.5)*0.1;
1471 paint_sea[
i] += (cv - 0.5)*0.1;
1474 for (i = 0; i < 4; i++)
1477 paint_color[
i] = 1.0;
1479 paint_color[
i] = (r * paint_sea[
i])*0.01 + ((100 - r) * paint_land[i])*0.01;
1481 vertexdata.color_array[
vi*4 + i] = paint_color[
i];