Game Development Community

Position of Nodes. Help needed

by Albert Steckenborn · in Torque Game Engine · 09/07/2006 (4:46 pm) · 4 replies

Hi,
i've created a model file with two boxes in it. Exery Box has a Collision box too. The boxes are connected in the tree in this way:

Start01
->pxNodeBox01
|---> Box01
|---> Col01
->pxNodeBox02
|---> Box02
|---> Col02
->pxNodeJoint01

in the Preload method im searching for the nodes to get the following informations out of the models.

1) position of each box
2) size of each box

But how to do that ?
i've created some code to read the position. But is it the local position (in the file) or the world position in game ?
How do i get the size of each box and how can i change the position of each box ?

Thanks for helping !

// get node Box1 and Position
   pxNodeBox01     = shapeResource->findNode("pxNodeBox01");
   AssertFatal(pxNodeBox01>=0,"PhysXJointData::preload: missing node pxNodeBox01");
   shapeInstance->mNodeTransforms[pxNodeBox01].getColumn(3,&pxNodeBoxPos01);

   // get node Box2 and Position
   pxNodeBox02     = shapeResource->findNode("pxNodeBox02");
   AssertFatal(pxNodeBox02>=0,"PhysXJointData::preload: missing node pxNodeBox02");
   shapeInstance->mNodeTransforms[pxNodeBox02].getColumn(3,&pxNodeBoxPos02);

   // get node Joint and Position
   pxNodeJoint01     = shapeResource->findNode("pxNodeJoint01");
   AssertFatal(pxNodeJoint01>=0,"PhysXJointData::preload: missing node pxNodeJoint01");
   shapeInstance->mNodeTransforms[pxNodeJoint01].getColumn(3,&pxNodeJointPos01);

#1
09/09/2006 (6:40 am)
Ok. i've found it out. Only one question left.

with these code i can change the position of the complete model (two boxes)

NxVec3 pos = mActor01->getGlobalPosition();
		NxQuat quat = mActor01->getGlobalOrientationQuat();
		MatrixF mat;
		QuatF	q(quat.x,quat.y,quat.z,quat.w);
		q.setMatrix(&mat);
		mat.inverse(); // coz in setTransform it will inverse!
		mat.setColumn(3,Point3F(pos.x,pos.y,pos.z));
		Parent::setTransform(mat);


but i only want to animate one of both boxes.
i've tested it with these code

S32 node = mDataBlock->pxNodeBox01;
		MatrixF * mat = &mDataBlock->shapeInstance->mNodeTransforms[node];
		Point3F defaultPos = mDataBlock->shapeResource->defaultTranslations[node];
		defaultPos.z += 1.0; // only testing purposes
		mat->identity();
		mat->setColumn(3,defaultPos);

bus the box do not move.
Can anybody help me out ?
#3
09/10/2006 (12:50 pm)
Are you trying to animate the nodes?

If yes then this resource is good:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5345

I have not gotten into doing full fledged node animation. I am leading up to that, but I have not gotten there. I do know that this turret code does work. It may be able to help flesh out your code.
#4
09/11/2006 (2:24 am)
Thx man.
I will check it :-D