32#import "MyOpenGLView.h"
39#define SKY_BASIS_STARS 4800
40#define SKY_BASIS_BLOBS 1280
41#define SKY_clusterChance 0.80
46@interface SkyEntity (OOPrivate)
48- (BOOL)readColor1:(
OOColor **)ioColor1 andColor2:(
OOColor **)ioColor2 andColor3:(
OOColor **)ioColor3 andColor4:(
OOColor **)ioColor4 fromDictionary:(NSDictionary *)dictionary;
55- (id) initWithColors:(
OOColor *)col1 :(
OOColor *)col2 andSystemInfo:(NSDictionary *)systemInfo
62 nebulaCountMultiplier;
67 if (
self ==
nil)
return nil;
82 clusterChance = [systemInfo oo_floatForKey:@"sky_blur_cluster_chance" defaultValue:SKY_clusterChance];
83 alpha = [systemInfo oo_floatForKey:@"sky_blur_alpha" defaultValue:SKY_alpha];
84 scale = [systemInfo oo_floatForKey:@"sky_blur_scale" defaultValue:SKY_scale];
87 starCount = [systemInfo oo_floatForKey:@"sky_n_stars" defaultValue:-1];
88 starCountMultiplier = [systemInfo oo_floatForKey:@"star_count_multiplier" defaultValue:1.0f];
89 if (starCountMultiplier < 0.0f) starCountMultiplier *= -1.0f;
94 starCount *= starCountMultiplier;
102 nebulaCount = [systemInfo oo_floatForKey:@"sky_n_blurs" defaultValue:-1];
103 nebulaCountMultiplier = [systemInfo oo_floatForKey:@"nebula_count_multiplier" defaultValue:1.0f];
104 if (nebulaCountMultiplier < 0.0f) nebulaCountMultiplier *= -1.0f;
105 if (0 <= nebulaCount)
109 nebulaCount *= nebulaCountMultiplier;
136 nebulaCount:nebulaCount
137 nebulaHueFix:nebulaColorSet
138 clusterFactor:clusterChance
142 [skyDrawable release];
164- (BOOL) changeProperty:(NSString *)key withDictionary:(NSDictionary*)dict
166 id object = [dict objectForKey:key];
169 if ([key isEqualToString:
@"sun_color"])
175 skyColor = [col copy];
177 [UNIVERSE setLighting];
182 OOLogWARN(
@"script.warning",
@"Change to property '%@' not applied, will apply only on leaving and re-entering this system.",key);
193 cam_zero_distance = zero_distance;
200 OOLog(
@"sky.warning",
@"%@",
@"PLAYER is nil");
223- (GLfloat) cameraRangeFront
229- (GLfloat) cameraRangeBack
235- (void) drawImmediate:(
bool)immediate translucent:(
bool)translucent
237 if ([
UNIVERSE breakPatternHide])
return;
239 [
super drawImmediate:immediate translucent:translucent];
246- (NSString *) descriptionForObjDump
249 return [
self descriptionForObjDumpBasic];
256@implementation SkyEntity (OOPrivate)
258- (BOOL)readColor1:(
OOColor **)ioColor1 andColor2:(
OOColor **)ioColor2 andColor3:(
OOColor **)ioColor3 andColor4:(
OOColor **)ioColor4 fromDictionary:(NSDictionary *)dictionary
260 NSString *
string =
nil;
261 NSArray *tokens =
nil;
266 assert(ioColor1 != NULL && ioColor2 != NULL);
268 string = [dictionary oo_stringForKey:@"sky_rgb_colors"];
273 if ([tokens
count] == 6)
275 float r1 = OOClamp_0_1_f([tokens oo_floatAtIndex:0]);
276 float g1 = OOClamp_0_1_f([tokens oo_floatAtIndex:1]);
277 float b1 = OOClamp_0_1_f([tokens oo_floatAtIndex:2]);
278 float r2 = OOClamp_0_1_f([tokens oo_floatAtIndex:3]);
279 float g2 = OOClamp_0_1_f([tokens oo_floatAtIndex:4]);
280 float b2 = OOClamp_0_1_f([tokens oo_floatAtIndex:5]);
286 OOLogWARN(
@"sky.fromDict",
@"could not interpret \"%@\
" as two RGB colours (must be six numbers).",
string);
289 colorDesc = [dictionary objectForKey:@"sky_color_1"];
290 if (colorDesc !=
nil)
293 if (color !=
nil) *ioColor1 = color;
294 else OOLogWARN(
@"sky.fromDict",
@"could not interpret \"%@\
" as a colour.", colorDesc);
296 colorDesc = [dictionary objectForKey:@"sky_color_2"];
297 if (colorDesc !=
nil)
300 if (color !=
nil) *ioColor2 = color;
301 else OOLogWARN(
@"sky.fromDict",
@"could not interpret \"%@\
" as a colour.", colorDesc);
304 colorDesc = [dictionary objectForKey:@"nebula_color_1"];
305 if (colorDesc !=
nil)
313 else OOLogWARN(
@"sky.fromDict",
@"could not interpret \"%@\
" as a colour.", colorDesc);
317 colorDesc = [dictionary objectForKey:@"sky_color_1"];
318 if (colorDesc !=
nil)
321 if (color !=
nil) *ioColor3 = color;
322 else OOLogWARN(
@"sky.fromDict",
@"could not interpret \"%@\
" as a colour.", colorDesc);
326 colorDesc = [dictionary objectForKey:@"nebula_color_2"];
327 if (colorDesc !=
nil)
335 else OOLogWARN(
@"sky.fromDict",
@"could not interpret \"%@\
" as a colour.", colorDesc);
339 colorDesc = [dictionary objectForKey:@"sky_color_2"];
340 if (colorDesc !=
nil)
343 if (color !=
nil) *ioColor4 = color;
344 else OOLogWARN(
@"sky.fromDict",
@"could not interpret \"%@\
" as a colour.", colorDesc);
#define OOLogWARN(class, format,...)
#define OOLog(class, format,...)
BOOL OOCheckOpenGLErrors(NSString *format,...)
NSMutableArray * ScanTokensFromString(NSString *values)
void setStatus:(OOEntityStatus stat)
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
OOColor * colorWithDescription:(id description)
OOColor * premultipliedColor()
OOColor * blendedColorWithFraction:ofColor:(float fraction,[ofColor] OOColor *color)
void setDrawable:(OODrawable *drawable)
HPVector viewpointPosition()
BOOL readColor1:andColor2:andColor3:andColor4:fromDictionary:(OOColor **ioColor1,[andColor2] OOColor **ioColor2,[andColor3] OOColor **ioColor3,[andColor4] OOColor **ioColor4,[fromDictionary] NSDictionary *dictionary)