PDA

View Full Version : how to control the sprtite rotation according to its traveling direction


Shankar
10-28-2009, 05:25 AM
hello friends,
I am trying to point the sprite rotation according to its traveling direction. I coudn't get it right.
Can any one of you correct this code
//runtime Expression
vector $orgin = <<0,0,0>>;
vector $pos = particleShape1.position;
float $ang = angle ($orgin,$pos);

particleShape1.spriteTwistPP =rad_to_deg($ang);

Thanks a lot
Sankar

stooch
10-28-2009, 06:39 PM
hello friends,
I am trying to point the sprite rotation according to its traveling direction. I coudn't get it right.
Can any one of you correct this code
//runtime Expression
vector $orgin = <<0,0,0>>;
vector $pos = particleShape1.position;
float $ang = angle ($orgin,$pos);

particleShape1.spriteTwistPP =rad_to_deg($ang);

Thanks a lot
Sankar

in that code. you arent controlling the sprites rotation, you are controlling its twist...
twist is a rotation along one normal, in the case of a sprite, that normal is always pointing at the camera.

quite different.

problem with sprites is that they are... 2d images that face the camera. you might want to use an instancer with textured planes then hook up the rotation to a rotPP variable. note, the rotPP will have to be a vector, since you are describing a 3d rotation using 3d vectors.

now... if you want to TWIST a sprite so taht its always pointing ahead in the SCREEN space, then you must compare vectors from the camera SCREEN coordinates, not from world coordinates.

Aikiman
10-28-2009, 07:54 PM
Theres a mel script on my site that helps you do this. As Stooch has mentioned sprites face the camera so if I remember rightly make sure your camera is facing down the z-axis for this script to work. If it isnt you should be able to play with the code to suit your scene.

If your camera is animated all over the place then you might have to use instancing.

CGTalk Moderation
10-28-2009, 07:54 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.