added planets to the background scene code and implemented putting them into the background of the system info screen
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@458 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
2ac149abbb
commit
b3a1e9b8ff
@ -399,7 +399,7 @@
|
||||
0831C5C809E3396D0058029A /* ScriptCompiler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ScriptCompiler.m; path = src/Core/ScriptCompiler.m; sourceTree = "<group>"; };
|
||||
083325DB09DDBCDE00F5B8E4 /* OOColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OOColor.h; path = src/Core/OOColor.h; sourceTree = "<group>"; };
|
||||
083325DC09DDBCDE00F5B8E4 /* OOColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OOColor.m; path = src/Core/OOColor.m; sourceTree = "<group>"; };
|
||||
0865432206B8447D000CA0AB /* OoliteDev.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OoliteDev.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
0865432206B8447D000CA0AB /* Oolite.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Oolite.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
0878FD2F086EF845004CB752 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
|
||||
08CB1FEC09D3F2AA001EA329 /* customsounds.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; name = customsounds.plist; path = Resources/Config/customsounds.plist; sourceTree = "<group>"; };
|
||||
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
||||
@ -1014,7 +1014,7 @@
|
||||
19C28FACFE9D520D11CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0865432206B8447D000CA0AB /* OoliteDev.app */,
|
||||
0865432206B8447D000CA0AB /* Oolite.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@ -1322,7 +1322,7 @@
|
||||
name = Oolite;
|
||||
productInstallPath = "$(HOME)/Applications";
|
||||
productName = Oolite;
|
||||
productReference = 0865432206B8447D000CA0AB /* OoliteDev.app */;
|
||||
productReference = 0865432206B8447D000CA0AB /* Oolite.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
@ -883,5 +883,9 @@
|
||||
<key>status-rating</key>
|
||||
<string>Rating:</string>
|
||||
|
||||
<!-- background scenes for GUI screens -->
|
||||
<key>gui-scene-show-planet</key>
|
||||
<string>target-planet 120 80 640</string>
|
||||
|
||||
</dict>
|
||||
</plist>
|
||||
|
@ -45,8 +45,10 @@ Your fair use and other rights are in no way affected by the above.
|
||||
#define PLANET_TYPE_SUN 200
|
||||
#define PLANET_TYPE_ATMOSPHERE 300
|
||||
#define PLANET_TYPE_CORONA 400
|
||||
#define PLANET_TYPE_MINIATURE 111
|
||||
|
||||
#define ATMOSPHERE_DEPTH 500.0
|
||||
#define PLANET_MINIATURE_FACTOR 0.00185
|
||||
|
||||
#define MAX_SUBDIVIDE 6
|
||||
#define MAX_TRI_INDICES 3*(20+80+320+1280+5120+20480)
|
||||
@ -119,6 +121,7 @@ void setUpSinTable();
|
||||
- (id) initAsAtmosphereForPlanet:(PlanetEntity *) planet;
|
||||
- (id) initAsCoronaForPlanet:(PlanetEntity *) planet;
|
||||
- (id) initWithSeed:(Random_Seed) p_seed fromUniverse:(Universe *) uni;
|
||||
- (id) initMiniatureFromPlanet:(PlanetEntity*) planet;
|
||||
|
||||
- (id) initPlanetFromDictionary:(NSDictionary*) dict inUniverse:(Universe *) uni;
|
||||
- (id) initMoonFromDictionary:(NSDictionary*) dict inUniverse:(Universe *) uni;
|
||||
@ -128,6 +131,11 @@ void drawBallVertices (double radius, int step, double z_distance);
|
||||
void drawCorona (double inner_radius, double outer_radius, int step, double z_distance, GLfloat* col4v1, GLfloat* col4v2);
|
||||
void drawActiveCorona (double inner_radius, double outer_radius, int step, double z_distance, GLfloat* col4v1, int rv);
|
||||
|
||||
- (int*) r_seed;
|
||||
- (int) planet_seed;
|
||||
- (BOOL) isTextured;
|
||||
- (GLuint) textureName;
|
||||
|
||||
- (double) polar_color_factor;
|
||||
- (GLfloat *) amb_land;
|
||||
- (GLfloat *) amb_polar_land;
|
||||
|
@ -274,7 +274,11 @@ void setUpSinTable()
|
||||
//
|
||||
position = planet->position;
|
||||
q_rotation = planet->q_rotation;
|
||||
|
||||
if (planet->planet_type == PLANET_TYPE_GREEN)
|
||||
collision_radius = planet->collision_radius + ATMOSPHERE_DEPTH; // atmosphere is 500m deep only
|
||||
if (planet->planet_type == PLANET_TYPE_MINIATURE)
|
||||
collision_radius = planet->collision_radius + ATMOSPHERE_DEPTH * PLANET_MINIATURE_FACTOR; // atmosphere is 500m deep only
|
||||
//
|
||||
shuttles_on_ground = 0;
|
||||
last_launch_time = 0.0;
|
||||
@ -537,6 +541,85 @@ void setUpSinTable()
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initMiniatureFromPlanet:(PlanetEntity*) planet
|
||||
{
|
||||
int i;
|
||||
double aleph = 1.0 / sqrt(2.0);
|
||||
//
|
||||
self = [super init];
|
||||
//
|
||||
isTextured = [planet isTextured];
|
||||
textureName = [planet textureName]; //debug texture
|
||||
//
|
||||
planet_seed = [planet planet_seed]; // pseudo-random set-up for vertex colours
|
||||
|
||||
shuttles_on_ground = 0;
|
||||
last_launch_time = 8400.0;
|
||||
shuttle_launch_interval = 8400.0;
|
||||
|
||||
//NSLog(@"shuttles on ground:%d launch_interval:%.1f minutes", shuttles_on_ground, shuttle_launch_interval/60);
|
||||
|
||||
collision_radius = [planet collisionRadius] * PLANET_MINIATURE_FACTOR; // teeny tiny
|
||||
//
|
||||
scan_class = CLASS_NO_DRAW;
|
||||
status = STATUS_DEMO;
|
||||
//
|
||||
q_rotation.w = aleph; // represents a 90 degree rotation around x axis
|
||||
q_rotation.x = aleph; // (I hope!)
|
||||
q_rotation.y = 0.0;
|
||||
q_rotation.z = 0.0;
|
||||
//
|
||||
planet_type = PLANET_TYPE_MINIATURE; // generic planet type
|
||||
//
|
||||
for (i = 0; i < 5; i++)
|
||||
displayListNames[i] = 0; // empty for now!
|
||||
//
|
||||
[self setModel:(isTextured)? @"icostextured.dat" : @"icosahedron.dat"];
|
||||
//
|
||||
[self rescaleTo:1.0];
|
||||
//
|
||||
|
||||
//
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
amb_land[i] = [planet amb_land][i];
|
||||
amb_sea[i] = [planet amb_sea][i];
|
||||
amb_polar_land[i] = [planet amb_polar_land][i];
|
||||
amb_polar_sea[i] = [planet amb_polar_sea][i];
|
||||
}
|
||||
|
||||
[self initialiseBaseVertexArray];
|
||||
|
||||
int* planet_r_seed = [planet r_seed];
|
||||
for (i = 0; i < n_vertices; i++)
|
||||
r_seed[i] = planet_r_seed[i]; // land or sea
|
||||
[self initialiseBaseTerrainArray: -1]; // use the vertices we just set up
|
||||
|
||||
for (i = 0; i < next_free_vertex; i++)
|
||||
[self paintVertex:i :planet_seed];
|
||||
|
||||
[self scaleVertices];
|
||||
|
||||
// set speed of rotation
|
||||
rotational_velocity = 0.05;
|
||||
|
||||
// do atmosphere
|
||||
//
|
||||
atmosphere = [[PlanetEntity alloc] initAsAtmosphereForPlanet:self];
|
||||
[atmosphere setUniverse:universe];
|
||||
|
||||
//
|
||||
usingVAR = [self OGL_InitVAR];
|
||||
//
|
||||
if (usingVAR)
|
||||
[self OGL_AssignVARMemory:sizeof(VertexData) :(void *)&vertexdata :0];
|
||||
//
|
||||
//
|
||||
isPlanet = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initPlanetFromDictionary:(NSDictionary*) dict inUniverse:(Universe *) uni
|
||||
{
|
||||
int i;
|
||||
@ -930,6 +1013,8 @@ void setUpSinTable()
|
||||
NSString* type_string;
|
||||
switch (planet_type)
|
||||
{
|
||||
case PLANET_TYPE_MINIATURE :
|
||||
type_string = @"PLANET_TYPE_MINIATURE"; break;
|
||||
case PLANET_TYPE_SUN :
|
||||
type_string = @"PLANET_TYPE_SUN"; break;
|
||||
case PLANET_TYPE_GREEN :
|
||||
@ -941,7 +1026,7 @@ void setUpSinTable()
|
||||
default :
|
||||
type_string = @"UNKNOWN";
|
||||
}
|
||||
NSString* result = [[NSString alloc] initWithFormat:@"<PlanetEntity %@ diameter %.0fkm>", type_string, 0.001 * collision_radius];
|
||||
NSString* result = [[NSString alloc] initWithFormat:@"<PlanetEntity %@ diameter %.3fkm>", type_string, 0.001 * collision_radius];
|
||||
return [result autorelease];
|
||||
}
|
||||
|
||||
@ -949,6 +1034,7 @@ void setUpSinTable()
|
||||
{
|
||||
switch (planet_type)
|
||||
{
|
||||
case PLANET_TYPE_MINIATURE :
|
||||
case PLANET_TYPE_ATMOSPHERE :
|
||||
case PLANET_TYPE_CORONA :
|
||||
return NO;
|
||||
@ -1007,7 +1093,9 @@ void setUpSinTable()
|
||||
shuttles_on_ground--;
|
||||
last_launch_time = ugt;
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
case PLANET_TYPE_MINIATURE :
|
||||
// normal planetary rotation
|
||||
quaternion_rotate_about_y( &q_rotation, rotational_velocity * delta_t);
|
||||
quaternion_normalise(&q_rotation);
|
||||
@ -1027,7 +1115,6 @@ void setUpSinTable()
|
||||
[universe setSky_clear_color:0.8 * aleph * aleph :0.8 * aleph * aleph :0.9 * aleph :aleph]; // test - blue
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PLANET_TYPE_ATMOSPHERE :
|
||||
@ -1180,6 +1267,8 @@ void setUpSinTable()
|
||||
subdivideLevel = 4;
|
||||
}
|
||||
|
||||
if (planet_type == PLANET_TYPE_MINIATURE)
|
||||
subdivideLevel = 3;
|
||||
|
||||
glFrontFace(GL_CW); // face culling - front faces are AntiClockwise!
|
||||
|
||||
@ -1198,6 +1287,7 @@ void setUpSinTable()
|
||||
case PLANET_TYPE_ATMOSPHERE :
|
||||
glMultMatrixf(rotMatrix); // rotate the clouds!
|
||||
case PLANET_TYPE_GREEN :
|
||||
case PLANET_TYPE_MINIATURE :
|
||||
if (!translucent)
|
||||
{
|
||||
GLfloat mat1[] = { 1.0, 1.0, 1.0, 1.0 }; // opaque white
|
||||
@ -1517,6 +1607,23 @@ void drawActiveCorona (double inner_radius, double outer_radius, int step, doubl
|
||||
glEnd();
|
||||
}
|
||||
|
||||
- (int*) r_seed
|
||||
{
|
||||
return r_seed;
|
||||
}
|
||||
- (int) planet_seed
|
||||
{
|
||||
return planet_seed;
|
||||
}
|
||||
- (BOOL) isTextured
|
||||
{
|
||||
return isTextured;
|
||||
}
|
||||
- (GLuint) textureName
|
||||
{
|
||||
return textureName;
|
||||
}
|
||||
|
||||
- (double) polar_color_factor
|
||||
{
|
||||
return polar_color_factor;
|
||||
@ -1801,14 +1908,17 @@ int baseVertexIndexForEdge(int va, int vb, BOOL textured)
|
||||
{
|
||||
int vi;
|
||||
// set first 12 or 14 vertices
|
||||
if (percent_land >= 0)
|
||||
{
|
||||
for (vi = 0; vi < n_vertices; vi++)
|
||||
{
|
||||
if (gen_rnd_number() < percent_land)
|
||||
if (gen_rnd_number() < 256 * percent_land / 100)
|
||||
base_terrain_array[vi] = 0; // land
|
||||
else
|
||||
base_terrain_array[vi] = 100; // sea
|
||||
|
||||
}
|
||||
}
|
||||
//
|
||||
// for the next levels of subdivision simply build up from the level below!...
|
||||
//
|
||||
|
@ -2079,6 +2079,62 @@ static int shipsFound;
|
||||
return YES;
|
||||
}
|
||||
//
|
||||
// Add local planet model:
|
||||
//
|
||||
if ([i_key isEqual:@"local-planet"])
|
||||
{
|
||||
if ([i_info count] != 4) // must be local-planet_x_y_z
|
||||
return NO; // 0........... 1 2 3
|
||||
|
||||
PlanetEntity* doppelganger = [[PlanetEntity alloc] initMiniatureFromPlanet:[universe planet]]; // retain count = 1
|
||||
if (!doppelganger)
|
||||
return NO;
|
||||
|
||||
Vector model_p0 = [Entity vectorFromString:[[i_info subarrayWithRange:NSMakeRange( 1, 3)] componentsJoinedByString:@" "]];
|
||||
Quaternion model_q = { 0.707, 0.707, 0.0, 0.0 };
|
||||
model_p0.x += off.x;
|
||||
model_p0.y += off.y;
|
||||
model_p0.z += off.z;
|
||||
|
||||
if (debug)
|
||||
NSLog(@"::::: adding local-planet to scene:'%@'", doppelganger);
|
||||
[doppelganger setQRotation: model_q];
|
||||
[doppelganger setPosition: model_p0];
|
||||
[universe addEntity: doppelganger];
|
||||
|
||||
[doppelganger release];
|
||||
return YES;
|
||||
}
|
||||
//
|
||||
// Add target planet model:
|
||||
//
|
||||
if ([i_key isEqual:@"target-planet"])
|
||||
{
|
||||
if ([i_info count] != 4) // must be local-planet_x_y_z
|
||||
return NO; // 0........... 1 2 3
|
||||
|
||||
PlanetEntity* targetplanet = [[[PlanetEntity alloc] initWithSeed:target_system_seed fromUniverse:universe] autorelease];
|
||||
|
||||
PlanetEntity* doppelganger = [[PlanetEntity alloc] initMiniatureFromPlanet:targetplanet]; // retain count = 1
|
||||
if (!doppelganger)
|
||||
return NO;
|
||||
|
||||
Vector model_p0 = [Entity vectorFromString:[[i_info subarrayWithRange:NSMakeRange( 1, 3)] componentsJoinedByString:@" "]];
|
||||
Quaternion model_q = { 0.707, 0.707, 0.0, 0.0 };
|
||||
model_p0.x += off.x;
|
||||
model_p0.y += off.y;
|
||||
model_p0.z += off.z;
|
||||
|
||||
if (debug)
|
||||
NSLog(@"::::: adding target-planet to scene:'%@'", doppelganger);
|
||||
[doppelganger setQRotation: model_q];
|
||||
[doppelganger setPosition: model_p0];
|
||||
[universe addEntity: doppelganger];
|
||||
|
||||
[doppelganger release];
|
||||
return YES;
|
||||
}
|
||||
//
|
||||
// Add billboard model:
|
||||
//
|
||||
if ([i_key isEqual:@"billboard"])
|
||||
|
@ -2391,7 +2391,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
PlanetEntity* nearest_planet = nil;
|
||||
int i;
|
||||
for (i = 0; ((i < ent_count)&&(!nearest_planet)); i++)
|
||||
if (uni_entities[i]->isPlanet)
|
||||
if ((uni_entities[i]->isPlanet) && (uni_entities[i]->status != STATUS_DEMO))
|
||||
nearest_planet = [uni_entities[i] retain]; // retained
|
||||
|
||||
if (!nearest_planet)
|
||||
@ -2403,14 +2403,6 @@ double scoopSoundPlayTime = 0.0;
|
||||
|
||||
[nearest_planet release];
|
||||
|
||||
// PlanetEntity *planet = [universe planet];
|
||||
// PlanetEntity *sun = [universe sun];
|
||||
// double planet_zd = (planet)? planet->zero_distance : PLAYER_SUPER_ALTITUDE2;
|
||||
// double sun_zd = (sun)? sun->zero_distance : PLAYER_SUPER_ALTITUDE2;
|
||||
// double planet_cr = (planet)? planet->collision_radius : 0;
|
||||
// double sun_cr = (sun)? sun->collision_radius : 0;
|
||||
// double alt = (planet_zd < sun_zd) ? (sqrt(planet_zd) - planet_cr) : (sqrt(sun_zd) - sun_cr);
|
||||
|
||||
alt /= PLAYER_DIAL_MAX_ALTITUDE;
|
||||
|
||||
if (alt > 1.0)
|
||||
@ -4559,6 +4551,14 @@ double scoopSoundPlayTime = 0.0;
|
||||
[universe setDisplayText: YES];
|
||||
[universe setDisplayCursor: NO];
|
||||
[universe setViewDirection: VIEW_DOCKED];
|
||||
|
||||
// set gui background to show a copy of the planet
|
||||
//
|
||||
[universe removeDemoShips];
|
||||
[self setBackgroundFromDescriptionsKey:@"gui-scene-show-planet"];
|
||||
//
|
||||
////
|
||||
|
||||
}
|
||||
|
||||
- (NSArray *) markedDestinations
|
||||
|
Loading…
x
Reference in New Issue
Block a user