PDA

View Full Version : Getting position over time


eledh_telamion
12-18-2006, 11:32 AM
In an own method, I must get the position of an object in 3 different times. If "t" is our current time/frame, how can I get the positions of this object in these 3 times (t-1, t and t+1)?

erilaz
12-18-2006, 12:53 PM
Try using the at time function. You can set up something like this:


t = yourtime
for i = -1 to 1 do
(
at time (t + i)
objPos = yourObject.pos
print objPos

)

eledh_telamion
12-18-2006, 01:00 PM
Thanks erilaz, but I was working with VC++ on a plugin, and I think that you had just posted is a script. Despite of, thanks a lot.

shibumenon
12-18-2006, 01:05 PM
--function to get the pos at the times you require

fn get3Pos obj =
(
Pos3 = #()
curT = currentTime
Pos3 = (for i = -1 to 1 collect (at time (curT +i) obj.transform.pos) )
return Pos3
)

-- usage:
posArray = get3Pos $

shibumenon
12-18-2006, 01:09 PM
ooops ! .... a li'l while ago there was just a question and no replies !!

HalfVector
12-18-2006, 02:06 PM
Try the INode::GetObjTMAfterWSM method. It returns the world tranformation matrix (row 4 is the actual position) for a node in the given time.

eledh_telamion
12-19-2006, 11:20 AM
Well, I'd tried as you said, but apart of this method something fails when I'm getting values from the TM. There's a way to convert int into string to write ina MessageBox for example? I'm looking in the MSDN help, but I've no found nothing!

HalfVector
12-19-2006, 12:13 PM
So you want to print the matrix in a message box?.

void PrintMatrix(Matrix3 &mat)
{
TCHAR buffer[512];
memset(buffer, 0, 512);
sprintf(buffer, "The matrix is:\n\n( %.5f %.5f %.5f )\n( %.5f %.5f %.5f )\n( %.5f %.5f %.5f )\n( %.5f %.5f %.5f )",
mat.m[0][0], mat.m[0][1], mat.m[0][2],
mat.m[1][0], mat.m[1][1], mat.m[1][2],
mat.m[2][0], mat.m[2][1], mat.m[2][2],
mat.m[3][0], mat.m[3][1], mat.m[3][2]);
MessageBox(NULL, buffer, "Info", MB_OK);
}

I've not compiled that code so it could contains some error.

eledh_telamion
03-06-2007, 10:36 AM
A little question:

calling INode::GetObjTMAfterWSM and then getTrans would return the position of the node at T time?

eledh_telamion
03-14-2007, 12:41 PM
I write this method to get the speed of the object at time t. I'm not sure that it would work correctly. Any advice? Thanks!



Vector3D RingMaster::getVel(TimeValue t, Interval &valid)
{



Vector3D vel;



//t.vel= ((t+1.pos-t.pos)/2) + ((t.pos-t-1.vel)/2);



Matrix3 m0 = padre->GetNodeTM(t-1, &valid); // t-1

Point3 t0pos = m0.GetTrans();

Matrix3 m1 = padre->GetNodeTM(t, &valid); // t

Point3 t1pos = m1.GetTrans();

Matrix3 m2 = padre->GetNodeTM(t+1, &valid); // t+1

Point3 t2pos = m2.GetTrans();





if ( t==0 ) {

vel = Vector3D( (t2pos.x - t1pos.x)/2 , (t2pos.y - t1pos.y)/2 , (t2pos.z - t1pos.z)/2 );

////} else if ( t==n){

//// vel = Vector3D((t1pos - t0pos)/2);

} else {

vel = Vector3D( ((t2pos.x - t1pos.x)/2) + ((t1pos.x - t0pos.x)/2) , ((t2pos.y - t1pos.y)/2) + ((t1pos.y - t0pos.y)/2) , ((t2pos.z - t1pos.z)/2) + ((t1pos.z - t0pos.z)/2));

}



return (vel);

}

CGTalk Moderation
03-14-2007, 12:41 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.