29#define NEW_ATMOSPHERE 1
55#define OO_TERMINATOR_THRESHOLD_VECTOR_DEFAULT (make_vector(0.105, 0.18, 0.28))
57@interface OOPlanetEntity (Private) <OOGraphicsResetClient>
59- (void)setUpTerrainParametersWithSourceInfo:(NSDictionary*)sourceInfo targetInfo:(NSMutableDictionary*)targetInfo;
60- (void)setUpLandParametersWithSourceInfo:(NSDictionary*)sourceInfo targetInfo:(NSMutableDictionary*)targetInfo;
61- (void)setUpAtmosphereParametersWithSourceInfo:(NSDictionary*)sourceInfo targetInfo:(NSMutableDictionary*)targetInfo;
62- (void)setUpColorParametersWithSourceInfo:(NSDictionary*)sourceInfo targetInfo:(NSMutableDictionary*)targetInfo isAtmosphere:(BOOL)isAtmosphere;
63- (void)setUpTypeParametersWithSourceInfo:(NSDictionary*)sourceInfo targetInfo:(NSMutableDictionary*)targetInfo;
67@implementation OOPlanetEntity
72 NSMutableDictionary* planetInfo = [[UNIVERSE generateSystemData:s] mutableCopy];
73 [planetInfo autorelease];
75 [planetInfo oo_setBool:YES forKey:@"mainForLocalSystem"];
76 if (s != [
PLAYER systemID]) {
77 [planetInfo oo_setBool:YES forKey:@"isMiniature"];
79 return [
self initFromDictionary:planetInfo withAtmosphere:[planetInfo oo_boolForKey:@"has_atmosphere" defaultValue:YES] andSeed:[[UNIVERSE systemManager] getRandomSeedForSystem:s inGalaxy:[PLAYER galaxyNumber]] forSystem:s];
84- (id)initFromDictionary:(NSDictionary*)dict withAtmosphere:(BOOL)atmosphere andSeed:(
Random_Seed)seed forSystem:(
OOSystemID)systemID
87 dict = [NSDictionary dictionary];
94 scanClass = CLASS_NO_DRAW;
96 NSMutableDictionary* planetInfo = [[UNIVERSE generateSystemData:systemID] mutableCopy];
97 [planetInfo autorelease];
99 [
self setUpTypeParametersWithSourceInfo:dict targetInfo:planetInfo];
101 [
self setUpTerrainParametersWithSourceInfo:dict targetInfo:planetInfo];
104 NSString* seedStr = [dict oo_stringForKey:@"seed"];
105 if (seedStr !=
nil) {
110 OOLogERR(
@"planet.fromDict",
@"could not interpret \"%@\
" as planet seed, using default.", seedStr);
117 [
self setName:OOExpand([dict oo_stringForKey:KEY_PLANETNAME defaultValue:[planetInfo oo_stringForKey:KEY_PLANETNAME defaultValue:@"%H"]])];
119 int radius_km = [dict oo_intForKey:KEY_RADIUS defaultValue:[planetInfo oo_intForKey:KEY_RADIUS]];
120 collision_radius = radius_km * 10.0;
121 OOTechLevelID techLevel = [dict oo_intForKey:KEY_TECHLEVEL defaultValue:[planetInfo oo_intForKey:KEY_TECHLEVEL]];
125 _shuttlesOnGround = 1 + techLevel / 2;
126 _shuttleLaunchInterval = 3600.0 / (double)_shuttlesOnGround;
127 _lastLaunchTime = [UNIVERSE getTime] + 30.0 - _shuttleLaunchInterval;
130 int percent_land = [planetInfo oo_intForKey:@"percent_land" defaultValue:24 + (gen_rnd_number() % 48)];
131 [planetInfo setObject:[NSNumber numberWithFloat:0.01 * percent_land] forKey:@"land_fraction"];
133 int percent_ice = [planetInfo oo_intForKey:@"percent_ice" defaultValue:5];
134 [planetInfo setObject:[NSNumber numberWithFloat:0.01 * percent_ice] forKey:@"polar_fraction"];
140 _terminatorThresholdVector = [planetInfo oo_vectorForKey:@"terminator_threshold_vector" defaultValue:OO_TERMINATOR_THRESHOLD_VECTOR_DEFAULT];
144 [planetInfo setObject:[NSValue valueWithBytes:&planetNoiseSeed objCType:@encode(RANROTSeed)] forKey:@"noise_map_seed"];
145 [
self setUpLandParametersWithSourceInfo:dict targetInfo:planetInfo];
148 _airColorMixRatio = 0.5f;
151 _illuminationColor = [[planetInfo objectForKey:@"illumination_color"] retain];
165 [planetInfo setObject:[NSNumber numberWithFloat:0.01 * percent_land] forKey:@"cloud_fraction"];
166 [
self setUpAtmosphereParametersWithSourceInfo:dict targetInfo:planetInfo];
168 _airColor = [[planetInfo objectForKey:@"air_color"] retain];
169 _airColorMixRatio = [planetInfo oo_floatForKey:@"air_color_mix_ratio"];
171 _airDensity =
OOClamp_0_1_f([planetInfo oo_floatForKey:
@"air_density"]);
174 _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]];
185 _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]];
187 [_materialParameters retain];
189 _mesopause2 = (atmosphere) ? (kMesosphere + collision_radius) * (kMesosphere + collision_radius) : 0.0;
191 _normSpecMapName = [[dict oo_stringForKey:@"texture_normspec"] retain];
193 _textureName = [[dict oo_stringForKey:@"texture"] retain];
194 [
self setUpPlanetFromTexture:_textureName];
195 [_planetDrawable setRadius:collision_radius];
203 if ([dict objectForKey:
@"rotational_velocity"]) {
204 _rotationalVelocity = [dict oo_floatForKey:@"rotational_velocity" defaultValue:0.01f * randf()];
206 _rotationalVelocity = [planetInfo oo_floatForKey:@"rotation_speed" defaultValue:0.005f * randf()];
207 _rotationalVelocity *= [planetInfo oo_floatForKey:@"rotation_speed_factor" defaultValue:1.0f];
210 _atmosphereRotationalVelocity = [dict oo_floatForKey:@"atmosphere_rotational_velocity" defaultValue:0.01f * randf()];
213 energy = collision_radius * 1000.0f;
219 int deltaT = floor(fmod([
PLAYER clockTimeAdjusted], 86400));
223#ifdef OO_DUMP_PLANETINFO
224#define CPROP(PROP) OOLog(@"planetinfo.record", @ #PROP " = %@;", [(OOColor*)[planetInfo objectForKey:@ #PROP] descriptionComponents]);
225#define FPROP(PROP) OOLog(@"planetinfo.record", @ #PROP " = %f;", [planetInfo oo_floatForKey:@"" #PROP]);
227 CPROP(illumination_color);
228 FPROP(air_color_mix_ratio);
231 FPROP(cloud_fraction);
233 FPROP(land_fraction);
234 CPROP(polar_cloud_color);
235 CPROP(polar_land_color);
236 CPROP(polar_sea_color);
238 OOLog(
@"planetinfo.record",
@"rotation_speed = %f", _rotationalVelocity);
241 [
self setStatus:STATUS_ACTIVE];
248static Vector RandomHSBColor(
void)
266static Vector HSBColorWithColor(OOColor* color)
272static OOColor* ColorWithHSBColor(
Vector c)
277- (void)setUpTypeParametersWithSourceInfo:(NSDictionary*)sourceInfo targetInfo:(NSMutableDictionary*)targetInfo
279 [targetInfo oo_setBool:[sourceInfo oo_boolForKey:@"mainForLocalSystem"] forKey:@"mainForLocalSystem"];
280 [targetInfo oo_setBool:[sourceInfo oo_boolForKey:@"isMiniature"] forKey:@"isMiniature"];
283- (void)setUpTerrainParametersWithSourceInfo:(NSDictionary*)sourceInfo targetInfo:(NSMutableDictionary*)targetInfo
285 NSArray* keys = [NSArray arrayWithObjects:@"atmosphere_rotational_velocity", @"rotational_velocity", @"cloud_alpha", @"has_atmosphere", @"percent_cloud", @"percent_ice", @"percent_land", @"radius", @"seed", nil];
287 foreach (key, keys) {
288 id sval = [sourceInfo objectForKey:key];
290 [targetInfo setObject:sval forKey:key];
295- (void)setUpLandParametersWithSourceInfo:(NSDictionary*)sourceInfo targetInfo:(NSMutableDictionary*)targetInfo
297 [
self setUpColorParametersWithSourceInfo:sourceInfo targetInfo:targetInfo isAtmosphere:NO];
300- (void)setUpAtmosphereParametersWithSourceInfo:(NSDictionary*)sourceInfo targetInfo:(NSMutableDictionary*)targetInfo
302 [
self setUpColorParametersWithSourceInfo:sourceInfo targetInfo:targetInfo isAtmosphere:YES];
305- (void)setUpColorParametersWithSourceInfo:(NSDictionary*)sourceInfo targetInfo:(NSMutableDictionary*)targetInfo isAtmosphere:(BOOL)isAtmosphere
309 for (i = 0; i < 14; i++) {
313 Vector landHSB, seaHSB, landPolarHSB, seaPolarHSB, illumHSB;
314 Vector terminatorThreshold;
317 landHSB = RandomHSBColor();
321 seaHSB = RandomHSBColor();
325 if (seaHSB.
y < 0.22f)
326 seaHSB.
y = seaHSB.
y * 0.3f + 0.2f;
328 if (landHSB.
z > 0.66f)
334 landHSB = HSBColorWithColor(color);
340 seaHSB = HSBColorWithColor(color);
346 illumHSB = HSBColorWithColor(color);
348 NSString* illumHSBColorString = [sourceInfo oo_stringForKey:@"illumination_hsb_color"];
349 if (illumHSBColorString)
352 illumHSB = HSBColorWithColor([OOColor colorWithRed:0.8f green:0.8f blue:0.4f alpha:1.0f]);
358 landPolarHSB = HSBColorWithColor(color);
360 landPolarHSB = LighterHSBColor(landHSB);
365 seaPolarHSB = HSBColorWithColor(color);
367 seaPolarHSB = LighterHSBColor(seaHSB);
370 [targetInfo setObject:ColorWithHSBColor(landHSB) forKey:@"land_color"];
371 [targetInfo setObject:ColorWithHSBColor(seaHSB) forKey:@"sea_color"];
372 [targetInfo setObject:ColorWithHSBColor(landPolarHSB) forKey:@"polar_land_color"];
373 [targetInfo setObject:ColorWithHSBColor(seaPolarHSB) forKey:@"polar_sea_color"];
374 [targetInfo setObject:ColorWithHSBColor(illumHSB) forKey:@"illumination_color"];
376 landHSB = RandomHSBColor();
382 float cloudAlpha =
OOClamp_0_1_f([sourceInfo oo_floatForKey:
@"cloud_alpha" defaultValue:1.0f]);
383 [targetInfo setObject:[NSNumber numberWithFloat:cloudAlpha] forKey:@"cloud_alpha"];
388 seaHSB = HSBColorWithColor(color);
392 landHSB = HSBColorWithColor(color);
395 landPolarHSB =
vector_add(landHSB, LighterHSBColor(landHSB));
400 landPolarHSB = HSBColorWithColor(color);
402 [targetInfo setObject:ColorWithHSBColor(seaHSB) forKey:@"air_color"];
403 [targetInfo setObject:ColorWithHSBColor(landHSB) forKey:@"cloud_color"];
404 [targetInfo setObject:ColorWithHSBColor(landPolarHSB) forKey:@"polar_cloud_color"];
405 [targetInfo setObject:[NSNumber numberWithFloat:[sourceInfo oo_floatForKey:@"air_color_mix_ratio"]] forKey:@"air_color_mix_ratio"];
407 terminatorThreshold = [sourceInfo oo_vectorForKey:@"terminator_threshold_vector" defaultValue:OO_TERMINATOR_THRESHOLD_VECTOR_DEFAULT];
408 [targetInfo setObject:[NSString stringWithFormat:@"%f %f %f", terminatorThreshold.x, terminatorThreshold.y, terminatorThreshold.z] forKey:@"terminator_threshold_vector"];
411- (id)initAsMiniatureVersionOfPlanet:(OOPlanetEntity*)planet
423 scanClass = CLASS_NO_DRAW;
424 [
self setStatus:STATUS_COCKPIT_DISPLAY];
427 orientation = planet->orientation;
428 _rotationAxis = planet->_rotationAxis;
429 _atmosphereOrientation = planet->_atmosphereOrientation;
430 _rotationalVelocity = 0.04;
432 _terminatorThresholdVector = planet->_terminatorThresholdVector;
436 _planetDrawable = [planet->_planetDrawable copy];
437 [_planetDrawable setRadius:collision_radius];
440 _atmosphereDrawable = [planet->_atmosphereDrawable copy];
441 _cloudsShaderDrawable = [planet->_cloudsShaderDrawable copy];
442 _atmosphereShaderDrawable = [planet->_atmosphereShaderDrawable copy];
443 [_atmosphereDrawable setRadius:collision_radius + ATMOSPHERE_DEPTH * PLANET_MINIATURE_FACTOR * 2.0];
444 if (_cloudsShaderDrawable)
445 [_cloudsShaderDrawable setRadius:collision_radius + ATMOSPHERE_DEPTH * PLANET_MINIATURE_FACTOR * 2.0];
446 if (_atmosphereShaderDrawable)
447 [_atmosphereShaderDrawable setRadius:collision_radius + ATMOSPHERE_DEPTH * PLANET_MINIATURE_FACTOR * 2.0];
449 [_planetDrawable setLevelOfDetail:0.8f];
450 [_atmosphereDrawable setLevelOfDetail:0.8f];
451 if (_cloudsShaderDrawable)
452 [_cloudsShaderDrawable setLevelOfDetail:0.8f];
453 if (_atmosphereShaderDrawable)
454 [_atmosphereShaderDrawable setLevelOfDetail:0.8f];
464 DESTROY(_cloudsShaderDrawable);
465 DESTROY(_atmosphereShaderDrawable);
477- (NSString*)descriptionComponents
479 return [NSString stringWithFormat:@"position: %@ radius: %g m", HPVectorDescription([
self position]), [
self radius]];
484 [
super setOrientation:quat];
490 return collision_radius;
497 if (_atmosphereDrawable !=
nil)
502- (instancetype)miniatureVersion
504 return [[[[
self class] alloc] initAsMiniatureVersionOfPlanet:
self] autorelease];
509 [
super update:delta_t];
511 if (
EXPECT(!_miniature)) {
512 BOOL canDrawShaderAtmosphere = _atmosphereShaderDrawable && [UNIVERSE detailLevel] >=
DETAIL_LEVEL_SHADERS;
513 if (
EXPECT_NOT(_atmosphereDrawable && cam_zero_distance < _mesopause2)) {
514 NSAssert(_airColor !=
nil,
@"Expected a non-nil air colour for normal planet. Exiting.");
515 double alt = (sqrt(cam_zero_distance) - collision_radius) / kMesosphere;
516 double trueAlt = (sqrt(zero_distance) - collision_radius) / kMesosphere;
524 double aleph = 1.0 - alt;
525 double aleph2 = aleph * aleph;
535 double rate = ([PLAYER occlusionLevel] - 0.97) / 0.06;
537 if (
EXPECT(rate <= 1.0 && rate > 0.0)) {
553 if (
PLAYER->isSunlit && _airColor !=
nil)
554 mixColor = _airColor;
556 [UNIVERSE setSkyColorRed:[mixColor
redComponent] * aleph2
560 double atmosphereRadius = canDrawShaderAtmosphere ? collision_radius : collision_radius + (
ATMOSPHERE_DEPTH * alt);
561 [_atmosphereDrawable setRadius:atmosphereRadius];
562 if (_cloudsShaderDrawable)
563 [_cloudsShaderDrawable setRadius:atmosphereRadius];
564 if (_atmosphereShaderDrawable)
565 [_atmosphereShaderDrawable setRadius:collision_radius + (
ATMOSPHERE_DEPTH * alt)];
568 [UNIVERSE setAirResistanceFactor:OOClamp_0_1_f(1.0 - trueAlt)];
572 [_atmosphereDrawable setRadius:collision_radius + ATMOSPHERE_DEPTH];
573 if (_cloudsShaderDrawable)
574 [_cloudsShaderDrawable setRadius:collision_radius * ATMOSPHERE_DEPTH];
575 if (_atmosphereShaderDrawable)
576 [_atmosphereShaderDrawable setRadius:collision_radius + ATMOSPHERE_DEPTH];
578 if (canDrawShaderAtmosphere && [_atmosphereDrawable radius] != collision_radius) {
580 [_atmosphereDrawable setRadius:collision_radius];
581 if (_cloudsShaderDrawable)
582 [_cloudsShaderDrawable setRadius:collision_radius];
584 if ([
PLAYER findNearestPlanet] ==
self)
586 [UNIVERSE setAirResistanceFactor:0.0f];
590 double time = [UNIVERSE getTime];
592 if (_shuttlesOnGround > 0 && time > _lastLaunchTime + _shuttleLaunchInterval)
593 [
self launchShuttle];
600 [
self orientationChanged];
605- (BOOL)isFinishedLoading
607 OOMaterial* material = [
self material];
608 if (material !=
nil && ![material isFinishedLoading])
610 material = [
self atmosphereMaterial];
611 if (material !=
nil && ![material isFinishedLoading])
613 material = [
self atmosphereShaderMaterial];
614 if (material !=
nil && ![material isFinishedLoading])
619- (void)drawImmediate:(
bool)immediate translucent:(
bool)translucent
621 BOOL canDrawShaderAtmosphere = _atmosphereShaderDrawable && [UNIVERSE detailLevel] >=
DETAIL_LEVEL_SHADERS;
625 if (_miniature && ![
self isFinishedLoading])
629 if (
magnitude(cameraRelativePosition) > [
self radius] * 3000) {
632 if (![
UNIVERSE viewFrustumIntersectsSphereAt:cameraRelativePosition withRadius:([
self radius] +
ATMOSPHERE_DEPTH)]) {
641 [_planetDrawable calculateLevelOfDetailForViewDistance:cam_zero_distance];
642 [_atmosphereDrawable setLevelOfDetail:[_planetDrawable levelOfDetail]];
643 if (canDrawShaderAtmosphere) {
644 if (_cloudsShaderDrawable)
645 [_cloudsShaderDrawable setLevelOfDetail:[_planetDrawable levelOfDetail]];
646 [_atmosphereShaderDrawable setLevelOfDetail:[_planetDrawable levelOfDetail]];
662 [_planetDrawable renderOpaqueParts];
663 if (_atmosphereDrawable !=
nil) {
666 if (canDrawShaderAtmosphere) {
667 if (_cloudsShaderDrawable)
668 [_cloudsShaderDrawable renderTranslucentPartsOnOpaquePass];
669 [_atmosphereShaderDrawable renderTranslucentPartsOnOpaquePass];
671 [_atmosphereDrawable renderTranslucentPartsOnOpaquePass];
676#if OOLITE_HAVE_FIXED_THE_ABOVE_DESCRIBED_BUG_WHICH_WE_HAVENT
682 if (_atmosphereDrawable !=
nil) {
685 [_atmosphereDrawable renderTranslucentParts];
686 if (canDrawShaderAtmosphere)
687 [_atmosphereShaderDrawable renderTranslucentParts];
691 [_planetDrawable renderOpaqueParts];
700- (BOOL)checkCloseCollisionWith:(Entity*)other
705 ShipEntity* ship = (ShipEntity*)other;
706 if ([ship behaviour] == BEHAVIOUR_LAND_ON_PLANET) {
714- (BOOL)planetHasStation
717 ShipEntity* station =
nil;
718 station = [UNIVERSE nearestShipMatchingPredicate:IsStationPredicate
720 relativeToEntity:
self];
722 if (station &&
HPdistance([station position], position) < 4 * collision_radius)
731 if (_shuttlesOnGround == 0) {
734 if ([
PLAYER status] == STATUS_START_GAME) {
738 if (
self != [
UNIVERSE planet] && ![
self planetHasStation]) {
740 _shuttlesOnGround = 0;
746 float start_distance = collision_radius + 125.0f;
749 ShipEntity* shuttle_ship = [UNIVERSE newShipWithRole:@"shuttle"];
751 if ([[shuttle_ship crew]
count] == 0) {
760 [shuttle_ship
switchAITo:@"oolite-shuttleAI.js"];
761 [UNIVERSE addEntity:shuttle_ship];
763 _lastLaunchTime = [UNIVERSE getTime];
765 [shuttle_ship release];
769- (void)welcomeShuttle:(ShipEntity*)shuttle
784- (double)rotationalVelocity
786 return _rotationalVelocity;
789- (void)setRotationalVelocity:(
double)v
791 if ([
self hasAtmosphere]) {
794 _rotationalVelocity = v;
801 [_airColor getRed:&r green:&g blue:&b alpha:&a];
810- (void)setAirColor:(OOColor*)newColor
814 _airColor = [newColor retain];
819- (
Vector)illuminationColorAsVector
822 [_illuminationColor getRed:&r green:&g blue:&b alpha:&a];
826- (OOColor*)illuminationColor
828 return _illuminationColor;
831- (void)setIlluminationColor:(OOColor*)newColor
834 [_illuminationColor release];
835 _illuminationColor = [newColor retain];
840- (float)airColorMixRatio
842 return _airColorMixRatio;
845- (void)setAirColorMixRatio:(
float)newRatio
856- (void)setAirDensity:(
float)newDensity
861- (void)setTerminatorThresholdVector:(
Vector)newTerminatorThresholdVector
863 _terminatorThresholdVector.
x = newTerminatorThresholdVector.
x;
864 _terminatorThresholdVector.y = newTerminatorThresholdVector.
y;
865 _terminatorThresholdVector.z = newTerminatorThresholdVector.
z;
868- (
Vector)terminatorThresholdVector
870 return _terminatorThresholdVector;
875 return _atmosphereDrawable !=
nil;
879- (NSString*)textureFileName
881 return [_planetDrawable textureName];
884- (void)resetGraphicsState
887 [
self setUpPlanetFromTexture:_textureName];
890- (void)setTextureFileName:(NSString*)textureName
892 BOOL isMoon = _atmosphereDrawable ==
nil;
894 OOTexture* diffuseMap =
nil;
895 OOTexture* normalMap =
nil;
896 NSDictionary* macros =
nil;
903 const BOOL shadersOn = NO;
906 if (textureName !=
nil) {
907 NSDictionary* spec = [NSDictionary dictionaryWithObjectsAndKeys:textureName, @"name", @"yes", @"repeat_s", @"linear", @"min_filter", @"yes", @"cube_map", nil];
909 if (diffuseMap ==
nil)
913 if ([diffuseMap isCubeMap]) {
914 macros = [materialDefaults oo_dictionaryForKey:isMoon ? @"moon-customized-cubemap-macros" : @"planet-customized-cubemap-macros"];
916 macros = [materialDefaults oo_dictionaryForKey:isMoon ? @"moon-customized-macros" : @"planet-customized-macros"];
919 textureName =
@"dynamic";
922 if (_normSpecMapName) {
923 NSDictionary* nspec = [NSDictionary dictionaryWithObjectsAndKeys:_normSpecMapName, @"name", @"yes", @"repeat_s", @"linear", @"min_filter", @"yes", @"cube_map", nil];
925 if (normalMap !=
nil)
929 if ([normalMap isCubeMap]) {
930 macros = [materialDefaults oo_dictionaryForKey:isMoon ? @"moon-customized-cubemap-normspec-macros" : @"planet-customized-cubemap-normspec-macros"];
932 macros = [materialDefaults oo_dictionaryForKey:isMoon ? @"moon-customized-normspec-macros" : @"planet-customized-normspec-macros"];
939 secondaryTexture:(detailLevel >= DETAIL_LEVEL_SHADERS) ? &normalMap : NULL
940 withInfo:_materialParameters];
943 macros = [materialDefaults oo_dictionaryForKey:isMoon ? @"moon-dynamic-macros" : @"planet-dynamic-macros"];
945 textureName =
@"dynamic";
950 OOLog(
@"texture.planet.generate",
@"Preparing atmosphere for planet %@",
self);
952 OOTexture* atmosphere =
nil;
956 OOLog(
@"texture.planet.generate",
@"Planet %@ has atmosphere %@",
self, atmosphere);
958 OOSingleTextureMaterial* dynamicMaterial = [[
OOSingleTextureMaterial alloc] initWithName:@"dynamic" texture:atmosphere configuration:nil];
959 [_atmosphereDrawable setMaterial:dynamicMaterial];
962 NSMutableDictionary* aConfig = [[[materialDefaults oo_dictionaryForKey:@"atmosphere-material"] mutableCopy] autorelease];
963 [aConfig setObject:[NSArray arrayWithObjects:diffuseMap, normalMap, nil] forKey:@"_oo_texture_objects"];
965 NSDictionary* amacros = [materialDefaults oo_dictionaryForKey:@"atmosphere-dynamic-macros"];
967 OOMaterial* dynamicShaderMaterial = [OOShaderMaterial shaderMaterialWithName:@"dynamic"
968 configuration:aConfig
972 if (dynamicShaderMaterial ==
nil) {
973 DESTROY(_atmosphereShaderDrawable);
975 [_atmosphereShaderDrawable setMaterial:dynamicShaderMaterial];
978 NSMutableDictionary* cloudConfig = [[[materialDefaults oo_dictionaryForKey:@"clouds-dynamic-material"] mutableCopy] autorelease];
979 [cloudConfig setObject:[NSArray arrayWithObjects:atmosphere, nil] forKey:@"_oo_texture_objects"];
980 NSDictionary* cloudMacros = [materialDefaults oo_dictionaryForKey:@"clouds-dynamic-macros"];
982 OOMaterial* cloudsMaterial = [OOShaderMaterial shaderMaterialWithName:@"dynamic"
983 configuration:cloudConfig
986 if (cloudsMaterial ==
nil) {
987 DESTROY(_cloudsShaderDrawable);
989 [_cloudsShaderDrawable setMaterial:cloudsMaterial];
993 [dynamicMaterial release];
996 OOMaterial* material =
nil;
1000 NSMutableDictionary* config = [[[materialDefaults oo_dictionaryForKey:@"planet-material"] mutableCopy] autorelease];
1001 [config setObject:[NSArray arrayWithObjects:diffuseMap, normalMap, nil] forKey:@"_oo_texture_objects"];
1003 material = [OOShaderMaterial shaderMaterialWithName:textureName
1004 configuration:config
1006 bindingTarget:
self];
1009 if (material ==
nil) {
1011 [material autorelease];
1013 [_planetDrawable setMaterial:material];
1016- (BOOL)setUpPlanetFromTexture:(NSString*)textureName
1018 [
self setTextureFileName:textureName];
1022- (OOMaterial*)material
1024 return [_planetDrawable material];
1027- (OOMaterial*)atmosphereMaterial
1029 return [_atmosphereDrawable material];
1032- (OOMaterial*)atmosphereShaderMaterial
1034 if (!_atmosphereShaderDrawable)
1036 return [_atmosphereShaderDrawable material];
1044- (void)setName:(NSString*)name
1047 _name = [name retain];
OOINLINE float OOClamp_0_1_f(float value) INLINE_CONST_FUNC
OOINLINE HPVector vectorToHPVector(Vector v) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_add(HPVector a, HPVector b) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPdistance(HPVector v1, HPVector v2) INLINE_CONST_FUNC
#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_forward_from_quaternion(Quaternion quat) CONST_FUNC
struct Quaternion Quaternion
void quaternion_rotate_about_axis(Quaternion *quat, Vector axis, OOScalar angle) NONNULL_FUNC
const Quaternion kIdentityQuaternion
Vector vector_up_from_quaternion(Quaternion quat) CONST_FUNC
void quaternion_set_random(Quaternion *quat) NONNULL_FUNC
#define PLANET_MINIATURE_FACTOR
@ STELLAR_TYPE_NORMAL_PLANET
Random_Seed RandomSeedFromString(NSString *abcdefString)
BOOL ScanVectorFromString(NSString *xyzString, Vector *outVector)
OOINLINE Vector vector_add(Vector a, Vector b) INLINE_CONST_FUNC
OOINLINE OOScalar magnitude(Vector vec) INLINE_CONST_FUNC
OOINLINE Vector make_vector(OOScalar vx, OOScalar vy, OOScalar vz) INLINE_CONST_FUNC
OOINLINE OOScalar dot_product(Vector first, Vector second) INLINE_CONST_FUNC
const Vector kBasisYVector
OOINLINE void scale_vector(Vector *outVector, OOScalar factor) ALWAYS_INLINE_FUNC NONNULL_FUNC
OOINLINE Vector vector_multiply_scalar(Vector v, OOScalar s) INLINE_CONST_FUNC
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)
struct RANROTSeed RANROTSeed
OOINLINE int is_nil_seed(Random_Seed a_seed) INLINE_CONST_FUNC
struct Random_Seed Random_Seed