Game Development Community

Nodes and mount points

by Bill Vee · in Technical Issues · 05/16/2006 (6:26 pm) · 1 replies

Ok a while back I was playing around with mounts and needed a way to change a mount in a vehicle thru script and I found a useful post for getnodepoint at
This thread

What I needed was the mount position in relation to what it is mounted to.
Modified the code not to add the vehicleTransform and got what I needed.

ConsoleMethod(Vehicle, getNodePosition, const char*, 3, 3,
 "point getNodePosition(string nodeName)")
{
	Point3F nodePoint;
	MatrixF vehicleTransform;
	nodePoint = object->getNodePoint(argv[2]);
	//vehicleTransform = object->getTransform();
	//vehicleTransform.mulP(nodePoint);
	char* buff = Con::getReturnBuffer(100);
	dSprintf(buff, 100, "%g %g %g", nodePoint.x, nodePoint.y, nodePoint.z);
	return buff;
}
// Supporting Vehicle::Function
Point3F Vehicle::getNodePoint(const char* nodeName) {
Point3F nodePoint;
MatrixF nodeMat;
S32 nodeIndex;
nodeIndex = mDataBlock->shape->findNode(nodeName);
	if (nodeIndex != -1) {
nodeMat = mShapeInstance->mNodeTransforms[nodeIndex];
nodeMat.getColumn(3, &nodePoint);
} 
else {
Con::warnf("Error from getNodePosition(%s). The node does not exist.", 
nodeName);
}
return nodePoint;
}
Then modified it more to setNodePosition and it seems to work almost.
ConsoleMethod(Vehicle, setNodePosition, const char*, 4, 4,"(string nodeName,Point3F pos)")
{
	Point3F nodePoint;
	MatrixF vehicleTransform;
	Point3F pos;
   dSscanf(argv[3], "%g %g %g",
           &pos.x,
           &pos.y,
           &pos.z);
	//nodePoint = 
		object->setNodePoint(argv[2],pos);
	//vehicleTransform = object->getTransform();
	//vehicleTransform.mulP(nodePoint);
	char* buff = Con::getReturnBuffer(100);
	dSprintf(buff, 100, "%g %g %g", nodePoint.x, nodePoint.y, nodePoint.z);
	return buff;
}
// Supporting Vehicle::Function
void Vehicle::setNodePoint(const char* nodeName,Point3F offset1)
{
	Point3F nodePoint;
MatrixF nodeMat;
S32 nodeIndex;
nodeIndex = mDataBlock->shape->findNode(nodeName);

if (nodeIndex != -1) {
nodeMat = mShapeInstance->mNodeTransforms[nodeIndex];
nodeMat.setColumn(3, offset1);
mShapeInstance->mNodeTransforms[nodeIndex] = nodeMat;
} 
else {
Con::warnf("Error from getNodePosition(%s). The node does not exist.", 
nodeName);
}

}
It will grab the mount position correctly and It seems I can change it but the mount position dosn't appear to change on screen.

This is the relevant info from log file.

Reading mount0 position
%nodePosition,mount0 -4.8821 -2.69541 2.55578

Reading contrail0 position
%nodePosition,contrail0 -0.0573984 -13.1034 -0.1

Setting mount0 to 0 10 0

Reading mount0 position agian
%nodePosition,mount0 0 10 0

It seems to do what I want it to but the player still mounts to the old position.

I am assuming that mShapeInstance->mNodeTransforms[nodeIndex] is the mount/node points that is in all of the code dealing with getting the position of the mounted object.
So it would seem that by altering mShapeInstance->mNodeTransforms[nodeIndex] would do the trick but it doesn

#1
07/03/2006 (5:40 pm)
Posting: Unread posting for more than 30 days. I am posting to help get a reply to your un-answered question.