PDA

View Full Version : melscript doubt


arunspooja
05-03-2006, 05:25 AM
Hai guys

i dont know how to create an expression for controlling the rotation by values.

ie, if iam creating two objects nurbscircle and polycube.

and adding a boolean attribute to nurbscircle. Through which i want to control the rotation y attribute of polyCube.

The polyCube has to rotate in y-axis from `0 to 70` and it has to return to `70 to 0 to -70`

it has to loop its rotation between 70 to -70

and if i switch "off" the attribute in circle, it has to stop.

can any one help me out to do this

A_New_Hope
05-03-2006, 08:49 AM
maybe something like this?


int $dir;
// rotation speed
float $speed = 1;

// check if control attr is on/true/1
if ( nurbscircle.ControlAttr == on )
{
// check if the rotation is bigger the 70 and the dir is 1
if ( pCube1.rotateY >= 70 && $dir == 1 )
{
// set dir to 0
$dir = 0;
}
// chek if rotation is less then -70 and the dir is 0
else if ( pCube1.rotateY <= -70 && $dir == 0 )
{
// set dir to 1
$dir = 1;
}


if ( $dir == 0 )
{
// if dir = o the decreas the rotation
pCube1.rotateY = pCube1.rotateY - $speed;
}
else
{
// if dit = 1 the increas rotation
pCube1.rotateY = pCube1.rotateY + $speed;
}
}

CGTalk Moderation
05-03-2006, 08:49 AM
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.