Atmosphere color parameters can now be also controlled from the JS Planet object. This enables script control over atmospheres of OXP added planets. The two new properties are airColor and airColorMixRatio. The system.info.airColor and .airColorMixRatio remain but control only the main system planet.
parent
3021c8f3ca
commit
2d1bcb200f
|
@ -123,7 +123,7 @@
|
|||
{
|
||||
atmPosition = "relativePosition";
|
||||
atmRadius = "collisionRadius";
|
||||
atmColor = "airColor";
|
||||
atmColor = "airColorAsVector";
|
||||
atmColorMixRatio = "airColorMixRatio";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -366,7 +366,7 @@
|
|||
"timeElapsedSinceSpawn",
|
||||
"throwingSparks",
|
||||
"fogUniform",
|
||||
"airColor",
|
||||
"airColorAsVector",
|
||||
"airColorMixRatio",
|
||||
|
||||
// Renamed, previously player-only properties for 1.74
|
||||
|
|
|
@ -91,7 +91,8 @@ MA 02110-1301, USA.
|
|||
|
||||
- (BOOL) isFinishedLoading;
|
||||
|
||||
- (Vector) airColor; // visible to shader bindings
|
||||
- (Vector) airColorAsVector; // visible to shader bindings
|
||||
- (OOColor *) airColor;
|
||||
- (void) setAirColor:(OOColor *) newColor;
|
||||
- (float) airColorMixRatio; // visible to shader bindings
|
||||
- (void) setAirColorMixRatio:(float) newRatio;
|
||||
|
|
|
@ -390,7 +390,7 @@ static OOColor *ColorWithHSBColor(Vector c)
|
|||
color = [OOColor colorWithDescription:[sourceInfo objectForKey:@"air_color"]];
|
||||
if (color != nil) seaHSB = HSBColorWithColor(color);
|
||||
color = [OOColor colorWithDescription:[sourceInfo objectForKey:@"cloud_color"]];
|
||||
if (color != nil) landHSB = HSBColorWithColor(color);
|
||||
if (color != nil) landHSB = HSBColorWithColor(color);
|
||||
|
||||
// polar areas: brighter, less saturation
|
||||
landPolarHSB = vector_add(landHSB,LighterHSBColor(landHSB));
|
||||
|
@ -795,7 +795,7 @@ static OOColor *ColorWithHSBColor(Vector c)
|
|||
|
||||
|
||||
// this method is visible to shader bindings, hence it returns vector
|
||||
- (Vector) airColor
|
||||
- (Vector) airColorAsVector
|
||||
{
|
||||
float r, g, b, a;
|
||||
[_airColor getRed:&r green:&g blue:&b alpha:&a];
|
||||
|
@ -803,6 +803,12 @@ static OOColor *ColorWithHSBColor(Vector c)
|
|||
}
|
||||
|
||||
|
||||
- (OOColor *) airColor
|
||||
{
|
||||
return _airColor;
|
||||
}
|
||||
|
||||
|
||||
- (void) setAirColor:(OOColor *) newColor
|
||||
{
|
||||
if (newColor)
|
||||
|
|
|
@ -58,6 +58,8 @@ static JSClass sPlanetClass =
|
|||
enum
|
||||
{
|
||||
// Property IDs
|
||||
kPlanet_airColor, // air color, read/write
|
||||
kPlanet_airColorMixRatio, // air color mix ratio, float, read/write
|
||||
kPlanet_isMainPlanet, // Is [UNIVERSE planet], boolean, read-only
|
||||
kPlanet_hasAtmosphere,
|
||||
kPlanet_name, // Name of planet, string, read/write
|
||||
|
@ -71,6 +73,8 @@ enum
|
|||
static JSPropertySpec sPlanetProperties[] =
|
||||
{
|
||||
// JS name ID flags
|
||||
{ "airColor", kPlanet_airColor, OOJS_PROP_READWRITE_CB },
|
||||
{ "airColorMixRatio", kPlanet_airColorMixRatio, OOJS_PROP_READWRITE_CB },
|
||||
{ "hasAtmosphere", kPlanet_hasAtmosphere, OOJS_PROP_READONLY_CB },
|
||||
{ "isMainPlanet", kPlanet_isMainPlanet, OOJS_PROP_READONLY_CB },
|
||||
{ "name", kPlanet_name, OOJS_PROP_READWRITE_CB },
|
||||
|
@ -136,6 +140,13 @@ static JSBool PlanetGetProperty(JSContext *context, JSObject *this, jsid propID,
|
|||
|
||||
switch (JSID_TO_INT(propID))
|
||||
{
|
||||
case kPlanet_airColor:
|
||||
*value = OOJSValueFromNativeObject(context, [[planet airColor] normalizedArray]);
|
||||
return YES;
|
||||
|
||||
case kPlanet_airColorMixRatio:
|
||||
return JS_NewNumberValue(context, [planet airColorMixRatio], value);
|
||||
|
||||
case kPlanet_isMainPlanet:
|
||||
*value = OOJSValueFromBOOL(planet == (id)[UNIVERSE planet]);
|
||||
return YES;
|
||||
|
@ -180,11 +191,28 @@ static JSBool PlanetSetProperty(JSContext *context, JSObject *this, jsid propID,
|
|||
NSString *sValue = nil;
|
||||
Quaternion qValue;
|
||||
jsdouble dValue;
|
||||
OOColor *colorForScript = nil;
|
||||
|
||||
if (!JSPlanetGetPlanetEntity(context, this, &planet)) return NO;
|
||||
|
||||
switch (JSID_TO_INT(propID))
|
||||
{
|
||||
case kPlanet_airColor:
|
||||
colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
|
||||
if (colorForScript != nil || JSVAL_IS_NULL(*value))
|
||||
{
|
||||
[planet setAirColor:colorForScript];
|
||||
return YES;
|
||||
}
|
||||
break;
|
||||
|
||||
case kPlanet_airColorMixRatio:
|
||||
if (JS_ValueToNumber(context, *value, &dValue))
|
||||
{
|
||||
[planet setAirColorMixRatio:dValue];
|
||||
return YES;
|
||||
}
|
||||
break;
|
||||
|
||||
case kPlanet_name:
|
||||
sValue = OOStringFromJSValue(context, *value);
|
||||
|
|
Loading…
Reference in New Issue