Lots of fiddling around, most of it reverted. Meh. New shinier (and simpler) sky.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@968 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
3c4929873f
commit
17e40ba6c7
@ -268,6 +268,7 @@
|
|||||||
1A26D0EB0BCF9D3B0073F257 /* OOTextureLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A26D0E50BCF9D3B0073F257 /* OOTextureLoader.m */; };
|
1A26D0EB0BCF9D3B0073F257 /* OOTextureLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A26D0E50BCF9D3B0073F257 /* OOTextureLoader.m */; };
|
||||||
1A26D0F50BCF9D8D0073F257 /* pngusr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A26D0F40BCF9D8D0073F257 /* pngusr.h */; };
|
1A26D0F50BCF9D8D0073F257 /* pngusr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A26D0F40BCF9D8D0073F257 /* pngusr.h */; };
|
||||||
1A26D0F60BCF9D8D0073F257 /* pngusr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A26D0F40BCF9D8D0073F257 /* pngusr.h */; };
|
1A26D0F60BCF9D8D0073F257 /* pngusr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A26D0F40BCF9D8D0073F257 /* pngusr.h */; };
|
||||||
|
1A28CAB50BFF404F000EBA08 /* planetinfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1A28CAB40BFF404F000EBA08 /* planetinfo.plist */; };
|
||||||
1A29967E0B9F064C002D2149 /* OOCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A29967C0B9F064C002D2149 /* OOCache.h */; };
|
1A29967E0B9F064C002D2149 /* OOCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A29967C0B9F064C002D2149 /* OOCache.h */; };
|
||||||
1A29967F0B9F064C002D2149 /* OOCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A29967D0B9F064C002D2149 /* OOCache.m */; };
|
1A29967F0B9F064C002D2149 /* OOCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A29967D0B9F064C002D2149 /* OOCache.m */; };
|
||||||
1A2A16680BD10B1200152975 /* OOSingleTextureMaterial.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A16660BD10B1200152975 /* OOSingleTextureMaterial.m */; };
|
1A2A16680BD10B1200152975 /* OOSingleTextureMaterial.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A16660BD10B1200152975 /* OOSingleTextureMaterial.m */; };
|
||||||
@ -1076,6 +1077,7 @@
|
|||||||
1A26D0E40BCF9D3B0073F257 /* OOPNGTextureLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOPNGTextureLoader.h; sourceTree = "<group>"; };
|
1A26D0E40BCF9D3B0073F257 /* OOPNGTextureLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOPNGTextureLoader.h; sourceTree = "<group>"; };
|
||||||
1A26D0E50BCF9D3B0073F257 /* OOTextureLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOTextureLoader.m; sourceTree = "<group>"; };
|
1A26D0E50BCF9D3B0073F257 /* OOTextureLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOTextureLoader.m; sourceTree = "<group>"; };
|
||||||
1A26D0F40BCF9D8D0073F257 /* pngusr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pngusr.h; path = src/Core/Materials/pngusr.h; sourceTree = SOURCE_ROOT; };
|
1A26D0F40BCF9D8D0073F257 /* pngusr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pngusr.h; path = src/Core/Materials/pngusr.h; sourceTree = SOURCE_ROOT; };
|
||||||
|
1A28CAB40BFF404F000EBA08 /* planetinfo.plist */ = {isa = PBXFileReference; explicitFileType = text.plist; fileEncoding = 4; path = planetinfo.plist; sourceTree = "<group>"; };
|
||||||
1A29967C0B9F064C002D2149 /* OOCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOCache.h; sourceTree = "<group>"; };
|
1A29967C0B9F064C002D2149 /* OOCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOCache.h; sourceTree = "<group>"; };
|
||||||
1A29967D0B9F064C002D2149 /* OOCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOCache.m; sourceTree = "<group>"; };
|
1A29967D0B9F064C002D2149 /* OOCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOCache.m; sourceTree = "<group>"; };
|
||||||
1A2A16660BD10B1200152975 /* OOSingleTextureMaterial.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOSingleTextureMaterial.m; sourceTree = "<group>"; };
|
1A2A16660BD10B1200152975 /* OOSingleTextureMaterial.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOSingleTextureMaterial.m; sourceTree = "<group>"; };
|
||||||
@ -1439,6 +1441,7 @@
|
|||||||
1AED74C70BBA3CAA009410CD /* logcontrol.plist.xml */,
|
1AED74C70BBA3CAA009410CD /* logcontrol.plist.xml */,
|
||||||
1A71E4490BCD5C4200CD5C13 /* material-defaults.plist */,
|
1A71E4490BCD5C4200CD5C13 /* material-defaults.plist */,
|
||||||
1A2316E90B9CFAD700EF0852 /* missiontext.plist */,
|
1A2316E90B9CFAD700EF0852 /* missiontext.plist */,
|
||||||
|
1A28CAB40BFF404F000EBA08 /* planetinfo.plist */,
|
||||||
1A2316EB0B9CFAD700EF0852 /* shipdata.plist */,
|
1A2316EB0B9CFAD700EF0852 /* shipdata.plist */,
|
||||||
1A2316EC0B9CFAD700EF0852 /* shipyard.plist */,
|
1A2316EC0B9CFAD700EF0852 /* shipyard.plist */,
|
||||||
1A2316ED0B9CFAD700EF0852 /* speech_pronunciation_guide.plist */,
|
1A2316ED0B9CFAD700EF0852 /* speech_pronunciation_guide.plist */,
|
||||||
@ -1690,15 +1693,12 @@
|
|||||||
children = (
|
children = (
|
||||||
25F3E63A0994F08A002F25FD /* OOOpenGL.h */,
|
25F3E63A0994F08A002F25FD /* OOOpenGL.h */,
|
||||||
1A2A1DEA0BD2A28E00152975 /* OOMacroOpenGL.h */,
|
1A2A1DEA0BD2A28E00152975 /* OOMacroOpenGL.h */,
|
||||||
1A2A1B120BD2774300152975 /* OODrawable.h */,
|
|
||||||
1A2A1B130BD2774300152975 /* OODrawable.m */,
|
|
||||||
1A2A1CA80BD2914F00152975 /* OOMesh.h */,
|
|
||||||
1A2A1CA90BD2914F00152975 /* OOMesh.m */,
|
|
||||||
1A43234A0BCFC9BB00F65914 /* OOOpenGLExtensionManager.h */,
|
1A43234A0BCFC9BB00F65914 /* OOOpenGLExtensionManager.h */,
|
||||||
1A43234B0BCFC9BB00F65914 /* OOOpenGLExtensionManager.m */,
|
1A43234B0BCFC9BB00F65914 /* OOOpenGLExtensionManager.m */,
|
||||||
25161100099544380037C2E1 /* OpenGLSprite.h */,
|
25161100099544380037C2E1 /* OpenGLSprite.h */,
|
||||||
251610FF099544380037C2E1 /* OpenGLSprite.m */,
|
251610FF099544380037C2E1 /* OpenGLSprite.m */,
|
||||||
08125F0809F9083F00AB9BF9 /* OOGLDefs.h */,
|
08125F0809F9083F00AB9BF9 /* OOGLDefs.h */,
|
||||||
|
1ADC3F850BFA1388000E0F89 /* Drawables */,
|
||||||
1A71DDD30BCC0EEF00CD5C13 /* Materials */,
|
1A71DDD30BCC0EEF00CD5C13 /* Materials */,
|
||||||
);
|
);
|
||||||
name = Graphics;
|
name = Graphics;
|
||||||
@ -2087,6 +2087,17 @@
|
|||||||
path = Doc;
|
path = Doc;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
1ADC3F850BFA1388000E0F89 /* Drawables */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
1A2A1B120BD2774300152975 /* OODrawable.h */,
|
||||||
|
1A2A1B130BD2774300152975 /* OODrawable.m */,
|
||||||
|
1A2A1CA80BD2914F00152975 /* OOMesh.h */,
|
||||||
|
1A2A1CA90BD2914F00152975 /* OOMesh.m */,
|
||||||
|
);
|
||||||
|
name = Drawables;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
1AEAAC6C0BA457C3000705D0 /* SpiderMonkey headers */ = {
|
1AEAAC6C0BA457C3000705D0 /* SpiderMonkey headers */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -2434,6 +2445,7 @@
|
|||||||
25F3E8A80994FE65002F25FD /* oolite-expansion-document.icns in Resources */,
|
25F3E8A80994FE65002F25FD /* oolite-expansion-document.icns in Resources */,
|
||||||
25F3E8A90994FE65002F25FD /* oolite-icon.icns in Resources */,
|
25F3E8A90994FE65002F25FD /* oolite-icon.icns in Resources */,
|
||||||
25F3E8B40994FE9B002F25FD /* InfoPlist.strings in Resources */,
|
25F3E8B40994FE9B002F25FD /* InfoPlist.strings in Resources */,
|
||||||
|
1A28CAB50BFF404F000EBA08 /* planetinfo.plist in Resources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -257,7 +257,7 @@ strings.conversion.randomSeed = inherit;
|
|||||||
texture.planet.generate = inherit;
|
texture.planet.generate = inherit;
|
||||||
|
|
||||||
|
|
||||||
$textureDebug = $troubleShootingDump;
|
$textureDebug = no;
|
||||||
texture.load.noName = $error;
|
texture.load.noName = $error;
|
||||||
texture.dealloc = $textureDebug;
|
texture.dealloc = $textureDebug;
|
||||||
texture.setUp = $textureDebug;
|
texture.setUp = $textureDebug;
|
||||||
@ -272,7 +272,7 @@ textureLoader.queueTask.inconsistency = $error;
|
|||||||
textureLoader.unknownType = $error;
|
textureLoader.unknownType = $error;
|
||||||
|
|
||||||
|
|
||||||
universe.populate = $troubleShootingDump; // “Populating a system with…” message when generating a star system
|
universe.populate = no; // “Populating a system with…” message when generating a star system
|
||||||
universe.populate.witchspace = inherit;
|
universe.populate.witchspace = inherit;
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<key>$soundError</key>
|
<key>$soundError</key>
|
||||||
<string>$error</string>
|
<string>$error</string>
|
||||||
<key>$textureDebug</key>
|
<key>$textureDebug</key>
|
||||||
<string>$troubleShootingDump</string>
|
<string>no</string>
|
||||||
<key>$troubleShootingDump</key>
|
<key>$troubleShootingDump</key>
|
||||||
<string>yes</string>
|
<string>yes</string>
|
||||||
<key>_default</key>
|
<key>_default</key>
|
||||||
@ -425,7 +425,7 @@
|
|||||||
<key>unclassified</key>
|
<key>unclassified</key>
|
||||||
<string>inherit</string>
|
<string>inherit</string>
|
||||||
<key>universe.populate</key>
|
<key>universe.populate</key>
|
||||||
<string>$troubleShootingDump</string>
|
<string>no</string>
|
||||||
<key>universe.populate.witchspace</key>
|
<key>universe.populate.witchspace</key>
|
||||||
<string>inherit</string>
|
<string>inherit</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
@ -31,9 +31,9 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
static NSString * const kOOLogOpenGLExtensionsVAR = @"rendering.opengl.extensions.var";
|
static NSString * const kOOLogOpenGLExtensionsVAR = @"rendering.opengl.extensions.var";
|
||||||
static NSString * const kOOLogOpenGLStateDump = @"rendering.opengl.stateDump";
|
static NSString * const kOOLogOpenGLStateDump = @"rendering.opengl.stateDump";
|
||||||
static NSString * const kOOLogEntityDataNotFound = @"entity.loadMesh.error.fileNotFound";
|
static NSString * const kOOLogEntityDataNotFound = @"entity.loadMesh.failed.fileNotFound";
|
||||||
static NSString * const kOOLogEntityTooManyVertices = @"entity.loadMesh.error.tooManyVertices";
|
static NSString * const kOOLogEntityTooManyVertices = @"entity.loadMesh.failed.tooManyVertices";
|
||||||
static NSString * const kOOLogEntityTooManyFaces = @"entity.loadMesh.error.tooManyFaces";
|
static NSString * const kOOLogEntityTooManyFaces = @"entity.loadMesh.failed.tooManyFaces";
|
||||||
|
|
||||||
|
|
||||||
#if GL_APPLE_vertex_array_object
|
#if GL_APPLE_vertex_array_object
|
||||||
|
@ -124,7 +124,6 @@ void setUpSinTable();
|
|||||||
|
|
||||||
- (id) initAsSunWithColor:(OOColor *) sun_color;
|
- (id) initAsSunWithColor:(OOColor *) sun_color;
|
||||||
- (id) initAsAtmosphereForPlanet:(PlanetEntity *) planet;
|
- (id) initAsAtmosphereForPlanet:(PlanetEntity *) planet;
|
||||||
- (id) initAsCoronaForPlanet:(PlanetEntity *) planet;
|
|
||||||
- (id) initWithSeed:(Random_Seed) p_seed;
|
- (id) initWithSeed:(Random_Seed) p_seed;
|
||||||
- (id) initMiniatureFromPlanet:(PlanetEntity*) planet;
|
- (id) initMiniatureFromPlanet:(PlanetEntity*) planet;
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ MA 02110-1301, USA.
|
|||||||
#import "OOCharacter.h"
|
#import "OOCharacter.h"
|
||||||
#import "OOStringParsing.h"
|
#import "OOStringParsing.h"
|
||||||
#import "PlayerEntity.h"
|
#import "PlayerEntity.h"
|
||||||
|
#import "OOCollectionExtractors.h"
|
||||||
|
|
||||||
#define kOOLogUnconvertedNSLog @"unclassified.PlanetEntity"
|
#define kOOLogUnconvertedNSLog @"unclassified.PlanetEntity"
|
||||||
|
|
||||||
@ -186,7 +187,7 @@ void setUpSinTable()
|
|||||||
sun_diffuse[0] = 0.5 * (1.0 + r); // paler
|
sun_diffuse[0] = 0.5 * (1.0 + r); // paler
|
||||||
sun_diffuse[1] = 0.5 * (1.0 + g); // paler
|
sun_diffuse[1] = 0.5 * (1.0 + g); // paler
|
||||||
sun_diffuse[2] = 0.5 * (1.0 + b); // paler
|
sun_diffuse[2] = 0.5 * (1.0 + b); // paler
|
||||||
sun_diffuse[3] = 1.0; // paler
|
sun_diffuse[3] = 1.0;
|
||||||
sun_specular[0] = r;
|
sun_specular[0] = r;
|
||||||
sun_specular[1] = g;
|
sun_specular[1] = g;
|
||||||
sun_specular[2] = b;
|
sun_specular[2] = b;
|
||||||
@ -196,14 +197,13 @@ void setUpSinTable()
|
|||||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, sun_diffuse);
|
glLightfv(GL_LIGHT1, GL_DIFFUSE, sun_diffuse);
|
||||||
glLightfv(GL_LIGHT1, GL_SPECULAR, sun_specular);
|
glLightfv(GL_LIGHT1, GL_SPECULAR, sun_specular);
|
||||||
|
|
||||||
//
|
|
||||||
// main disc less saturation more brightness
|
// main disc less saturation more brightness
|
||||||
color = [OOColor colorWithCalibratedHue: hue saturation: sat * 0.333 brightness: 1.0 alpha: alf];
|
color = [OOColor colorWithCalibratedHue: hue saturation: sat * 0.333 brightness: 1.0 alpha: alf];
|
||||||
amb_land[0] = [color redComponent];
|
amb_land[0] = [color redComponent];
|
||||||
amb_land[1] = [color greenComponent];
|
amb_land[1] = [color greenComponent];
|
||||||
amb_land[2] = [color blueComponent];
|
amb_land[2] = [color blueComponent];
|
||||||
amb_land[3] = 1.0;
|
amb_land[3] = 1.0;
|
||||||
//
|
|
||||||
// nearest corona much more saturation
|
// nearest corona much more saturation
|
||||||
hue += hue_drift;
|
hue += hue_drift;
|
||||||
if (hue < 0.0) hue += 1.0;
|
if (hue < 0.0) hue += 1.0;
|
||||||
@ -213,7 +213,7 @@ void setUpSinTable()
|
|||||||
amb_polar_land[1] = [color greenComponent];
|
amb_polar_land[1] = [color greenComponent];
|
||||||
amb_polar_land[2] = [color blueComponent];
|
amb_polar_land[2] = [color blueComponent];
|
||||||
amb_polar_land[3] = 1.0;
|
amb_polar_land[3] = 1.0;
|
||||||
//
|
|
||||||
// next corona slightly more saturation
|
// next corona slightly more saturation
|
||||||
hue += hue_drift;
|
hue += hue_drift;
|
||||||
if (hue < 0.0) hue += 1.0;
|
if (hue < 0.0) hue += 1.0;
|
||||||
@ -363,45 +363,6 @@ void setUpSinTable()
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initAsCoronaForPlanet:(PlanetEntity *) planet
|
|
||||||
{
|
|
||||||
self = [super init];
|
|
||||||
//
|
|
||||||
isTextured = NO;
|
|
||||||
isShadered = NO;
|
|
||||||
//
|
|
||||||
if (!planet)
|
|
||||||
{
|
|
||||||
NSLog(@"ERROR Planetentity initAsCoronaForPlanet:NULL");
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
position = planet->position;
|
|
||||||
collision_radius = planet->collision_radius + ATMOSPHERE_DEPTH * 2; // atmosphere is 5000m deep only
|
|
||||||
//
|
|
||||||
shuttles_on_ground = 0;
|
|
||||||
last_launch_time = 0.0;
|
|
||||||
shuttle_launch_interval = 60 * 60;
|
|
||||||
//
|
|
||||||
scanClass = CLASS_NO_DRAW;
|
|
||||||
//
|
|
||||||
planet_type = PLANET_TYPE_CORONA;
|
|
||||||
//
|
|
||||||
amb_land[0] = 0.85;
|
|
||||||
amb_land[1] = 0.85;
|
|
||||||
amb_land[2] = 1.0;
|
|
||||||
amb_land[3] = 1.0; // blue color
|
|
||||||
|
|
||||||
atmosphere = nil;
|
|
||||||
|
|
||||||
[self setOwner:planet];
|
|
||||||
//
|
|
||||||
isPlanet = YES;
|
|
||||||
//
|
|
||||||
root_planet = planet;
|
|
||||||
//
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) initWithSeed:(Random_Seed) p_seed
|
- (id) initWithSeed:(Random_Seed) p_seed
|
||||||
{
|
{
|
||||||
@ -696,29 +657,25 @@ void setUpSinTable()
|
|||||||
isTextured = NO;
|
isTextured = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
|
||||||
if ([dict objectForKey:@"seed"])
|
NSString *seedStr = [dict stringForKey:@"seed"];
|
||||||
|
if (seedStr != nil)
|
||||||
{
|
{
|
||||||
NSArray* tokens = ScanTokensFromString([dict objectForKey:@"seed"]);
|
Random_Seed seed = RandomSeedFromString(seedStr);
|
||||||
if ([tokens count] != 6)
|
if (!is_nil_seed(seed))
|
||||||
NSLog(@"ERROR planet seed '%@' requires 6 values", [dict objectForKey:@"seed"]);
|
{
|
||||||
|
p_seed = seed;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p_seed.a = [[tokens objectAtIndex:0] intValue];
|
OOLog(@"planet.fromDict", @"ERROR: could not interpret \"%@\" as planet seed, using default.", seedStr);
|
||||||
p_seed.b = [[tokens objectAtIndex:1] intValue];
|
|
||||||
p_seed.c = [[tokens objectAtIndex:2] intValue];
|
|
||||||
p_seed.d = [[tokens objectAtIndex:3] intValue];
|
|
||||||
p_seed.e = [[tokens objectAtIndex:4] intValue];
|
|
||||||
p_seed.f = [[tokens objectAtIndex:5] intValue];
|
|
||||||
}
|
}
|
||||||
planet_seed = p_seed.a * 13 + p_seed.c * 11 + p_seed.e * 7; // pseudo-random set-up for vertex colours
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
//
|
|
||||||
seed_for_planet_description(p_seed);
|
seed_for_planet_description(p_seed);
|
||||||
//
|
//
|
||||||
NSDictionary* planetinfo = [UNIVERSE generateSystemData:p_seed];
|
NSDictionary* planetinfo = [UNIVERSE generateSystemData:p_seed];
|
||||||
int radius_km = [(NSNumber *)[planetinfo objectForKey:KEY_RADIUS] intValue];
|
int radius_km = [[planetinfo objectForKey:KEY_RADIUS] intValue];
|
||||||
if ([dict objectForKey:@"radius"])
|
if ([dict objectForKey:@"radius"])
|
||||||
{
|
{
|
||||||
radius_km = [[dict objectForKey:@"radius"] intValue];
|
radius_km = [[dict objectForKey:@"radius"] intValue];
|
||||||
|
@ -27,19 +27,13 @@ MA 02110-1301, USA.
|
|||||||
#import "OOSelfDrawingEntity.h"
|
#import "OOSelfDrawingEntity.h"
|
||||||
|
|
||||||
|
|
||||||
#define SKY_BILLBOARDS 3
|
#define BILLBOARD_DEPTH 50000.0
|
||||||
|
|
||||||
#define BILLBOARD_DEPTH 50000.0
|
|
||||||
// 50 km away!
|
|
||||||
|
|
||||||
#define SKY_N_STARS 480
|
|
||||||
#define SKY_N_BLOBS 128
|
|
||||||
#define SKY_MAX_STARS 4800
|
#define SKY_MAX_STARS 4800
|
||||||
#define SKY_MAX_BLOBS 1280
|
#define SKY_MAX_BLOBS 1280
|
||||||
#define SKY_BLOB_CLUSTER_CHANCE 0.80
|
#define SKY_BLOB_CLUSTER_CHANCE 0.80
|
||||||
#define SKY_BLOB_ALPHA 0.10
|
#define SKY_BLOB_ALPHA 0.10
|
||||||
#define SKY_BLOB_SCALE 10.0
|
#define SKY_BLOB_SCALE 10.0
|
||||||
#define SKY_BLOB_SCALE_PRIME 0.0005
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -60,28 +54,20 @@ typedef struct
|
|||||||
|
|
||||||
@interface SkyEntity: OOSelfDrawingEntity
|
@interface SkyEntity: OOSelfDrawingEntity
|
||||||
{
|
{
|
||||||
int sky_type;
|
OOColor *sky_color;
|
||||||
|
|
||||||
OOColor *sky_color;
|
|
||||||
|
|
||||||
GLuint star_textureName;
|
SkyStarsData starsData;
|
||||||
GLuint blob_textureName;
|
SkyBlobsData blobsData;
|
||||||
|
|
||||||
SkyStarsData starsData;
|
|
||||||
SkyBlobsData blobsData;
|
|
||||||
|
|
||||||
double blob_cluster_chance;
|
double blob_cluster_chance;
|
||||||
double blob_alpha;
|
double blob_alpha;
|
||||||
double blob_scale;
|
double blob_scale;
|
||||||
double blob_scale_prime;
|
double blob_scale_prime;
|
||||||
|
|
||||||
double delta;
|
int n_stars, n_blobs;
|
||||||
|
|
||||||
int n_stars, n_blobs;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithColors:(OOColor *) col1:(OOColor *) col2;
|
|
||||||
- (id) initWithColors:(OOColor *) col1:(OOColor *) col2 andSystemInfo:(NSDictionary *) systeminfo;
|
- (id) initWithColors:(OOColor *) col1:(OOColor *) col2 andSystemInfo:(NSDictionary *) systeminfo;
|
||||||
- (id) initAsWitchspace;
|
- (id) initAsWitchspace;
|
||||||
- (void) set_up_billboards:(OOColor *) col1:(OOColor *) col2;
|
- (void) set_up_billboards:(OOColor *) col1:(OOColor *) col2;
|
||||||
|
@ -22,240 +22,114 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SKY_SCALE 2000.0
|
|
||||||
|
|
||||||
#import "Entity.h"
|
|
||||||
#import "SkyEntity.h"
|
#import "SkyEntity.h"
|
||||||
#import "PlayerEntity.h"
|
#import "PlayerEntity.h"
|
||||||
|
|
||||||
#import "OOMaths.h"
|
#import "OOMaths.h"
|
||||||
#import "Universe.h"
|
#import "Universe.h"
|
||||||
#import "TextureStore.h"
|
|
||||||
#import "MyOpenGLView.h"
|
#import "MyOpenGLView.h"
|
||||||
#import "OOColor.h"
|
#import "OOColor.h"
|
||||||
#import "OOStringParsing.h"
|
#import "OOStringParsing.h"
|
||||||
|
#import "OOTexture.h"
|
||||||
|
#import "OOCollectionExtractors.h"
|
||||||
|
|
||||||
|
|
||||||
|
OOTexture *sStarTexture = nil, *sBlobTexture = nil;
|
||||||
|
|
||||||
|
|
||||||
|
@interface SkyEntity (OOPrivate)
|
||||||
|
|
||||||
|
- (void)readColor1:(OOColor **)ioColor1 andColor2:(OOColor **)ioColor2 fromDictionary:(NSDictionary *)dictionary;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
@implementation SkyEntity
|
@implementation SkyEntity
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
self = [super init];
|
|
||||||
//
|
|
||||||
delta = 0.0;
|
|
||||||
//
|
|
||||||
status = STATUS_EFFECT;
|
|
||||||
sky_type = SKY_BILLBOARDS;
|
|
||||||
//
|
|
||||||
float h1 = (ranrot_rand() % 1024)/1024.0;
|
float h1 = (ranrot_rand() % 1024)/1024.0;
|
||||||
float h2 = h1 + 1.0 / (1.0 + (ranrot_rand() % 5));
|
float h2 = h1 + 1.0 / (1.0 + (ranrot_rand() % 5));
|
||||||
while (h2 > 1.0)
|
while (h2 > 1.0) h2 -= 1.0;
|
||||||
h2 -= 1.0;
|
|
||||||
OOColor *col1 = [OOColor colorWithCalibratedHue:h1 saturation:(ranrot_rand() % 1024)/1024.0 brightness:0.5 +(ranrot_rand() % 1024)/2048.0 alpha:1.0];
|
OOColor *col1 = [OOColor colorWithCalibratedHue:h1
|
||||||
OOColor *col2 = [OOColor colorWithCalibratedHue:h2 saturation:0.5 +(ranrot_rand() % 1024)/2048.0 brightness:0.5 +(ranrot_rand() % 1024)/2048.0 alpha:1.0];
|
saturation:(ranrot_rand() % 1024) / 1024.0
|
||||||
//
|
brightness:0.5 + (ranrot_rand() % 1024) / 2048.0
|
||||||
sky_color = [[col2 blendedColorWithFraction:0.5 ofColor:col1] retain];
|
alpha:1.0];
|
||||||
//
|
OOColor *col2 = [OOColor colorWithCalibratedHue:h2
|
||||||
// init stars
|
saturation:0.5 +(ranrot_rand() % 1024) / 2048.0
|
||||||
//
|
brightness:0.5 +(ranrot_rand() % 1024) / 2048.0
|
||||||
[self set_up_billboards:col1 :col2];
|
alpha:1.0];
|
||||||
//
|
|
||||||
|
return [self initWithColors:col1 :col2 andSystemInfo:nil];
|
||||||
//
|
|
||||||
usingVAR = [self OGL_InitVAR];
|
|
||||||
//
|
|
||||||
if (usingVAR)
|
|
||||||
{
|
|
||||||
[self OGL_AssignVARMemory:sizeof(SkyStarsData) :(void *)&starsData :0];
|
|
||||||
[self OGL_AssignVARMemory:sizeof(SkyBlobsData) :(void *)&blobsData :1];
|
|
||||||
}
|
|
||||||
//
|
|
||||||
isSky = YES;
|
|
||||||
//
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithColors:(OOColor *) col1:(OOColor *) col2
|
|
||||||
|
- (id) initWithColors:(OOColor *) col1:(OOColor *) col2 andSystemInfo:(NSDictionary *) systemInfo
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
//
|
if (self == nil) return nil;
|
||||||
n_stars = SKY_N_STARS;
|
|
||||||
n_blobs = SKY_N_BLOBS;
|
|
||||||
|
|
||||||
delta = 0.0;
|
// Load textures
|
||||||
//
|
if (sStarTexture == nil) sStarTexture = [OOTexture textureWithName:@"star64.png" inFolder:@"Textures" options:kOOTextureDefaultOptions anisotropy:0.0f lodBias:-0.6f];
|
||||||
status = STATUS_EFFECT;
|
if (sBlobTexture == nil) sBlobTexture = [OOTexture textureWithName:@"galaxy256.png" inFolder:@"Textures" options:kOOTextureDefaultOptions anisotropy:0.0f lodBias:0.0f];
|
||||||
sky_type = SKY_BILLBOARDS;
|
|
||||||
//
|
// Load colours
|
||||||
|
[self readColor1:&col1 andColor2:&col2 fromDictionary:systemInfo];
|
||||||
sky_color = [[col2 blendedColorWithFraction:0.5 ofColor:col1] retain];
|
sky_color = [[col2 blendedColorWithFraction:0.5 ofColor:col1] retain];
|
||||||
//
|
|
||||||
// init stars
|
|
||||||
//
|
|
||||||
blob_cluster_chance = SKY_BLOB_CLUSTER_CHANCE;
|
|
||||||
blob_alpha = SKY_BLOB_ALPHA;
|
|
||||||
blob_scale = SKY_BLOB_SCALE;
|
|
||||||
blob_scale_prime = 0.005 / blob_scale;
|
|
||||||
//
|
|
||||||
[self set_up_billboards:col1 :col2];
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
usingVAR = [self OGL_InitVAR];
|
|
||||||
//
|
|
||||||
if (usingVAR)
|
|
||||||
{
|
|
||||||
[self OGL_AssignVARMemory:sizeof(SkyStarsData) :(void *)&starsData :0];
|
|
||||||
[self OGL_AssignVARMemory:sizeof(SkyBlobsData) :(void *)&blobsData :1];
|
|
||||||
}
|
|
||||||
//
|
|
||||||
isSky = YES;
|
|
||||||
//
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) initWithColors:(OOColor *) col1:(OOColor *) col2 andSystemInfo:(NSDictionary *) systeminfo
|
|
||||||
{
|
|
||||||
OOColor* color1 = col1;
|
|
||||||
OOColor* color2 = col2;
|
|
||||||
|
|
||||||
self = [super init];
|
|
||||||
//
|
|
||||||
n_stars = SKY_N_STARS;
|
|
||||||
n_blobs = SKY_N_BLOBS;
|
|
||||||
|
|
||||||
delta = 0.0;
|
// Load distribution values
|
||||||
//
|
blob_cluster_chance = [systemInfo floatForKey:@"sky_blur_cluster_chance" defaultValue:SKY_BLOB_CLUSTER_CHANCE];
|
||||||
status = STATUS_EFFECT;
|
blob_alpha = [systemInfo floatForKey:@"sky_blur_alpha" defaultValue:SKY_BLOB_ALPHA];
|
||||||
sky_type = SKY_BILLBOARDS;
|
blob_scale = [systemInfo floatForKey:@"sky_blur_scale" defaultValue:SKY_BLOB_SCALE];
|
||||||
//
|
|
||||||
blob_cluster_chance = SKY_BLOB_CLUSTER_CHANCE;
|
|
||||||
blob_alpha = SKY_BLOB_ALPHA;
|
|
||||||
blob_scale = SKY_BLOB_SCALE;
|
|
||||||
blob_scale_prime = 0.005 / blob_scale;
|
blob_scale_prime = 0.005 / blob_scale;
|
||||||
//
|
|
||||||
|
n_stars = [systemInfo floatForKey:@"sky_n_stars" defaultValue:-1];
|
||||||
//// possible systeminfo overrides
|
if (0 <= n_stars)
|
||||||
//
|
|
||||||
if ([systeminfo objectForKey:@"sky_rgb_colors"])
|
|
||||||
{
|
{
|
||||||
NSString* value = (NSString *)[systeminfo objectForKey:@"sky_rgb_colors"];
|
n_stars = MIN(SKY_MAX_STARS, n_stars);
|
||||||
NSArray* tokens = ScanTokensFromString(value);
|
|
||||||
if ([tokens count] == 6)
|
|
||||||
{
|
|
||||||
float r1 = [(NSString *)[tokens objectAtIndex:0] floatValue];
|
|
||||||
float g1 = [(NSString *)[tokens objectAtIndex:1] floatValue];
|
|
||||||
float b1 = [(NSString *)[tokens objectAtIndex:2] floatValue];
|
|
||||||
float r2 = [(NSString *)[tokens objectAtIndex:3] floatValue];
|
|
||||||
float g2 = [(NSString *)[tokens objectAtIndex:4] floatValue];
|
|
||||||
float b2 = [(NSString *)[tokens objectAtIndex:5] floatValue];
|
|
||||||
color1 = [OOColor colorWithCalibratedRed:r1 green:g1 blue:b1 alpha:1.0];
|
|
||||||
color2 = [OOColor colorWithCalibratedRed:r2 green:g2 blue:b2 alpha:1.0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ([systeminfo objectForKey:@"sky_blur_cluster_chance"])
|
|
||||||
{
|
|
||||||
NSNumber* value = (NSNumber *)[systeminfo objectForKey:@"sky_blur_cluster_chance"];
|
|
||||||
blob_cluster_chance = [value doubleValue];
|
|
||||||
}
|
|
||||||
if ([systeminfo objectForKey:@"sky_blur_alpha"])
|
|
||||||
{
|
|
||||||
NSNumber* value = (NSNumber *)[systeminfo objectForKey:@"sky_blur_alpha"];
|
|
||||||
blob_alpha = [value doubleValue];
|
|
||||||
}
|
|
||||||
if ([systeminfo objectForKey:@"sky_blur_scale"])
|
|
||||||
{
|
|
||||||
NSNumber* value = (NSNumber *)[systeminfo objectForKey:@"sky_blur_scale"];
|
|
||||||
blob_scale = [value doubleValue];
|
|
||||||
}
|
|
||||||
//
|
|
||||||
if ([systeminfo objectForKey:@"sky_n_stars"])
|
|
||||||
{
|
|
||||||
NSNumber* value = (NSNumber *)[systeminfo objectForKey:@"sky_n_stars"];
|
|
||||||
n_stars = [value doubleValue];
|
|
||||||
if (n_stars < 0)
|
|
||||||
n_stars = 0;
|
|
||||||
if (n_stars > SKY_MAX_STARS)
|
|
||||||
n_stars = SKY_MAX_STARS;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
n_stars = SKY_MAX_STARS * 0.5 * randf() * randf(); // around 0.125
|
n_stars = SKY_MAX_STARS * 0.5 * randf() * randf();
|
||||||
}
|
}
|
||||||
//
|
|
||||||
if ([systeminfo objectForKey:@"sky_n_blurs"])
|
n_blobs = [systemInfo floatForKey:@"sky_n_blurs" defaultValue:-1];
|
||||||
|
if (0 <= n_blobs)
|
||||||
{
|
{
|
||||||
NSNumber* value = (NSNumber *)[systeminfo objectForKey:@"sky_n_blurs"];
|
n_blobs = MIN(SKY_MAX_BLOBS, n_stars);
|
||||||
n_blobs = [value doubleValue];
|
|
||||||
if (n_blobs < 0)
|
|
||||||
n_blobs = 0;
|
|
||||||
if (n_blobs > SKY_MAX_BLOBS)
|
|
||||||
n_blobs = SKY_MAX_BLOBS;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
n_blobs = SKY_MAX_BLOBS * 0.4 * randf() * randf(); // around 0.10
|
n_blobs = SKY_MAX_BLOBS * 0.5 * randf() * randf();
|
||||||
}
|
}
|
||||||
//
|
|
||||||
////
|
// init stars and blobs
|
||||||
|
[self set_up_billboards:col1 :col2];
|
||||||
sky_color = [[color2 blendedColorWithFraction:0.5 ofColor:color1] retain];
|
|
||||||
//
|
#if GL_APPLE_vertex_array_object
|
||||||
// init stars
|
|
||||||
//
|
|
||||||
[self set_up_billboards:color1 :color2];
|
|
||||||
|
|
||||||
//
|
|
||||||
usingVAR = [self OGL_InitVAR];
|
usingVAR = [self OGL_InitVAR];
|
||||||
//
|
|
||||||
if (usingVAR)
|
if (usingVAR)
|
||||||
{
|
{
|
||||||
[self OGL_AssignVARMemory:sizeof(SkyStarsData) :(void *)&starsData :0];
|
[self OGL_AssignVARMemory:sizeof(SkyStarsData) :(void *)&starsData :0];
|
||||||
[self OGL_AssignVARMemory:sizeof(SkyBlobsData) :(void *)&blobsData :1];
|
[self OGL_AssignVARMemory:sizeof(SkyBlobsData) :(void *)&blobsData :1];
|
||||||
}
|
}
|
||||||
//
|
#endif
|
||||||
|
|
||||||
|
status = STATUS_EFFECT;
|
||||||
isSky = YES;
|
isSky = YES;
|
||||||
//
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (id) initAsWitchspace
|
- (id) initAsWitchspace
|
||||||
{
|
{
|
||||||
self = [super init];
|
NSDictionary *info = [[UNIVERSE planetinfo] objectForKey:@"interstellar space!"];
|
||||||
//
|
|
||||||
n_stars = SKY_N_STARS;
|
|
||||||
n_blobs = SKY_N_BLOBS;
|
|
||||||
|
|
||||||
delta = 0.0;
|
return [self initWithColors:nil :nil andSystemInfo:info];
|
||||||
//
|
|
||||||
status = STATUS_EFFECT;
|
|
||||||
sky_type = SKY_BILLBOARDS;
|
|
||||||
//
|
|
||||||
OOColor *col1 = [OOColor colorWithCalibratedRed:0.0 green:1.0 blue:0.5 alpha:1.0];
|
|
||||||
OOColor *col2 = [OOColor colorWithCalibratedRed:0.0 green:1.0 blue:0.0 alpha:1.0];
|
|
||||||
//
|
|
||||||
sky_color = [[col2 blendedColorWithFraction:0.5 ofColor:col1] retain];
|
|
||||||
//
|
|
||||||
// init stars
|
|
||||||
//
|
|
||||||
blob_cluster_chance = SKY_BLOB_CLUSTER_CHANCE;
|
|
||||||
blob_alpha = SKY_BLOB_ALPHA;
|
|
||||||
blob_scale = SKY_BLOB_SCALE;
|
|
||||||
blob_scale_prime = 0.005 / blob_scale;
|
|
||||||
//
|
|
||||||
[self set_up_billboards:col1 :col2];
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
usingVAR = [self OGL_InitVAR];
|
|
||||||
//
|
|
||||||
if (usingVAR)
|
|
||||||
{
|
|
||||||
[self OGL_AssignVARMemory:sizeof(SkyStarsData) :(void *)&starsData :0];
|
|
||||||
[self OGL_AssignVARMemory:sizeof(SkyBlobsData) :(void *)&blobsData :1];
|
|
||||||
}
|
|
||||||
//
|
|
||||||
isSky = YES;
|
|
||||||
//
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) set_up_billboards:(OOColor *) col1:(OOColor *) col2
|
- (void) set_up_billboards:(OOColor *) col1:(OOColor *) col2
|
||||||
@ -332,7 +206,7 @@ MA 02110-1301, USA.
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
star_textureName = 0;
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// init blobs
|
// init blobs
|
||||||
@ -343,7 +217,7 @@ MA 02110-1301, USA.
|
|||||||
float hu, sa, br, al;
|
float hu, sa, br, al;
|
||||||
[col3 getHue:&hu saturation:&sa brightness:&br alpha:&al];
|
[col3 getHue:&hu saturation:&sa brightness:&br alpha:&al];
|
||||||
sa = 0.5 * sa + 0.5; // move saturation up a notch!
|
sa = 0.5 * sa + 0.5; // move saturation up a notch!
|
||||||
//br = 0.5 * br + 0.5; // move brightness up a notch!
|
br *= blob_alpha; // Premultiply alpha
|
||||||
col3 = [OOColor colorWithCalibratedHue:hu saturation:sa brightness:br alpha:al];
|
col3 = [OOColor colorWithCalibratedHue:hu saturation:sa brightness:br alpha:al];
|
||||||
Quaternion q;
|
Quaternion q;
|
||||||
quaternion_set_random(&q);
|
quaternion_set_random(&q);
|
||||||
@ -355,7 +229,7 @@ MA 02110-1301, USA.
|
|||||||
blob_color[i][0] = [col3 redComponent];
|
blob_color[i][0] = [col3 redComponent];
|
||||||
blob_color[i][1] = [col3 greenComponent];
|
blob_color[i][1] = [col3 greenComponent];
|
||||||
blob_color[i][2] = [col3 blueComponent];
|
blob_color[i][2] = [col3 blueComponent];
|
||||||
blob_color[i][3] = blob_alpha;
|
blob_color[i][3] = 1.0f;
|
||||||
blob_vector[i] = vk;
|
blob_vector[i] = vk;
|
||||||
blob_vector[i].x *= BILLBOARD_DEPTH;
|
blob_vector[i].x *= BILLBOARD_DEPTH;
|
||||||
blob_vector[i].y *= BILLBOARD_DEPTH;
|
blob_vector[i].y *= BILLBOARD_DEPTH;
|
||||||
@ -424,8 +298,6 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blob_textureName = 0;
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
@ -469,91 +341,83 @@ MA 02110-1301, USA.
|
|||||||
// glShadeModel(GL_SMOOTH); // smoothing for color values...
|
// glShadeModel(GL_SMOOTH); // smoothing for color values...
|
||||||
|
|
||||||
if (immediate)
|
if (immediate)
|
||||||
{
|
{
|
||||||
switch (sky_type)
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
glBlendFunc(GL_ONE, GL_ONE); // Pure additive blending, ignoring alpha
|
||||||
|
|
||||||
|
#if GL_APPLE_vertex_array_object
|
||||||
|
if (usingVAR) glBindVertexArrayAPPLE(gVertexArrayRangeObjects[0]);
|
||||||
|
#endif
|
||||||
|
[sStarTexture apply];
|
||||||
|
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer( 3, GL_FLOAT, 0, starsData.vertex_array);
|
||||||
|
// 3 coords per vertex
|
||||||
|
// of type GL_FLOAT
|
||||||
|
// 0 stride (tightly packed)
|
||||||
|
// pointer to first vertex
|
||||||
|
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glTexCoordPointer( 2, GL_INT, 0, starsData.texture_uv_array);
|
||||||
|
// 2 coords per vertex
|
||||||
|
// of type GL_INT
|
||||||
|
// 0 stride (tightly packed)
|
||||||
|
// pointer to first coordinate pair
|
||||||
|
|
||||||
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
glColorPointer( 4, GL_FLOAT, 0, starsData.color_array);
|
||||||
|
// 4 values per vertex color
|
||||||
|
// of type GL_FLOAT
|
||||||
|
// 0 stride (tightly packed)
|
||||||
|
// pointer to quadruplet
|
||||||
|
|
||||||
|
glDisableClientState(GL_INDEX_ARRAY);
|
||||||
|
glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
|
glDisableClientState(GL_EDGE_FLAG_ARRAY);
|
||||||
|
|
||||||
|
glDrawArrays( GL_QUADS, 0, 4 * n_stars);
|
||||||
|
|
||||||
|
//
|
||||||
|
// blobs
|
||||||
|
if (![UNIVERSE reducedDetail])
|
||||||
{
|
{
|
||||||
case SKY_BILLBOARDS :
|
[sBlobTexture apply];
|
||||||
if (star_textureName == 0) star_textureName = [TextureStore getTextureNameFor:@"star64.png"];
|
|
||||||
if (blob_textureName == 0) blob_textureName = [TextureStore getTextureNameFor:@"galaxy256.png"];
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
||||||
glBlendFunc(GL_ONE, GL_ONE); // Pure additive blending, ignoring alpha
|
|
||||||
|
|
||||||
#if GL_APPLE_vertex_array_object
|
#if GL_APPLE_vertex_array_object
|
||||||
if (usingVAR) glBindVertexArrayAPPLE(gVertexArrayRangeObjects[0]);
|
if (usingVAR) glBindVertexArrayAPPLE(gVertexArrayRangeObjects[1]);
|
||||||
#endif
|
|
||||||
glBindTexture(GL_TEXTURE_2D, star_textureName);
|
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
glVertexPointer( 3, GL_FLOAT, 0, starsData.vertex_array);
|
|
||||||
// 3 coords per vertex
|
|
||||||
// of type GL_FLOAT
|
|
||||||
// 0 stride (tightly packed)
|
|
||||||
// pointer to first vertex
|
|
||||||
|
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
glTexCoordPointer( 2, GL_INT, 0, starsData.texture_uv_array);
|
|
||||||
// 2 coords per vertex
|
|
||||||
// of type GL_INT
|
|
||||||
// 0 stride (tightly packed)
|
|
||||||
// pointer to first coordinate pair
|
|
||||||
|
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
|
||||||
glColorPointer( 4, GL_FLOAT, 0, starsData.color_array);
|
|
||||||
// 4 values per vertex color
|
|
||||||
// of type GL_FLOAT
|
|
||||||
// 0 stride (tightly packed)
|
|
||||||
// pointer to quadruplet
|
|
||||||
|
|
||||||
glDisableClientState(GL_INDEX_ARRAY);
|
|
||||||
glDisableClientState(GL_NORMAL_ARRAY);
|
|
||||||
glDisableClientState(GL_EDGE_FLAG_ARRAY);
|
|
||||||
|
|
||||||
glDrawArrays( GL_QUADS, 0, 4 * n_stars);
|
|
||||||
|
|
||||||
//
|
|
||||||
// blobs
|
|
||||||
if (![UNIVERSE reducedDetail])
|
|
||||||
{
|
|
||||||
glBindTexture(GL_TEXTURE_2D, blob_textureName);
|
|
||||||
|
|
||||||
#if GL_APPLE_vertex_array_object
|
|
||||||
if (usingVAR) glBindVertexArrayAPPLE(gVertexArrayRangeObjects[1]);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glVertexPointer( 3, GL_FLOAT, 0, blobsData.vertex_array);
|
glVertexPointer( 3, GL_FLOAT, 0, blobsData.vertex_array);
|
||||||
// 3 coords per vertex
|
// 3 coords per vertex
|
||||||
// of type GL_FLOAT
|
// of type GL_FLOAT
|
||||||
// 0 stride (tightly packed)
|
// 0 stride (tightly packed)
|
||||||
// pointer to first vertex
|
// pointer to first vertex
|
||||||
|
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glTexCoordPointer( 2, GL_INT, 0, blobsData.texture_uv_array);
|
glTexCoordPointer( 2, GL_INT, 0, blobsData.texture_uv_array);
|
||||||
// 2 coords per vertex
|
// 2 coords per vertex
|
||||||
// of type GL_INT
|
// of type GL_INT
|
||||||
// 0 stride (tightly packed)
|
// 0 stride (tightly packed)
|
||||||
// pointer to first coordinate pair
|
// pointer to first coordinate pair
|
||||||
|
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
glColorPointer( 4, GL_FLOAT, 0, blobsData.color_array);
|
glColorPointer( 4, GL_FLOAT, 0, blobsData.color_array);
|
||||||
// 4 values per vertex color
|
// 4 values per vertex color
|
||||||
// of type GL_FLOAT
|
// of type GL_FLOAT
|
||||||
// 0 stride (tightly packed)
|
// 0 stride (tightly packed)
|
||||||
// pointer to quadruplet
|
// pointer to quadruplet
|
||||||
|
|
||||||
glDisableClientState(GL_INDEX_ARRAY);
|
glDisableClientState(GL_INDEX_ARRAY);
|
||||||
glDisableClientState(GL_NORMAL_ARRAY);
|
glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
glDisableClientState(GL_EDGE_FLAG_ARRAY);
|
glDisableClientState(GL_EDGE_FLAG_ARRAY);
|
||||||
|
|
||||||
glDrawArrays( GL_QUADS, 0, 4 * n_blobs);
|
glDrawArrays( GL_QUADS, 0, 4 * n_blobs);
|
||||||
|
|
||||||
}
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Basic alpha blending
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Basic alpha blending
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -574,18 +438,55 @@ MA 02110-1301, USA.
|
|||||||
CheckOpenGLErrors([NSString stringWithFormat:@"SkyEntity after drawing %@", self]);
|
CheckOpenGLErrors([NSString stringWithFormat:@"SkyEntity after drawing %@", self]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
@end
|
||||||
// No over-ride of Entity's version of the method is required for non-Win32 platforms.
|
|
||||||
- (void) reloadTextures
|
|
||||||
{
|
|
||||||
// Force the sky textures to be reloaded next time a frame is drawn.
|
|
||||||
star_textureName = 0;
|
|
||||||
blob_textureName = 0;
|
|
||||||
|
|
||||||
// Reset the entity display list.
|
|
||||||
[super reloadTextures];
|
@implementation SkyEntity (OOPrivate)
|
||||||
|
|
||||||
|
- (void)readColor1:(OOColor **)ioColor1 andColor2:(OOColor **)ioColor2 fromDictionary:(NSDictionary *)dictionary
|
||||||
|
{
|
||||||
|
NSString *string = nil;
|
||||||
|
NSArray *tokens = nil;
|
||||||
|
id colorDesc = nil;
|
||||||
|
OOColor *color = nil;
|
||||||
|
|
||||||
|
assert(ioColor1 != NULL && ioColor2 != NULL);
|
||||||
|
|
||||||
|
string = [dictionary stringForKey:@"sky_rgb_colors"];
|
||||||
|
if (string != nil)
|
||||||
|
{
|
||||||
|
tokens = ScanTokensFromString(string);
|
||||||
|
|
||||||
|
if ([tokens count] == 6)
|
||||||
|
{
|
||||||
|
float r1 = [tokens floatAtIndex:0];
|
||||||
|
float g1 = [tokens floatAtIndex:1];
|
||||||
|
float b1 = [tokens floatAtIndex:2];
|
||||||
|
float r2 = [tokens floatAtIndex:3];
|
||||||
|
float g2 = [tokens floatAtIndex:4];
|
||||||
|
float b2 = [tokens floatAtIndex:5];
|
||||||
|
*ioColor1 = [OOColor colorWithCalibratedRed:r1 green:g1 blue:b1 alpha:1.0];
|
||||||
|
*ioColor2 = [OOColor colorWithCalibratedRed:r2 green:g2 blue:b2 alpha:1.0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OOLog(@"sky.fromDict", @"ERROR: could not interpret \"%@\" as two RGB colours (must be six numbers).", string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
colorDesc = [dictionary objectForKey:@"sky_color_1"];
|
||||||
|
if (colorDesc != nil)
|
||||||
|
{
|
||||||
|
color = [[OOColor colorWithDescription:colorDesc] premultipliedColor];
|
||||||
|
if (color != nil) *ioColor1 = color;
|
||||||
|
else OOLog(@"sky.fromDict", @"ERROR: could not interpret \"%@\" as a colour.", colorDesc);
|
||||||
|
}
|
||||||
|
colorDesc = [dictionary objectForKey:@"sky_color_2"];
|
||||||
|
if (colorDesc != nil)
|
||||||
|
{
|
||||||
|
color = [[OOColor colorWithDescription:colorDesc] premultipliedColor];
|
||||||
|
if (color != nil) *ioColor2 = color;
|
||||||
|
else OOLog(@"sky.fromDict", @"ERROR: could not interpret \"%@\" as a colour.", colorDesc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -69,6 +69,7 @@ enum
|
|||||||
kOOTextureRepeatT = 0x0040UL,
|
kOOTextureRepeatT = 0x0040UL,
|
||||||
kOOTextureAllowRectTexture = 0x0080UL, // Indicates that GL_TEXTURE_RECTANGLE_EXT may be used instead of GL_TEXTURE_2D. See -texCoordsScale for a discussion of rectangle textures.
|
kOOTextureAllowRectTexture = 0x0080UL, // Indicates that GL_TEXTURE_RECTANGLE_EXT may be used instead of GL_TEXTURE_2D. See -texCoordsScale for a discussion of rectangle textures.
|
||||||
kOOTextureSearchInImages = 0x0100UL, // Search in Images directories rather than Textures directories.
|
kOOTextureSearchInImages = 0x0100UL, // Search in Images directories rather than Textures directories.
|
||||||
|
kOOTextureNoFNFMessage = 0x0200UL, // Don't log file not found error
|
||||||
|
|
||||||
kOOTextureMinFilterMask = 0x0003UL,
|
kOOTextureMinFilterMask = 0x0003UL,
|
||||||
kOOTextureMagFilterMask = 0x0004UL,
|
kOOTextureMagFilterMask = 0x0004UL,
|
||||||
@ -82,7 +83,9 @@ enum
|
|||||||
| kOOTextureAllowRectTexture
|
| kOOTextureAllowRectTexture
|
||||||
#endif
|
#endif
|
||||||
| kOOTextureRepeatS
|
| kOOTextureRepeatS
|
||||||
| kOOTextureRepeatT,
|
| kOOTextureRepeatT
|
||||||
|
| kOOTextureSearchInImages
|
||||||
|
| kOOTextureNoFNFMessage,
|
||||||
|
|
||||||
kOOTextureFlagsAllowedForRectangleTexture =
|
kOOTextureFlagsAllowedForRectangleTexture =
|
||||||
kOOTextureDefinedFlags & ~(kOOTextureRepeatS | kOOTextureRepeatT)
|
kOOTextureDefinedFlags & ~(kOOTextureRepeatS | kOOTextureRepeatT)
|
||||||
|
@ -176,6 +176,7 @@ static BOOL sRectangleTextureAvailable;
|
|||||||
NSString *key = nil;
|
NSString *key = nil;
|
||||||
OOTexture *result = nil;
|
OOTexture *result = nil;
|
||||||
NSString *path = nil;
|
NSString *path = nil;
|
||||||
|
BOOL noFNF;
|
||||||
|
|
||||||
if (EXPECT_NOT(name == nil)) return nil;
|
if (EXPECT_NOT(name == nil)) return nil;
|
||||||
if (EXPECT_NOT(!sCheckedExtensions)) [self checkExtensions];
|
if (EXPECT_NOT(!sCheckedExtensions)) [self checkExtensions];
|
||||||
@ -221,6 +222,9 @@ static BOOL sRectangleTextureAvailable;
|
|||||||
lodBias = 0.0f;
|
lodBias = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
noFNF = options & kOOTextureNoFNFMessage;
|
||||||
|
options &= ~kOOTextureNoFNFMessage;
|
||||||
|
|
||||||
// Look for existing texture
|
// Look for existing texture
|
||||||
key = [NSString stringWithFormat:@"%@%@%@:0x%.4X/%g/%g", directory ? directory : @"", directory ? @"/" : @"", name, options, anisotropy, lodBias];
|
key = [NSString stringWithFormat:@"%@%@%@:0x%.4X/%g/%g", directory ? directory : @"", directory ? @"/" : @"", name, options, anisotropy, lodBias];
|
||||||
result = [[sInUseTextures objectForKey:key] pointerValue];
|
result = [[sInUseTextures objectForKey:key] pointerValue];
|
||||||
@ -229,7 +233,7 @@ static BOOL sRectangleTextureAvailable;
|
|||||||
path = [ResourceManager pathForFileNamed:name inFolder:directory];
|
path = [ResourceManager pathForFileNamed:name inFolder:directory];
|
||||||
if (path == nil)
|
if (path == nil)
|
||||||
{
|
{
|
||||||
OOLog(kOOLogFileNotFound, @"Could not find texture file \"%@\".", name);
|
if (!noFNF) OOLog(kOOLogFileNotFound, @"***** ERROR: Could not find texture file \"%@\".", name);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,10 +85,12 @@ MA 02110-1301, USA.
|
|||||||
- (void)getHue:(float *)hue saturation:(float *)saturation brightness:(float *)brightness alpha:(float *)alpha;
|
- (void)getHue:(float *)hue saturation:(float *)saturation brightness:(float *)brightness alpha:(float *)alpha;
|
||||||
|
|
||||||
|
|
||||||
/* Get the alpha component. For colors which do not have alpha components, this will return 1.0 (opaque).
|
// Get the alpha component.
|
||||||
*/
|
|
||||||
- (float)alphaComponent;
|
- (float)alphaComponent;
|
||||||
|
|
||||||
|
// Returns the colour, premultiplied by its alpha channel, and with an alpha of 1.0. If the reciever's alpha is 1.0, it will return itself.
|
||||||
|
- (OOColor *)premultipliedColor;
|
||||||
|
|
||||||
- (GLfloat *) RGBA;
|
- (GLfloat *) RGBA;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -422,6 +422,17 @@ MA 02110-1301, USA.
|
|||||||
return rgba[3];
|
return rgba[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (OOColor *)premultipliedColor
|
||||||
|
{
|
||||||
|
if (rgba[3] == 1.0f) return [[self retain] autorelease];
|
||||||
|
return [OOColor colorWithCalibratedRed:rgba[0] * rgba[3]
|
||||||
|
green:rgba[1] * rgba[3]
|
||||||
|
blue:rgba[2] * rgba[3]
|
||||||
|
alpha:1.0f];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (GLfloat *) RGBA;
|
- (GLfloat *) RGBA;
|
||||||
{
|
{
|
||||||
return rgba;
|
return rgba;
|
||||||
|
@ -67,7 +67,6 @@ SOFTWARE.
|
|||||||
- (GLfloat)collisionRadius;
|
- (GLfloat)collisionRadius;
|
||||||
- (GLfloat)maxDrawDistance;
|
- (GLfloat)maxDrawDistance;
|
||||||
- (Geometry *)geometry;
|
- (Geometry *)geometry;
|
||||||
- (GLfloat)volume;
|
|
||||||
|
|
||||||
- (BoundingBox)boundingBox;
|
- (BoundingBox)boundingBox;
|
||||||
// This needs a better name.
|
// This needs a better name.
|
||||||
|
@ -97,12 +97,6 @@ SOFTWARE.
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (GLfloat)volume
|
|
||||||
{
|
|
||||||
return 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
- (BoundingBox)boundingBox
|
- (BoundingBox)boundingBox
|
||||||
{
|
{
|
||||||
return kZeroBoundingBox;
|
return kZeroBoundingBox;
|
||||||
|
@ -123,7 +123,6 @@ typedef uint8_t OOMeshMaterialCount;
|
|||||||
GLfloat collisionRadius;
|
GLfloat collisionRadius;
|
||||||
GLfloat maxDrawDistance;
|
GLfloat maxDrawDistance;
|
||||||
BoundingBox boundingBox;
|
BoundingBox boundingBox;
|
||||||
GLfloat volume;
|
|
||||||
|
|
||||||
Octree *octree;
|
Octree *octree;
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ shaderBindingTarget:(id<OOWeakReferenceSupport>)object
|
|||||||
|
|
||||||
- (NSString *)description
|
- (NSString *)description
|
||||||
{
|
{
|
||||||
return [NSString stringWithFormat:@"<%@ %p>{\"%@\", %u vertices, %u faces, radius: %g m volume:%g m^3 smooth: %s}", [self class], self, [self modelName], [self vertexCount], [self faceCount], [self collisionRadius], [self volume], isSmoothShaded ? "YES" : "NO"];
|
return [NSString stringWithFormat:@"<%@ %p>{\"%@\", %u vertices, %u faces, radius: %g m volume:%g m^3 smooth: %s}", [self class], self, [self modelName], [self vertexCount], [self faceCount], [self collisionRadius], isSmoothShaded ? "YES" : "NO"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -350,12 +350,6 @@ shaderBindingTarget:(id<OOWeakReferenceSupport>)object
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (GLfloat)volume
|
|
||||||
{
|
|
||||||
return volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
- (OOMesh *)meshRescaledBy:(GLfloat)scaleFactor
|
- (OOMesh *)meshRescaledBy:(GLfloat)scaleFactor
|
||||||
{
|
{
|
||||||
return [self meshRescaledByX:scaleFactor y:scaleFactor z:scaleFactor];
|
return [self meshRescaledByX:scaleFactor y:scaleFactor z:scaleFactor];
|
||||||
@ -1227,8 +1221,6 @@ shaderBindingTarget:(id<OOWeakReferenceSupport>)target
|
|||||||
|
|
||||||
d_squared = (length_longest_axis + length_shortest_axis) * (length_longest_axis + length_shortest_axis) * 0.25; // square of average length
|
d_squared = (length_longest_axis + length_shortest_axis) * (length_longest_axis + length_shortest_axis) * 0.25; // square of average length
|
||||||
maxDrawDistance = d_squared * NO_DRAW_DISTANCE_FACTOR * NO_DRAW_DISTANCE_FACTOR; // no longer based on the collision radius
|
maxDrawDistance = d_squared * NO_DRAW_DISTANCE_FACTOR * NO_DRAW_DISTANCE_FACTOR; // no longer based on the collision radius
|
||||||
|
|
||||||
volume = (boundingBox.max.x - boundingBox.min.x) * (boundingBox.max.y - boundingBox.min.y) * (boundingBox.max.z - boundingBox.min.z);
|
|
||||||
|
|
||||||
collisionRadius = sqrt(result);
|
collisionRadius = sqrt(result);
|
||||||
}
|
}
|
||||||
|
@ -80,19 +80,6 @@ MA 02110-1301, USA.
|
|||||||
[texture apply];
|
[texture apply];
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
#if OBSOLETE
|
|
||||||
glTexCoord2f(0.0, 1.0-textureCropRect.size.height);
|
|
||||||
glVertex3f(x, y+size.height, z);
|
|
||||||
|
|
||||||
glTexCoord2f(0.0, 1.0);
|
|
||||||
glVertex3f(x, y, z);
|
|
||||||
|
|
||||||
glTexCoord2f(textureCropRect.size.width, 1.0);
|
|
||||||
glVertex3f(x+size.width, y, z);
|
|
||||||
|
|
||||||
glTexCoord2f(textureCropRect.size.width, 1.0-textureCropRect.size.height);
|
|
||||||
glVertex3f(x+size.width, y+size.height, z);
|
|
||||||
#else
|
|
||||||
glTexCoord2f(0.0, 0.0);
|
glTexCoord2f(0.0, 0.0);
|
||||||
glVertex3f(x, y+size.height, z);
|
glVertex3f(x, y+size.height, z);
|
||||||
|
|
||||||
@ -104,7 +91,7 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
glTexCoord2f(1.0, 0.0);
|
glTexCoord2f(1.0, 0.0);
|
||||||
glVertex3f(x+size.width, y+size.height, z);
|
glVertex3f(x+size.width, y+size.height, z);
|
||||||
#endif
|
|
||||||
glEnd();
|
glEnd();
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
@ -829,17 +829,6 @@ static BOOL MaintainLinkedLists(Universe* uni);
|
|||||||
[a_planet setEnergy: 1000000.0];
|
[a_planet setEnergy: 1000000.0];
|
||||||
[self addEntity:a_planet]; // [entities addObject:a_planet];
|
[self addEntity:a_planet]; // [entities addObject:a_planet];
|
||||||
|
|
||||||
#if 0
|
|
||||||
double region_radius = 2.5f * planet_radius;
|
|
||||||
double region_spacing = 2.0 * region_radius;
|
|
||||||
Vector region_pos = a_planet->position;
|
|
||||||
while (region_pos.z > -planet_radius)
|
|
||||||
{
|
|
||||||
[universeRegion addSubregionAtPosition: region_pos withRadius: region_radius]; // collision regions from planet to witchpoint
|
|
||||||
region_pos.z -= region_spacing;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
planet = [a_planet universalID];
|
planet = [a_planet universalID];
|
||||||
/*--*/
|
/*--*/
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user