ShapeBaseImage Node Transform Confusion
by Tim Dix (Raverix) · in Torque 3D Professional · 08/24/2010 (5:06 pm) · 1 replies
Edit: Solved! mountImage looks like it only happens on the server? Moving that code elsewhere took care of the problem.
Hello, I'm hoping you all can help me clear up some confusion with ShapeBaseImages. What I'm trying to do is manually control some of the node transforms. I thought this would be really simple, but I'm missing something.
I have a class which inherits from ShapeBase, and overrides mountImage like so:
::mountImage()
And then client side I modify the transforms with the following.
::interpolateTick()
Obviously, this is still just debug code and test is only there to ensure I'm constantly rotating so I can see the result. Unfortunately, I'm not seeing a result from this at all. Now, I've noticed some weirdness...
One, findNode("codeTurret") returns 4, and findNode("codeWeapon") returns 6. However, I've found through trial and error that mNodeTransforms[5] = codeTurret, and mNodeTransforms[12] = codeWeapon. Edit: 5, and 12, corresponded to the actual mesh nodes which are linked to 4, and 6, so this is correct behavior... but I still don't know why modifying the transforms for 4 and 6 aren't working.
Is mNodeTransforms using some other index?
Next, you can see in the example I have animate commented out. This is because as long as animate is being called, my transforms are being overridden despite having MaskNodeHandsOff set, is there another step I'm missing here?

Hello, I'm hoping you all can help me clear up some confusion with ShapeBaseImages. What I'm trying to do is manually control some of the node transforms. I thought this would be really simple, but I'm missing something.
I have a class which inherits from ShapeBase, and overrides mountImage like so:
::mountImage()
...
MountedImage& image = mMountedImageList[imageSlot];
if (image.shapeInstance) {
S32 turretNode = image.shapeInstance->getShape()->findNode("codeTurret");
S32 weaponNode = image.shapeInstance->getShape()->findNode("codeWeapon");
if(turretNode != -1)
image.shapeInstance->setNodeAnimationState(turretNode,TSShapeInstance::MaskNodeHandsOff);
if(weaponNode != -1)
image.shapeInstance->setNodeAnimationState(weaponNode,TSShapeInstance::MaskNodeHandsOff);
}
...
}And then client side I modify the transforms with the following.
::interpolateTick()
...
MountedImage& image = mMountedImageList[2];
static F32 test = 0;
if(image.shapeInstance) {
MatrixF *tmat = &image.shapeInstance->mNodeTransforms[image.shapeInstance->getShape()->findNode("codeTurret")];
MatrixF *wmat = &image.shapeInstance->mNodeTransforms[image.shapeInstance->getShape()->findNode("codeWeapon")];
tmat->set(EulerF(test++,0,0));
wmat->identity();
image.shapeInstance->setDirty(TSShapeInstance::TransformDirty);
//image.shapeInstance->animate();
}
...Obviously, this is still just debug code and test is only there to ensure I'm constantly rotating so I can see the result. Unfortunately, I'm not seeing a result from this at all. Now, I've noticed some weirdness...
One, findNode("codeTurret") returns 4, and findNode("codeWeapon") returns 6. However, I've found through trial and error that mNodeTransforms[5] = codeTurret, and mNodeTransforms[12] = codeWeapon. Edit: 5, and 12, corresponded to the actual mesh nodes which are linked to 4, and 6, so this is correct behavior... but I still don't know why modifying the transforms for 4 and 6 aren't working.
Is mNodeTransforms using some other index?
Next, you can see in the example I have animate commented out. This is because as long as animate is being called, my transforms are being overridden despite having MaskNodeHandsOff set, is there another step I'm missing here?

About the author
Torque 3D Owner Tim Dix (Raverix)
<codeTurret id=4> <mesh id=5/> <codeWeapon id=6> <modenodes/> <mesh id=12/>So modifying 5 and 12, in this instance explains why the meshes rotated... unfortunately, I still can't figure out why my rotations on 4 and 6 aren't taking effect.
After stepping through the code, I can see that my turret transform is precisely what I expect it to be before calling shapeInstance->animate();, and then afterwards, the transform is correctly multiplied by it's parent's transform to get it's offset, but I'm not seeing the change in game.