So my question is how can I add more than two equations?
{
[... code ...]
return (SphereTorus == 0.0) ? qSphere : qTorus : qSquare;
}
First: Absolutely do not use == with floats (it doesn't do what you
think it does/won't work reliably/will make you ask more questions on
the mailing list etc ;)
Use Integers if you're going to use ==, otherwise use <, >, <=, >=.
next up, to get more than 2 shapes, you need to nest conditionals like
this:
vec3 functionShape(in float theta,in float phi)
{
vec3 qSphere;
qSphere.x = sin(phi) * cos(theta);
qSphere.y = cos(phi);
qSphere.z = sin(phi) * sin(theta);
vec3 qTorus;
qTorus.x = radio * cos(theta);
qTorus.y = largo * cos(phi);
qTorus.z = radio * sin(theta);
vec3 qSquare;
qSquare.x = radio * cos(theta);
qSquare.y = largo * cos(phi);
qSquare.z = radio * r * sin(theta);
return (SphereTorusSquare == 0) ? qSphere : (SphereTorusSquare ==
1) ? qTorus : qSquare;
}
(Note: I've renamed Spheretorus to SphereTorusSquare, and it's now an
uniform int, where 0 means sphere, 1 means torus, and 2 (or anything
other than 0 or 1 really) means square.)
You can keep following that pattern (adding a conditional to evaluate
as the last expression) to add more.
--
[ christopher wright ]
[email protected]
http://kineme.net/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com
This email sent to [email protected]