PDA

View Full Version : finding the direction of moving chararacter


caspermel
05-15-2007, 09:34 AM
Hi there;

Is there a way to find the objects moving direction in a maya animation? I mean for example,
I have a car model moving in a direction, is there a way to find the models direction so that I can find the front of the model?

I just thought of getting the orientation difference between the two key frames of the moving character may be, but I am not sure how can be made possible?

If I am not clear let me know :)

Thanks a lot

Melis :)

kungfuelmosan
05-19-2007, 02:35 PM
//Hope this is what your after? (lemme know)

//Specify frames to find the difference between
int $frameOne = 1;
int $frameTwo = 3;

/* Or ulternstively use the current frame and the one after it?:

int $frameOne = `currentTime -q`;
int $frameTwo = ($frameOne+1);

*/

//Specify the object (selected)

string $objects[] = `ls -sl`;
string $object = $objects[0];

currentTime $frameOne;
float $worldCoords_one[] = `objectCenter $object`;

currentTime $frameTwo;
float $worldCoords_two[] = `objectCenter $object`;

//Find the difference between frames
float $movedX = ($worldCoords_one[0]-$worldCoords_two[0]);
float $movedY = ($worldCoords_one[1]-$worldCoords_two[1]);
float $movedZ = ($worldCoords_one[2]-$worldCoords_two[2]);

//Print result
print ($object+" has moved: "+$movedX+" along the X axis, "+$movedY+" along the Y axis and "+$movedZ+" along the Z axis";

Sick Spider
05-21-2007, 12:30 AM
By the way, if you are just looking the front of the car, for example, you can just query the front point (CV) of the model, its nuber will stay the same throughout the clip.
You know just do:

float $myFrontPoint[] = `xform -q -ws -t "CarModel.vtx[32]"`;

Or you can just put a locator and parent it to the model and query it.

caspermel
05-21-2007, 08:21 AM
thanks for the replies I will try for them asap :)

Melis

CGTalk Moderation
05-21-2007, 08:21 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.