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:
Jens Ayton 2007-05-19 15:09:05 +00:00
parent 3c4929873f
commit 17e40ba6c7
18 changed files with 252 additions and 417 deletions

View File

@ -268,6 +268,7 @@
1A26D0EB0BCF9D3B0073F257 /* OOTextureLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A26D0E50BCF9D3B0073F257 /* OOTextureLoader.m */; };
1A26D0F50BCF9D8D0073F257 /* 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 */; };
1A29967F0B9F064C002D2149 /* OOCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A29967D0B9F064C002D2149 /* OOCache.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>"; };
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; };
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>"; };
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>"; };
@ -1439,6 +1441,7 @@
1AED74C70BBA3CAA009410CD /* logcontrol.plist.xml */,
1A71E4490BCD5C4200CD5C13 /* material-defaults.plist */,
1A2316E90B9CFAD700EF0852 /* missiontext.plist */,
1A28CAB40BFF404F000EBA08 /* planetinfo.plist */,
1A2316EB0B9CFAD700EF0852 /* shipdata.plist */,
1A2316EC0B9CFAD700EF0852 /* shipyard.plist */,
1A2316ED0B9CFAD700EF0852 /* speech_pronunciation_guide.plist */,
@ -1690,15 +1693,12 @@
children = (
25F3E63A0994F08A002F25FD /* OOOpenGL.h */,
1A2A1DEA0BD2A28E00152975 /* OOMacroOpenGL.h */,
1A2A1B120BD2774300152975 /* OODrawable.h */,
1A2A1B130BD2774300152975 /* OODrawable.m */,
1A2A1CA80BD2914F00152975 /* OOMesh.h */,
1A2A1CA90BD2914F00152975 /* OOMesh.m */,
1A43234A0BCFC9BB00F65914 /* OOOpenGLExtensionManager.h */,
1A43234B0BCFC9BB00F65914 /* OOOpenGLExtensionManager.m */,
25161100099544380037C2E1 /* OpenGLSprite.h */,
251610FF099544380037C2E1 /* OpenGLSprite.m */,
08125F0809F9083F00AB9BF9 /* OOGLDefs.h */,
1ADC3F850BFA1388000E0F89 /* Drawables */,
1A71DDD30BCC0EEF00CD5C13 /* Materials */,
);
name = Graphics;
@ -2087,6 +2087,17 @@
path = Doc;
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 */ = {
isa = PBXGroup;
children = (
@ -2434,6 +2445,7 @@
25F3E8A80994FE65002F25FD /* oolite-expansion-document.icns in Resources */,
25F3E8A90994FE65002F25FD /* oolite-icon.icns in Resources */,
25F3E8B40994FE9B002F25FD /* InfoPlist.strings in Resources */,
1A28CAB50BFF404F000EBA08 /* planetinfo.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -257,7 +257,7 @@ strings.conversion.randomSeed = inherit;
texture.planet.generate = inherit;
$textureDebug = $troubleShootingDump;
$textureDebug = no;
texture.load.noName = $error;
texture.dealloc = $textureDebug;
texture.setUp = $textureDebug;
@ -272,7 +272,7 @@ textureLoader.queueTask.inconsistency = $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;

View File

@ -33,7 +33,7 @@
<key>$soundError</key>
<string>$error</string>
<key>$textureDebug</key>
<string>$troubleShootingDump</string>
<string>no</string>
<key>$troubleShootingDump</key>
<string>yes</string>
<key>_default</key>
@ -425,7 +425,7 @@
<key>unclassified</key>
<string>inherit</string>
<key>universe.populate</key>
<string>$troubleShootingDump</string>
<string>no</string>
<key>universe.populate.witchspace</key>
<string>inherit</string>
</dict>

View File

@ -31,9 +31,9 @@ MA 02110-1301, USA.
static NSString * const kOOLogOpenGLExtensionsVAR = @"rendering.opengl.extensions.var";
static NSString * const kOOLogOpenGLStateDump = @"rendering.opengl.stateDump";
static NSString * const kOOLogEntityDataNotFound = @"entity.loadMesh.error.fileNotFound";
static NSString * const kOOLogEntityTooManyVertices = @"entity.loadMesh.error.tooManyVertices";
static NSString * const kOOLogEntityTooManyFaces = @"entity.loadMesh.error.tooManyFaces";
static NSString * const kOOLogEntityDataNotFound = @"entity.loadMesh.failed.fileNotFound";
static NSString * const kOOLogEntityTooManyVertices = @"entity.loadMesh.failed.tooManyVertices";
static NSString * const kOOLogEntityTooManyFaces = @"entity.loadMesh.failed.tooManyFaces";
#if GL_APPLE_vertex_array_object

View File

@ -124,7 +124,6 @@ void setUpSinTable();
- (id) initAsSunWithColor:(OOColor *) sun_color;
- (id) initAsAtmosphereForPlanet:(PlanetEntity *) planet;
- (id) initAsCoronaForPlanet:(PlanetEntity *) planet;
- (id) initWithSeed:(Random_Seed) p_seed;
- (id) initMiniatureFromPlanet:(PlanetEntity*) planet;

View File

@ -34,6 +34,7 @@ MA 02110-1301, USA.
#import "OOCharacter.h"
#import "OOStringParsing.h"
#import "PlayerEntity.h"
#import "OOCollectionExtractors.h"
#define kOOLogUnconvertedNSLog @"unclassified.PlanetEntity"
@ -186,7 +187,7 @@ void setUpSinTable()
sun_diffuse[0] = 0.5 * (1.0 + r); // paler
sun_diffuse[1] = 0.5 * (1.0 + g); // 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[1] = g;
sun_specular[2] = b;
@ -196,14 +197,13 @@ void setUpSinTable()
glLightfv(GL_LIGHT1, GL_DIFFUSE, sun_diffuse);
glLightfv(GL_LIGHT1, GL_SPECULAR, sun_specular);
//
// main disc less saturation more brightness
color = [OOColor colorWithCalibratedHue: hue saturation: sat * 0.333 brightness: 1.0 alpha: alf];
amb_land[0] = [color redComponent];
amb_land[1] = [color greenComponent];
amb_land[2] = [color blueComponent];
amb_land[3] = 1.0;
//
// nearest corona much more saturation
hue += hue_drift;
if (hue < 0.0) hue += 1.0;
@ -213,7 +213,7 @@ void setUpSinTable()
amb_polar_land[1] = [color greenComponent];
amb_polar_land[2] = [color blueComponent];
amb_polar_land[3] = 1.0;
//
// next corona slightly more saturation
hue += hue_drift;
if (hue < 0.0) hue += 1.0;
@ -363,45 +363,6 @@ void setUpSinTable()
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
{
@ -696,29 +657,25 @@ void setUpSinTable()
isTextured = NO;
}
}
//
if ([dict objectForKey:@"seed"])
NSString *seedStr = [dict stringForKey:@"seed"];
if (seedStr != nil)
{
NSArray* tokens = ScanTokensFromString([dict objectForKey:@"seed"]);
if ([tokens count] != 6)
NSLog(@"ERROR planet seed '%@' requires 6 values", [dict objectForKey:@"seed"]);
Random_Seed seed = RandomSeedFromString(seedStr);
if (!is_nil_seed(seed))
{
p_seed = seed;
}
else
{
p_seed.a = [[tokens objectAtIndex:0] intValue];
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];
OOLog(@"planet.fromDict", @"ERROR: could not interpret \"%@\" as planet seed, using default.", seedStr);
}
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);
//
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"])
{
radius_km = [[dict objectForKey:@"radius"] intValue];

View File

@ -27,19 +27,13 @@ MA 02110-1301, USA.
#import "OOSelfDrawingEntity.h"
#define SKY_BILLBOARDS 3
#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_BLOBS 1280
#define SKY_BLOB_CLUSTER_CHANCE 0.80
#define SKY_BLOB_ALPHA 0.10
#define SKY_BLOB_SCALE 10.0
#define SKY_BLOB_SCALE_PRIME 0.0005
typedef struct
@ -60,13 +54,8 @@ typedef struct
@interface SkyEntity: OOSelfDrawingEntity
{
int sky_type;
OOColor *sky_color;
GLuint star_textureName;
GLuint blob_textureName;
SkyStarsData starsData;
SkyBlobsData blobsData;
@ -75,13 +64,10 @@ typedef struct
double blob_scale;
double blob_scale_prime;
double delta;
int n_stars, n_blobs;
}
- (id) initWithColors:(OOColor *) col1:(OOColor *) col2;
- (id) initWithColors:(OOColor *) col1:(OOColor *) col2 andSystemInfo:(NSDictionary *) systeminfo;
- (id) initAsWitchspace;
- (void) set_up_billboards:(OOColor *) col1:(OOColor *) col2;

View File

@ -22,240 +22,114 @@ MA 02110-1301, USA.
*/
#define SKY_SCALE 2000.0
#import "Entity.h"
#import "SkyEntity.h"
#import "PlayerEntity.h"
#import "OOMaths.h"
#import "Universe.h"
#import "TextureStore.h"
#import "MyOpenGLView.h"
#import "OOColor.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
- (id) init
{
self = [super init];
//
delta = 0.0;
//
status = STATUS_EFFECT;
sky_type = SKY_BILLBOARDS;
//
float h1 = (ranrot_rand() % 1024)/1024.0;
float h2 = h1 + 1.0 / (1.0 + (ranrot_rand() % 5));
while (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 *col2 = [OOColor colorWithCalibratedHue:h2 saturation:0.5 +(ranrot_rand() % 1024)/2048.0 brightness:0.5 +(ranrot_rand() % 1024)/2048.0 alpha:1.0];
//
sky_color = [[col2 blendedColorWithFraction:0.5 ofColor:col1] retain];
//
// init stars
//
[self set_up_billboards:col1 :col2];
//
while (h2 > 1.0) h2 -= 1.0;
//
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;
OOColor *col1 = [OOColor colorWithCalibratedHue:h1
saturation:(ranrot_rand() % 1024) / 1024.0
brightness:0.5 + (ranrot_rand() % 1024) / 2048.0
alpha:1.0];
OOColor *col2 = [OOColor colorWithCalibratedHue:h2
saturation:0.5 +(ranrot_rand() % 1024) / 2048.0
brightness:0.5 +(ranrot_rand() % 1024) / 2048.0
alpha:1.0];
return [self initWithColors:col1 :col2 andSystemInfo:nil];
}
- (id) initWithColors:(OOColor *) col1:(OOColor *) col2
- (id) initWithColors:(OOColor *) col1:(OOColor *) col2 andSystemInfo:(NSDictionary *) systemInfo
{
self = [super init];
//
n_stars = SKY_N_STARS;
n_blobs = SKY_N_BLOBS;
if (self == nil) return nil;
delta = 0.0;
//
status = STATUS_EFFECT;
sky_type = SKY_BILLBOARDS;
//
// Load textures
if (sStarTexture == nil) sStarTexture = [OOTexture textureWithName:@"star64.png" inFolder:@"Textures" options:kOOTextureDefaultOptions anisotropy:0.0f lodBias:-0.6f];
if (sBlobTexture == nil) sBlobTexture = [OOTexture textureWithName:@"galaxy256.png" inFolder:@"Textures" options:kOOTextureDefaultOptions anisotropy:0.0f lodBias:0.0f];
// Load colours
[self readColor1:&col1 andColor2:&col2 fromDictionary:systemInfo];
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;
// Load distribution values
blob_cluster_chance = [systemInfo floatForKey:@"sky_blur_cluster_chance" defaultValue:SKY_BLOB_CLUSTER_CHANCE];
blob_alpha = [systemInfo floatForKey:@"sky_blur_alpha" defaultValue:SKY_BLOB_ALPHA];
blob_scale = [systemInfo floatForKey:@"sky_blur_scale" defaultValue:SKY_BLOB_SCALE];
blob_scale_prime = 0.005 / blob_scale;
//
[self set_up_billboards:col1 :col2];
//
//
usingVAR = [self OGL_InitVAR];
//
if (usingVAR)
n_stars = [systemInfo floatForKey:@"sky_n_stars" defaultValue:-1];
if (0 <= n_stars)
{
[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;
//
status = STATUS_EFFECT;
sky_type = SKY_BILLBOARDS;
//
blob_cluster_chance = SKY_BLOB_CLUSTER_CHANCE;
blob_alpha = SKY_BLOB_ALPHA;
blob_scale = SKY_BLOB_SCALE;
blob_scale_prime = 0.005 / blob_scale;
//
//// possible systeminfo overrides
//
if ([systeminfo objectForKey:@"sky_rgb_colors"])
{
NSString* value = (NSString *)[systeminfo objectForKey:@"sky_rgb_colors"];
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;
n_stars = MIN(SKY_MAX_STARS, n_stars);
}
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 = [value doubleValue];
if (n_blobs < 0)
n_blobs = 0;
if (n_blobs > SKY_MAX_BLOBS)
n_blobs = SKY_MAX_BLOBS;
n_blobs = MIN(SKY_MAX_BLOBS, n_stars);
}
else
{
n_blobs = SKY_MAX_BLOBS * 0.4 * randf() * randf(); // around 0.10
n_blobs = SKY_MAX_BLOBS * 0.5 * randf() * randf();
}
//
////
sky_color = [[color2 blendedColorWithFraction:0.5 ofColor:color1] retain];
//
// init stars
//
[self set_up_billboards:color1 :color2];
// init stars and blobs
[self set_up_billboards:col1 :col2];
//
#if GL_APPLE_vertex_array_object
usingVAR = [self OGL_InitVAR];
//
if (usingVAR)
{
[self OGL_AssignVARMemory:sizeof(SkyStarsData) :(void *)&starsData :0];
[self OGL_AssignVARMemory:sizeof(SkyBlobsData) :(void *)&blobsData :1];
}
//
#endif
status = STATUS_EFFECT;
isSky = YES;
//
return self;
}
- (id) initAsWitchspace
{
self = [super init];
//
n_stars = SKY_N_STARS;
n_blobs = SKY_N_BLOBS;
NSDictionary *info = [[UNIVERSE planetinfo] objectForKey:@"interstellar space!"];
delta = 0.0;
//
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;
return [self initWithColors:nil :nil andSystemInfo:info];
}
- (void) set_up_billboards:(OOColor *) col1:(OOColor *) col2
@ -332,7 +206,7 @@ MA 02110-1301, USA.
}
}
star_textureName = 0;
//
//
// init blobs
@ -343,7 +217,7 @@ MA 02110-1301, USA.
float hu, sa, br, al;
[col3 getHue:&hu saturation:&sa brightness:&br alpha:&al];
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];
Quaternion q;
quaternion_set_random(&q);
@ -355,7 +229,7 @@ MA 02110-1301, USA.
blob_color[i][0] = [col3 redComponent];
blob_color[i][1] = [col3 greenComponent];
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].x *= BILLBOARD_DEPTH;
blob_vector[i].y *= BILLBOARD_DEPTH;
@ -424,8 +298,6 @@ MA 02110-1301, USA.
}
}
blob_textureName = 0;
//
}
- (void) dealloc
@ -469,13 +341,7 @@ MA 02110-1301, USA.
// glShadeModel(GL_SMOOTH); // smoothing for color values...
if (immediate)
{
switch (sky_type)
{
case SKY_BILLBOARDS :
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
@ -483,7 +349,7 @@ MA 02110-1301, USA.
#if GL_APPLE_vertex_array_object
if (usingVAR) glBindVertexArrayAPPLE(gVertexArrayRangeObjects[0]);
#endif
glBindTexture(GL_TEXTURE_2D, star_textureName);
[sStarTexture apply];
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer( 3, GL_FLOAT, 0, starsData.vertex_array);
@ -516,7 +382,7 @@ MA 02110-1301, USA.
// blobs
if (![UNIVERSE reducedDetail])
{
glBindTexture(GL_TEXTURE_2D, blob_textureName);
[sBlobTexture apply];
#if GL_APPLE_vertex_array_object
if (usingVAR) glBindVertexArrayAPPLE(gVertexArrayRangeObjects[1]);
@ -552,8 +418,6 @@ MA 02110-1301, USA.
}
glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Basic alpha blending
break;
}
}
else
{
@ -574,18 +438,55 @@ MA 02110-1301, USA.
CheckOpenGLErrors([NSString stringWithFormat:@"SkyEntity after drawing %@", self]);
}
#ifdef WIN32
// 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;
@end
// 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

View File

@ -69,6 +69,7 @@ enum
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.
kOOTextureSearchInImages = 0x0100UL, // Search in Images directories rather than Textures directories.
kOOTextureNoFNFMessage = 0x0200UL, // Don't log file not found error
kOOTextureMinFilterMask = 0x0003UL,
kOOTextureMagFilterMask = 0x0004UL,
@ -82,7 +83,9 @@ enum
| kOOTextureAllowRectTexture
#endif
| kOOTextureRepeatS
| kOOTextureRepeatT,
| kOOTextureRepeatT
| kOOTextureSearchInImages
| kOOTextureNoFNFMessage,
kOOTextureFlagsAllowedForRectangleTexture =
kOOTextureDefinedFlags & ~(kOOTextureRepeatS | kOOTextureRepeatT)

View File

@ -176,6 +176,7 @@ static BOOL sRectangleTextureAvailable;
NSString *key = nil;
OOTexture *result = nil;
NSString *path = nil;
BOOL noFNF;
if (EXPECT_NOT(name == nil)) return nil;
if (EXPECT_NOT(!sCheckedExtensions)) [self checkExtensions];
@ -221,6 +222,9 @@ static BOOL sRectangleTextureAvailable;
lodBias = 0.0f;
}
noFNF = options & kOOTextureNoFNFMessage;
options &= ~kOOTextureNoFNFMessage;
// Look for existing texture
key = [NSString stringWithFormat:@"%@%@%@:0x%.4X/%g/%g", directory ? directory : @"", directory ? @"/" : @"", name, options, anisotropy, lodBias];
result = [[sInUseTextures objectForKey:key] pointerValue];
@ -229,7 +233,7 @@ static BOOL sRectangleTextureAvailable;
path = [ResourceManager pathForFileNamed:name inFolder:directory];
if (path == nil)
{
OOLog(kOOLogFileNotFound, @"Could not find texture file \"%@\".", name);
if (!noFNF) OOLog(kOOLogFileNotFound, @"***** ERROR: Could not find texture file \"%@\".", name);
return nil;
}

View File

@ -85,10 +85,12 @@ MA 02110-1301, USA.
- (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;
// 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;
@end

View File

@ -422,6 +422,17 @@ MA 02110-1301, USA.
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;
{
return rgba;

View File

@ -67,7 +67,6 @@ SOFTWARE.
- (GLfloat)collisionRadius;
- (GLfloat)maxDrawDistance;
- (Geometry *)geometry;
- (GLfloat)volume;
- (BoundingBox)boundingBox;
// This needs a better name.

View File

@ -97,12 +97,6 @@ SOFTWARE.
}
- (GLfloat)volume
{
return 0.0f;
}
- (BoundingBox)boundingBox
{
return kZeroBoundingBox;

View File

@ -123,7 +123,6 @@ typedef uint8_t OOMeshMaterialCount;
GLfloat collisionRadius;
GLfloat maxDrawDistance;
BoundingBox boundingBox;
GLfloat volume;
Octree *octree;

View File

@ -167,7 +167,7 @@ shaderBindingTarget:(id<OOWeakReferenceSupport>)object
- (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
{
return [self meshRescaledByX:scaleFactor y:scaleFactor z:scaleFactor];
@ -1228,8 +1222,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
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);
}

View File

@ -80,19 +80,6 @@ MA 02110-1301, USA.
[texture apply];
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);
glVertex3f(x, y+size.height, z);
@ -104,7 +91,7 @@ MA 02110-1301, USA.
glTexCoord2f(1.0, 0.0);
glVertex3f(x+size.width, y+size.height, z);
#endif
glEnd();
glDisable(GL_TEXTURE_2D);
}

View File

@ -829,17 +829,6 @@ static BOOL MaintainLinkedLists(Universe* uni);
[a_planet setEnergy: 1000000.0];
[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];
/*--*/