Added uniform types for random numbers, vectors and quaternions.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1773 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
5e8da50afc
commit
47563b5518
@ -325,6 +325,7 @@ static NSString *MacrosToString(NSDictionary *macros);
|
|||||||
SEL selector = NULL;
|
SEL selector = NULL;
|
||||||
OOUniformConvertOptions convertOptions;
|
OOUniformConvertOptions convertOptions;
|
||||||
BOOL quatAsMatrix = YES;
|
BOOL quatAsMatrix = YES;
|
||||||
|
GLfloat scale = 1.0;
|
||||||
|
|
||||||
for (uniformEnum = [uniformDefs keyEnumerator]; (name = [uniformEnum nextObject]); )
|
for (uniformEnum = [uniformDefs keyEnumerator]; (name = [uniformEnum nextObject]); )
|
||||||
{
|
{
|
||||||
@ -341,6 +342,7 @@ static NSString *MacrosToString(NSDictionary *macros);
|
|||||||
value = [(NSDictionary *)definition objectForKey:@"value"];
|
value = [(NSDictionary *)definition objectForKey:@"value"];
|
||||||
binding = [(NSDictionary *)definition stringForKey:@"binding"];
|
binding = [(NSDictionary *)definition stringForKey:@"binding"];
|
||||||
type = [(NSDictionary *)definition stringForKey:@"type"];
|
type = [(NSDictionary *)definition stringForKey:@"type"];
|
||||||
|
scale = [(NSDictionary *)definition floatForKey:@"scale" defaultValue:1.0];
|
||||||
if (type == nil)
|
if (type == nil)
|
||||||
{
|
{
|
||||||
if (value == nil && binding != nil) type = @"binding";
|
if (value == nil && binding != nil) type = @"binding";
|
||||||
@ -357,6 +359,38 @@ static NSString *MacrosToString(NSDictionary *macros);
|
|||||||
binding = definition;
|
binding = definition;
|
||||||
type = @"binding";
|
type = @"binding";
|
||||||
}
|
}
|
||||||
|
else if ([definition isKindOfClass:[NSArray class]])
|
||||||
|
{
|
||||||
|
binding = definition;
|
||||||
|
type = @"vector";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transform random values to concrete values
|
||||||
|
if ([type isEqualToString:@"randomFloat"])
|
||||||
|
{
|
||||||
|
type = @"float";
|
||||||
|
value = [NSNumber numberWithFloat:randf() * scale];
|
||||||
|
}
|
||||||
|
else if ([type isEqualToString:@"randomUnitVector"])
|
||||||
|
{
|
||||||
|
type = @"vector";
|
||||||
|
value = OOPropertyListFromVector(vector_multiply_scalar(OORandomUnitVector(), scale));
|
||||||
|
}
|
||||||
|
else if ([type isEqualToString:@"randomVectorSpatial"])
|
||||||
|
{
|
||||||
|
type = @"vector";
|
||||||
|
value = OOPropertyListFromVector(OOVectorRandomSpatial(scale));
|
||||||
|
}
|
||||||
|
else if ([type isEqualToString:@"randomVectorRadial"])
|
||||||
|
{
|
||||||
|
type = @"vector";
|
||||||
|
value = OOPropertyListFromVector(OOVectorRandomRadial(scale));
|
||||||
|
}
|
||||||
|
else if ([type isEqualToString:@"randomQuaternion"])
|
||||||
|
{
|
||||||
|
type = @"quaternion";
|
||||||
|
value = OOPropertyListFromQuaternion(OORandomQuaternion());
|
||||||
|
}
|
||||||
|
|
||||||
if ([type isEqualToString:@"float"] || [type isEqualToString:@"real"])
|
if ([type isEqualToString:@"float"] || [type isEqualToString:@"real"])
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user