PDA

View Full Version : urgent .. rotate objects like sprites.


Firas
11-04-2003, 09:25 AM
hi all,

this is urgent .. i need to write an expression assigned to rx,ry,rz to make my object faceing the Camera .. i though Constrain Aim will do it .. but its not.

FrankFirsching
11-04-2003, 07:17 PM
The aim-constraint orients towards the center of the camera. Sprites are oriented to be parallel to the image-plane. You can achieve this using following expression:

float $rot[3] = `xform -q -ws -ro camera1`;
float $compensate[3] = `xform -q -ws -ro groupOfOrientedObject`;
rx = $rot[0]-$compensate[0];
ry = $rot[1]-$compensate[1];
rz = $rot[2]-$compensate[2];

The first line queries the world-orientation of the camera. The second one does this with the object one level higher in the hierarchy, than the oriented object is. The three last lines calculate the necessary angles.
If the object to align to the image-plane is on the top-hierarchy, you don't need the stuff with $compensate.
HTH
Frank

Firas
11-05-2003, 08:18 AM
FrankFirsching

:surprised am sure u didnt give yourself the time to think of it ..

:shrug:

FrankFirsching
11-05-2003, 07:00 PM
This expression is doing the right thing. You can take a look at the attached file. Perhaps you didn't give yourself enough time to understand the expression?!?
By the way, if you want an urgent answer, and somebody is posting, you shouldn't reply with such a defiant comment :thumbsdow Additionally it would be a good idea to explain your problem a bit further, since your elaboration on your problem is quite short.

P.S.: There is also a solution using orient-constraints, but I leave it to you to find this out :p

CGTalk Moderation
01-16-2006, 02: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.