29#define NEW_ATMOSPHERE 1
56#define OO_TERMINATOR_THRESHOLD_VECTOR_DEFAULT (make_vector(0.105, 0.18, 0.28))
59@interface OOPlanetEntity (Private) <OOGraphicsResetClient>
61- (void) setUpTerrainParametersWithSourceInfo:(NSDictionary *)sourceInfo targetInfo:(NSMutableDictionary *)targetInfo;
62- (void) setUpLandParametersWithSourceInfo:(NSDictionary *)sourceInfo targetInfo:(NSMutableDictionary *)targetInfo;
63- (void) setUpAtmosphereParametersWithSourceInfo:(NSDictionary *)sourceInfo targetInfo:(NSMutableDictionary *)targetInfo;
64- (void) setUpColorParametersWithSourceInfo:(NSDictionary *)sourceInfo targetInfo:(NSMutableDictionary *)targetInfo isAtmosphere:(BOOL)isAtmosphere;
65- (void) setUpTypeParametersWithSourceInfo:(NSDictionary *)sourceInfo targetInfo:(NSMutableDictionary *)targetInfo;
70@implementation OOPlanetEntity
75 NSMutableDictionary *planetInfo = [[UNIVERSE generateSystemData:s] mutableCopy];
76 [planetInfo autorelease];
78 [planetInfo oo_setBool:YES forKey:@"mainForLocalSystem"];
79 if (s != [
PLAYER systemID])
81 [planetInfo oo_setBool:YES forKey:@"isMiniature"];
83 return [
self initFromDictionary:planetInfo withAtmosphere:[planetInfo oo_boolForKey:@"has_atmosphere" defaultValue:YES] andSeed:[[UNIVERSE systemManager] getRandomSeedForSystem:s inGalaxy:[PLAYER galaxyNumber]] forSystem:s];
90- (id) initFromDictionary:(NSDictionary *)dict withAtmosphere:(BOOL)atmosphere andSeed:(
Random_Seed)seed forSystem:(
OOSystemID)systemID
92 if (dict ==
nil) dict = [NSDictionary dictionary];
96 if (
self ==
nil)
return nil;
98 scanClass = CLASS_NO_DRAW;
100 NSMutableDictionary *planetInfo = [[UNIVERSE generateSystemData:systemID] mutableCopy];
101 [planetInfo autorelease];
103 [
self setUpTypeParametersWithSourceInfo:dict targetInfo:planetInfo];
105 [
self setUpTerrainParametersWithSourceInfo:dict targetInfo:planetInfo];
109 NSString *seedStr = [dict oo_stringForKey:@"seed"];
113 if (!
is_nil_seed(overrideSeed)) seed = overrideSeed;
114 else OOLogERR(
@"planet.fromDict",
@"could not interpret \"%@\
" as planet seed, using default.", seedStr);
121 [
self setName:OOExpand([dict oo_stringForKey:KEY_PLANETNAME defaultValue:[planetInfo oo_stringForKey:KEY_PLANETNAME defaultValue:@"%H"]])];
123 int radius_km = [dict oo_intForKey:KEY_RADIUS defaultValue:[planetInfo oo_intForKey:KEY_RADIUS]];
124 collision_radius = radius_km * 10.0;
125 OOTechLevelID techLevel = [dict oo_intForKey:KEY_TECHLEVEL defaultValue:[planetInfo oo_intForKey:KEY_TECHLEVEL]];
127 if (techLevel > 14) techLevel = 14;
128 _shuttlesOnGround = 1 + techLevel / 2;
129 _shuttleLaunchInterval = 3600.0 / (double)_shuttlesOnGround;
130 _lastLaunchTime = [UNIVERSE getTime] + 30.0 - _shuttleLaunchInterval;
133 int percent_land = [planetInfo oo_intForKey:@"percent_land" defaultValue:24 + (gen_rnd_number() % 48)];
134 [planetInfo setObject:[NSNumber numberWithFloat:0.01 * percent_land] forKey:@"land_fraction"];
136 int percent_ice = [planetInfo oo_intForKey:@"percent_ice" defaultValue:5];
137 [planetInfo setObject:[NSNumber numberWithFloat:0.01 * percent_ice] forKey:@"polar_fraction"];
144 _terminatorThresholdVector = [planetInfo oo_vectorForKey:@"terminator_threshold_vector" defaultValue:OO_TERMINATOR_THRESHOLD_VECTOR_DEFAULT];
148 [planetInfo setObject:[NSValue valueWithBytes:&planetNoiseSeed objCType:@encode(RANROTSeed)] forKey:@"noise_map_seed"];
149 [
self setUpLandParametersWithSourceInfo:dict targetInfo:planetInfo];
152 _airColorMixRatio = 0.5f;
155 _illuminationColor = [[planetInfo objectForKey:@"illumination_color"] retain];
169 [planetInfo setObject:[NSNumber numberWithFloat:0.01 * percent_land] forKey:@"cloud_fraction"];
170 [
self setUpAtmosphereParametersWithSourceInfo:dict targetInfo:planetInfo];
172 _airColor = [[planetInfo objectForKey:@"air_color"] retain];
173 _airColorMixRatio = [planetInfo oo_floatForKey:@"air_color_mix_ratio"];
175 _airDensity = OOClamp_0_1_f([planetInfo oo_floatForKey:
@"air_density"]);
178 _materialParameters = [planetInfo dictionaryWithValuesForKeys:[NSArray arrayWithObjects:@"cloud_fraction", @"air_color", @"air_color_mix_ratio", @"air_density", @"cloud_color", @"polar_cloud_color", @"cloud_alpha", @"land_fraction", @"land_color", @"sea_color", @"polar_land_color", @"polar_sea_color", @"noise_map_seed", @"economy", @"polar_fraction", @"isMiniature", @"perlin_3d", @"terminator_threshold_vector", nil]];
191 _materialParameters = [planetInfo dictionaryWithValuesForKeys:[NSArray arrayWithObjects:@"land_fraction", @"land_color", @"sea_color", @"polar_land_color", @"polar_sea_color", @"noise_map_seed", @"economy", @"polar_fraction", @"isMiniature", @"perlin_3d", @"terminator_threshold_vector", @"illumination_color", nil]];
193 [_materialParameters retain];
195 _mesopause2 = (atmosphere) ? (kMesosphere + collision_radius) * (kMesosphere + collision_radius) : 0.0;
197 _normSpecMapName = [[dict oo_stringForKey:@"texture_normspec"] retain];
199 _textureName = [[dict oo_stringForKey:@"texture"] retain];
200 [
self setUpPlanetFromTexture:_textureName];
201 [_planetDrawable setRadius:collision_radius];
209 if ([dict objectForKey:
@"rotational_velocity"])
211 _rotationalVelocity = [dict oo_floatForKey:@"rotational_velocity" defaultValue:0.01f * randf()];
215 _rotationalVelocity = [planetInfo oo_floatForKey:@"rotation_speed" defaultValue:0.005f * randf()];
216 _rotationalVelocity *= [planetInfo oo_floatForKey:@"rotation_speed_factor" defaultValue:1.0f];
219 _atmosphereRotationalVelocity = [dict oo_floatForKey:@"atmosphere_rotational_velocity" defaultValue:0.01f * randf()];
222 energy = collision_radius * 1000.0f;
228 int deltaT = floor(fmod([
PLAYER clockTimeAdjusted], 86400));
233#ifdef OO_DUMP_PLANETINFO
234#define CPROP(PROP) OOLog(@"planetinfo.record",@#PROP " = %@;",[(OOColor *)[planetInfo objectForKey:@#PROP] descriptionComponents]);
235#define FPROP(PROP) OOLog(@"planetinfo.record",@#PROP " = %f;",[planetInfo oo_floatForKey:@"" #PROP]);
237 CPROP(illumination_color);
238 FPROP(air_color_mix_ratio);
241 FPROP(cloud_fraction);
243 FPROP(land_fraction);
244 CPROP(polar_cloud_color);
245 CPROP(polar_land_color);
246 CPROP(polar_sea_color);
248 OOLog(
@"planetinfo.record",
@"rotation_speed = %f",_rotationalVelocity);
251 [
self setStatus:STATUS_ACTIVE];
259static Vector RandomHSBColor(
void)
270static Vector LighterHSBColor(Vector c)
281static Vector HSBColorWithColor(
OOColor *color)
284 return (Vector){ c.
h/360, c.
s, c.
b };
288static OOColor *ColorWithHSBColor(Vector c)
294- (void) setUpTypeParametersWithSourceInfo:(NSDictionary *)sourceInfo targetInfo:(NSMutableDictionary *)targetInfo
296 [targetInfo oo_setBool:[sourceInfo oo_boolForKey:@"mainForLocalSystem"] forKey:@"mainForLocalSystem"];
297 [targetInfo oo_setBool:[sourceInfo oo_boolForKey:@"isMiniature"] forKey:@"isMiniature"];
302- (void) setUpTerrainParametersWithSourceInfo:(NSDictionary *)sourceInfo targetInfo:(NSMutableDictionary *)targetInfo
304 NSArray *keys = [NSArray arrayWithObjects:@"atmosphere_rotational_velocity",@"rotational_velocity",@"cloud_alpha",@"has_atmosphere",@"percent_cloud",@"percent_ice",@"percent_land",@"radius",@"seed",nil];
306 foreach (key, keys) {
307 id sval = [sourceInfo objectForKey:key];
309 [targetInfo setObject:sval forKey:key];
316- (void) setUpLandParametersWithSourceInfo:(NSDictionary *)sourceInfo targetInfo:(NSMutableDictionary *)targetInfo
318 [
self setUpColorParametersWithSourceInfo:sourceInfo targetInfo:targetInfo isAtmosphere:NO];
322- (void) setUpAtmosphereParametersWithSourceInfo:(NSDictionary *)sourceInfo targetInfo:(NSMutableDictionary *)targetInfo
324 [
self setUpColorParametersWithSourceInfo:sourceInfo targetInfo:targetInfo isAtmosphere:YES];
328- (void) setUpColorParametersWithSourceInfo:(NSDictionary *)sourceInfo targetInfo:(NSMutableDictionary *)targetInfo isAtmosphere:(BOOL)isAtmosphere
332 for (i = 0; i < 14; i++)
337 Vector landHSB, seaHSB, landPolarHSB, seaPolarHSB, illumHSB;
338 Vector terminatorThreshold;
341 landHSB = RandomHSBColor();
347 seaHSB = RandomHSBColor();
349 while (dot_product(landHSB, seaHSB) > .80f);
352 if (seaHSB.y < 0.22f) seaHSB.y = seaHSB.y * 0.3f + 0.2f;
354 if (landHSB.z > 0.66f) landHSB.z = 0.66f;
358 if (color !=
nil) landHSB = HSBColorWithColor(color);
362 if (color !=
nil) seaHSB = HSBColorWithColor(color);
366 if (color !=
nil) illumHSB = HSBColorWithColor(color);
369 NSString *illumHSBColorString = [sourceInfo oo_stringForKey:@"illumination_hsb_color"];
371 else illumHSB = HSBColorWithColor([
OOColor colorWithRed:0.8f green:0.8f blue:0.4f alpha:1.0f]);
378 landPolarHSB = HSBColorWithColor(color);
382 landPolarHSB = LighterHSBColor(landHSB);
388 seaPolarHSB = HSBColorWithColor(color);
392 seaPolarHSB = LighterHSBColor(seaHSB);
395 [targetInfo setObject:ColorWithHSBColor(landHSB) forKey:@"land_color"];
396 [targetInfo setObject:ColorWithHSBColor(seaHSB) forKey:@"sea_color"];
397 [targetInfo setObject:ColorWithHSBColor(landPolarHSB) forKey:@"polar_land_color"];
398 [targetInfo setObject:ColorWithHSBColor(seaPolarHSB) forKey:@"polar_sea_color"];
399 [targetInfo setObject:ColorWithHSBColor(illumHSB) forKey:@"illumination_color"];
403 landHSB = RandomHSBColor();
406 seaHSB = vector_add(landHSB,((Vector){1.333, 0.6, 2}));
407 scale_vector(&seaHSB, 0.333);
409 float cloudAlpha = OOClamp_0_1_f([sourceInfo oo_floatForKey:
@"cloud_alpha" defaultValue:1.0f]);
410 [targetInfo setObject:[NSNumber numberWithFloat:cloudAlpha] forKey:@"cloud_alpha"];
414 if (color !=
nil) seaHSB = HSBColorWithColor(color);
417 if (color !=
nil) landHSB = HSBColorWithColor(color);
420 landPolarHSB = vector_add(landHSB,LighterHSBColor(landHSB));
421 scale_vector(&landPolarHSB, 0.5);
424 if (color !=
nil) landPolarHSB = HSBColorWithColor(color);
426 [targetInfo setObject:ColorWithHSBColor(seaHSB) forKey:@"air_color"];
427 [targetInfo setObject:ColorWithHSBColor(landHSB) forKey:@"cloud_color"];
428 [targetInfo setObject:ColorWithHSBColor(landPolarHSB) forKey:@"polar_cloud_color"];
429 [targetInfo setObject:[NSNumber numberWithFloat:[sourceInfo oo_floatForKey:@"air_color_mix_ratio"]] forKey:@"air_color_mix_ratio"];
431 terminatorThreshold = [sourceInfo oo_vectorForKey:@"terminator_threshold_vector" defaultValue:OO_TERMINATOR_THRESHOLD_VECTOR_DEFAULT];
432 [targetInfo setObject:[NSString stringWithFormat:@"%f %f %f", terminatorThreshold.x, terminatorThreshold.y, terminatorThreshold.z] forKey:@"terminator_threshold_vector"];
436- (id) initAsMiniatureVersionOfPlanet:(OOPlanetEntity *)planet
446 if (
self ==
nil)
return nil;
448 scanClass = CLASS_NO_DRAW;
449 [
self setStatus:STATUS_COCKPIT_DISPLAY];
452 orientation = planet->orientation;
453 _rotationAxis = planet->_rotationAxis;
454 _atmosphereOrientation = planet->_atmosphereOrientation;
455 _rotationalVelocity = 0.04;
457 _terminatorThresholdVector = planet->_terminatorThresholdVector;
461 _planetDrawable = [planet->_planetDrawable copy];
462 [_planetDrawable setRadius:collision_radius];
465 _atmosphereDrawable = [planet->_atmosphereDrawable copy];
466 _atmosphereShaderDrawable = [planet->_atmosphereShaderDrawable copy];
467 [_atmosphereDrawable setRadius:collision_radius + ATMOSPHERE_DEPTH * PLANET_MINIATURE_FACTOR * 2.0];
468 if (_atmosphereShaderDrawable) [_atmosphereShaderDrawable setRadius:collision_radius + ATMOSPHERE_DEPTH * PLANET_MINIATURE_FACTOR * 2.0];
470 [_planetDrawable setLevelOfDetail:0.8f];
471 [_atmosphereDrawable setLevelOfDetail:0.8f];
472 if (_atmosphereShaderDrawable) [_atmosphereShaderDrawable setLevelOfDetail:0.8f];
483 DESTROY(_atmosphereShaderDrawable);
496- (NSString*) descriptionComponents
498 return [NSString stringWithFormat:@"position: %@ radius: %g m", HPVectorDescription([
self position]), [
self radius]];
502- (void) setOrientation:(Quaternion) quat
504 [
super setOrientation: quat];
511 return collision_radius;
523- (instancetype) miniatureVersion
525 return [[[[
self class] alloc] initAsMiniatureVersionOfPlanet:self] autorelease];
531 [
super update:delta_t];
535 BOOL canDrawShaderAtmosphere = _atmosphereShaderDrawable && [UNIVERSE detailLevel] >=
DETAIL_LEVEL_SHADERS;
536 if (
EXPECT_NOT(_atmosphereDrawable && cam_zero_distance < _mesopause2))
538 NSAssert(_airColor !=
nil,
@"Expected a non-nil air colour for normal planet. Exiting.");
539 double alt = (sqrt(cam_zero_distance) - collision_radius) / kMesosphere;
540 double trueAlt = (sqrt(zero_distance) - collision_radius) / kMesosphere;
544 if (alt <= 0.0) alt = 1e-4;
547 double aleph = 1.0 - alt;
548 double aleph2 = aleph * aleph;
558 double rate = ([PLAYER occlusionLevel] - 0.97)/0.06;
560 if (
EXPECT(rate <= 1.0 && rate > 0.0))
579 if (
PLAYER->isSunlit && _airColor !=
nil) mixColor = _airColor;
581 [UNIVERSE setSkyColorRed:[mixColor
redComponent] * aleph2
585 double atmosphereRadius = canDrawShaderAtmosphere ? collision_radius : collision_radius + (
ATMOSPHERE_DEPTH * alt);
586 [_atmosphereDrawable setRadius:atmosphereRadius];
587 if (_atmosphereShaderDrawable) [_atmosphereShaderDrawable setRadius:collision_radius + (
ATMOSPHERE_DEPTH * alt)];
590 [UNIVERSE setAirResistanceFactor:OOClamp_0_1_f(1.0 - trueAlt)];
597 [_atmosphereDrawable setRadius:collision_radius + ATMOSPHERE_DEPTH];
598 if (_atmosphereShaderDrawable) [_atmosphereShaderDrawable setRadius:collision_radius + ATMOSPHERE_DEPTH];
600 if (canDrawShaderAtmosphere && [_atmosphereDrawable radius] != collision_radius)
603 [_atmosphereDrawable setRadius:collision_radius];
605 if ([
PLAYER findNearestPlanet] ==
self)
607 [UNIVERSE setAirResistanceFactor:0.0f];
611 double time = [UNIVERSE getTime];
613 if (_shuttlesOnGround > 0 && time > _lastLaunchTime + _shuttleLaunchInterval) [
self launchShuttle];
620 [
self orientationChanged];
626- (BOOL) isFinishedLoading
629 if (material !=
nil && ![material isFinishedLoading])
return NO;
630 material = [
self atmosphereMaterial];
631 if (material !=
nil && ![material isFinishedLoading])
return NO;
632 material = [
self atmosphereShaderMaterial];
633 if (material !=
nil && ![material isFinishedLoading])
return NO;
638- (void) drawImmediate:(
bool)immediate translucent:(
bool)translucent
640 BOOL canDrawShaderAtmosphere = _atmosphereShaderDrawable && [UNIVERSE detailLevel] >=
DETAIL_LEVEL_SHADERS;
642 if ([
UNIVERSE breakPatternHide])
return;
643 if (_miniature && ![
self isFinishedLoading])
return;
646 if (magnitude(cameraRelativePosition) > [
self radius]*3000) {
659 [_planetDrawable calculateLevelOfDetailForViewDistance:cam_zero_distance];
660 [_atmosphereDrawable setLevelOfDetail:[_planetDrawable levelOfDetail]];
661 if (canDrawShaderAtmosphere) [_atmosphereShaderDrawable setLevelOfDetail:[_planetDrawable levelOfDetail]];
676 [_planetDrawable renderOpaqueParts];
677 if (_atmosphereDrawable !=
nil)
681 [_atmosphereDrawable renderTranslucentPartsOnOpaquePass];
682 if (canDrawShaderAtmosphere) [_atmosphereShaderDrawable renderTranslucentPartsOnOpaquePass];
686#if OOLITE_HAVE_FIXED_THE_ABOVE_DESCRIBED_BUG_WHICH_WE_HAVENT
693 if (_atmosphereDrawable !=
nil)
697 [_atmosphereDrawable renderTranslucentParts];
698 if (canDrawShaderAtmosphere) [_atmosphereShaderDrawable renderTranslucentParts];
704 [_planetDrawable renderOpaqueParts];
713- (BOOL) checkCloseCollisionWith:(
Entity *)other
720 if ([ship behaviour] == BEHAVIOUR_LAND_ON_PLANET)
730- (BOOL) planetHasStation
734 station = [UNIVERSE nearestShipMatchingPredicate:IsStationPredicate
736 relativeToEntity:self];
738 if (station && HPdistance([station position], position) < 4 * collision_radius)
746- (void) launchShuttle
748 if (_shuttlesOnGround == 0)
752 if ([
PLAYER status] == STATUS_START_GAME)
757 if (
self != [
UNIVERSE planet] && ![
self planetHasStation])
760 _shuttlesOnGround = 0;
766 float start_distance = collision_radius + 125.0f;
769 ShipEntity *shuttle_ship = [UNIVERSE newShipWithRole:@"shuttle"];
772 if ([[shuttle_ship crew]
count] == 0)
782 [shuttle_ship
switchAITo:@"oolite-shuttleAI.js"];
783 [UNIVERSE addEntity:shuttle_ship];
785 _lastLaunchTime = [UNIVERSE getTime];
787 [shuttle_ship release];
810- (double) rotationalVelocity
812 return _rotationalVelocity;
816- (void) setRotationalVelocity:(
double) v
818 if ([
self hasAtmosphere])
822 _rotationalVelocity = v;
827- (Vector) airColorAsVector
830 [_airColor getRed:&r green:&g blue:&b alpha:&a];
831 return make_vector(r, g, b);
841- (void) setAirColor:(
OOColor *) newColor
846 _airColor = [newColor retain];
852- (Vector) illuminationColorAsVector
855 [_illuminationColor getRed:&r green:&g blue:&b alpha:&a];
856 return make_vector(r, g, b);
862 return _illuminationColor;
866- (void) setIlluminationColor:(
OOColor *) newColor
870 [_illuminationColor release];
871 _illuminationColor = [newColor retain];
877- (float) airColorMixRatio
879 return _airColorMixRatio;
883- (void) setAirColorMixRatio:(
float) newRatio
885 _airColorMixRatio = OOClamp_0_1_f(newRatio);
896- (void) setAirDensity: (
float)newDensity
898 _airDensity = OOClamp_0_1_f(newDensity);
902- (void) setTerminatorThresholdVector:(Vector) newTerminatorThresholdVector
904 _terminatorThresholdVector.x = newTerminatorThresholdVector.x;
905 _terminatorThresholdVector.y = newTerminatorThresholdVector.y;
906 _terminatorThresholdVector.z = newTerminatorThresholdVector.z;
910- (Vector) terminatorThresholdVector
912 return _terminatorThresholdVector;
916- (BOOL) hasAtmosphere
918 return _atmosphereDrawable !=
nil;
923- (NSString *) textureFileName
925 return [_planetDrawable textureName];
929- (void)resetGraphicsState
932 [
self setUpPlanetFromTexture:_textureName];
936- (void) setTextureFileName:(NSString *)textureName
938 BOOL isMoon = _atmosphereDrawable ==
nil;
942 NSDictionary *macros =
nil;
949 const BOOL shadersOn = NO;
952 if (textureName !=
nil)
954 NSDictionary *spec = [NSDictionary dictionaryWithObjectsAndKeys:textureName, @"name", @"yes", @"repeat_s", @"linear", @"min_filter", @"yes", @"cube_map", nil];
956 if (diffuseMap ==
nil)
return;
960 if ([diffuseMap isCubeMap])
962 macros = [materialDefaults oo_dictionaryForKey:isMoon ? @"moon-customized-cubemap-macros" : @"planet-customized-cubemap-macros"];
966 macros = [materialDefaults oo_dictionaryForKey:isMoon ? @"moon-customized-macros" : @"planet-customized-macros"];
969 else textureName =
@"dynamic";
972 if (_normSpecMapName)
974 NSDictionary *nspec = [NSDictionary dictionaryWithObjectsAndKeys:_normSpecMapName, @"name", @"yes", @"repeat_s", @"linear", @"min_filter", @"yes", @"cube_map", nil];
976 if (normalMap !=
nil)
981 if ([normalMap isCubeMap])
983 macros = [materialDefaults oo_dictionaryForKey:isMoon ? @"moon-customized-cubemap-normspec-macros" : @"planet-customized-cubemap-normspec-macros"];
987 macros = [materialDefaults oo_dictionaryForKey:isMoon ? @"moon-customized-normspec-macros" : @"planet-customized-normspec-macros"];
996 secondaryTexture:(detailLevel >= DETAIL_LEVEL_SHADERS) ? &normalMap : NULL
997 withInfo:_materialParameters];
1001 macros = [materialDefaults oo_dictionaryForKey:isMoon ? @"moon-dynamic-macros" : @"planet-dynamic-macros"];
1003 textureName =
@"dynamic";
1011 NSMutableDictionary *aConfig = [[[materialDefaults oo_dictionaryForKey:@"atmosphere-material"] mutableCopy] autorelease];
1012 [aConfig setObject:[NSArray arrayWithObjects:diffuseMap, normalMap, nil] forKey:@"_oo_texture_objects"];
1014 NSDictionary *amacros = [materialDefaults oo_dictionaryForKey:@"atmosphere-dynamic-macros"];
1016 OOMaterial *dynamicShaderMaterial = [OOShaderMaterial shaderMaterialWithName:@"dynamic"
1017 configuration:aConfig
1019 bindingTarget:self];
1021 if (dynamicShaderMaterial ==
nil)
1023 DESTROY(_atmosphereShaderDrawable);
1027 [_atmosphereShaderDrawable setMaterial:dynamicShaderMaterial];
1031 OOLog(
@"texture.planet.generate",
@"Preparing atmosphere for planet %@",
self);
1037 OOLog(
@"texture.planet.generate",
@"Planet %@ has atmosphere %@",
self,atmosphere);
1040 [_atmosphereDrawable setMaterial:dynamicMaterial];
1041 [dynamicMaterial release];
1049 NSMutableDictionary *config = [[[materialDefaults oo_dictionaryForKey:@"planet-material"] mutableCopy] autorelease];
1050 [config setObject:[NSArray arrayWithObjects:diffuseMap, normalMap, nil] forKey:@"_oo_texture_objects"];
1052 material = [OOShaderMaterial shaderMaterialWithName:textureName
1053 configuration:config
1055 bindingTarget:self];
1058 if (material ==
nil)
1061 [material autorelease];
1063 [_planetDrawable setMaterial:material];
1067- (BOOL) setUpPlanetFromTexture:(NSString *)textureName
1069 [
self setTextureFileName:textureName];
1076 return [_planetDrawable material];
1082 return [_atmosphereDrawable material];
1088 if(!_atmosphereShaderDrawable)
return nil;
1089 return [_atmosphereShaderDrawable material];
1099- (void) setName:(NSString *)name
1102 _name = [name retain];
#define OOLogERR(class, format,...)
#define OOLog(class, format,...)
OOMatrix OOMatrixForQuaternionRotation(Quaternion orientation)
void OOGLPushModelView(void)
void OOGLMultModelView(OOMatrix matrix)
OOMatrix OOGLPopModelView(void)
void OOGLWireframeModeOn(void)
void OOGLWireframeModeOff(void)
Vector vector_up_from_quaternion(Quaternion quat)
Vector vector_forward_from_quaternion(Quaternion quat)
void quaternion_set_random(Quaternion *quat)
const Quaternion kIdentityQuaternion
void quaternion_rotate_about_axis(Quaternion *quat, Vector axis, OOScalar angle)
#define PLANET_MINIATURE_FACTOR
@ STELLAR_TYPE_NORMAL_PLANET
Random_Seed RandomSeedFromString(NSString *abcdefString)
BOOL ScanVectorFromString(NSString *xyzString, Vector *outVector)
const Vector kBasisYVector
void setOrientation:(Quaternion quat)
void setScanClass:(OOScanClass sClass)
void setPosition:(HPVector posn)
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
OOColor * colorWithDescription:(id description)
OOColor * colorWithHue:saturation:brightness:alpha:(float hue,[saturation] float saturation,[brightness] float brightness,[alpha] float alpha)
OOHSBAComponents hsbaComponents()
OOColor * blendedColorWithFraction:ofColor:(float fraction,[ofColor] OOColor *color)
void registerClient:(id< OOGraphicsResetClient > client)
void unregisterClient:(id< OOGraphicsResetClient > client)
OOGraphicsResetManager * sharedManager()
instancetype atmosphereWithRadius:(float radius)
BOOL generateAtmosphereTexture:withInfo:(OOTexture **texture,[withInfo] NSDictionary *planetInfo)
void ensureFinishedLoading()
id textureWithConfiguration:(id configuration)
NSDictionary * materialDefaults()
void setCargoFlag:(OOCargoFlag flag)
void setSingleCrewWithRole:(NSString *crewRole)
void switchAITo:(NSString *aiString)
RANROTSeed RANROTGetFullSeed(void)
void setRandomSeed(RNG_Seed a_seed)
RNG_Seed currentRandomSeed(void)
void RANROTSetFullSeed(RANROTSeed seed)
void seed_for_planet_description(Random_Seed s_seed)
OOINLINE int is_nil_seed(Random_Seed a_seed) INLINE_CONST_FUNC