PDA

View Full Version : assigning nurbs to ocean shader


aracid
02-07-2005, 02:05 PM
hey all

theres a really simple problem that im trying to solve, and theres a tutorial available where u can link the height of nurbs control points to an ocean shader.

basically

float $u,$v;
float $minX = nurbsPlane2.scaleX * -.5 +nurbsPlane2.translateX;
float $maxX = nurbsPlane2.scaleX * .5 +nurbsPlane2.translateX;
float $minZ = nurbsPlane2.scaleZ * -.5 +nurbsPlane2.translateZ;
float $maxZ = nurbsPlane2.scaleZ * .5 +nurbsPlane2.translateZ;

float $displ[] = `colorAtPoint -o A -su 5 -sv 5 -mu $minX -mv $minZ -xu $maxX -xv $maxZ oceanShader1`;
//----
nurbsPlaneShape2.controlPoints[0].yValue = $displ[4];
nurbsPlaneShape2.controlPoints[1].yValue = $displ[3];
nurbsPlaneShape2.controlPoints[2].yValue = $displ[2];
nurbsPlaneShape2.controlPoints[3].yValue = $displ[1];
nurbsPlaneShape2.controlPoints[4].yValue =$displ[0];

nurbsPlaneShape2.controlPoints[5].yValue = $displ[9];
nurbsPlaneShape2.controlPoints[6].yValue = $displ[8];
nurbsPlaneShape2.controlPoints[7].yValue = $displ[7];
nurbsPlaneShape2.controlPoints[8].yValue = $displ[6];
nurbsPlaneShape2.controlPoints[9].yValue = $displ[5];
etc...

thats not my code, it belongs to Duncan Brinsmead & Neehar Karnik..

however i dont see why u have to have each control point modified manually.

float $loopU;
for ($loopU = 0; $loopU > $umax; $loopU ++)
{
nurbsPlaneShape2.controlPoints[$loopU ].yValue = 1;//$displ[4];

};


the algarithm isnt tough, but theres something silly going on in the assignment phase,
and that through a for loop statement, i cant alter the
nurbsPlaneShape2.controlPoints[$loopU ].yValue


thanks in advance
all the best

aracid

Jhavna
02-08-2005, 03:29 PM
for ($loopU = 0; $loopU > $umax; $loopU ++)

should read:

for ($loopU = 0; $loopU < $umax; $loopU ++)

otherwise the loop will not run as $loopU isn't greater than $umax. The loop will iterate while the middle statement is true.

Also $loopU doesn't need to be a float does it... I suggest using an int instead :)

aracid
02-08-2005, 04:37 PM
thanks so much :bounce:

all the best

aracid

CGTalk Moderation
02-08-2006, 05:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.