Understanding Ghost/NonGhost separation and animations
by Johan Janssen · in Torque Game Engine · 02/01/2008 (4:09 am) · 1 replies
I'm having a bit of a problem with disabling bone animations. What I'm trying to do is to directly take control over the bone rotations from script.
I defined the following functions on the player object to be called from script:
And what these do is:
However, what happens is that the bones are still animated. After staring at the code for two days I finally figured it out:
The object called and updated from script is: ghosted
The object that is animated in the animation loop is: non-ghosted
The question is, how can I get the non-ghosted object from script? Or, how can I get the non-ghosted object in C++ when I do have the ghosted object?
thanks in advance!
I defined the following functions on the player object to be called from script:
ConsoleMethod( Player, directBoneControl, void, 3, 3, "directBoneControl(boneName)") {
object->freeHeadRotation("bla");
}
ConsoleMethod( Player, disableDirectBoneControl, void, 2, 2, "disableDirectBoneControl()") {
object->lockHeadRotation();
}And what these do is:
void Player::freeHeadRotation( const char* boneName )
{
TSShape * shape = mShapeInstance->getShape();
// TODO JJ: get bone id by name
for (U32 i=0;i<shape->nodes.size();i++){
mShapeInstance->setNodeAnimationState(i, mShapeInstance->MaskNodeHandsOff);
}
}However, what happens is that the bones are still animated. After staring at the code for two days I finally figured it out:
The object called and updated from script is: ghosted
The object that is animated in the animation loop is: non-ghosted
The question is, how can I get the non-ghosted object from script? Or, how can I get the non-ghosted object in C++ when I do have the ghosted object?
thanks in advance!
Associate Fyodor -bank- Osokin
Dedicated Logic
#. After "disabling" animations on server, to tell the client to disable it too
#. Try to disable it directly on client-side.
I'm not sure if the second is correct, but first is "correct" one (IMHO).
For debug/testing purposes I would recommend doing something like this:
$temp::directBoneControl = true;
and in sources do the check:
if (Con::getBoolVariable("$temp::directBoneControl", false)) { // do the stuff } else { // do another stuff }And, if you change the state of this flag on server, do commandToClient, so client will know about it too:client-side:
function clientCmdDBoneControl(%newFlag) { $temp::directBoneControl = %newFlag; }And on server:function setBoneControl(%flag) { $temp::directBoneControl = %newFlag; for(%i=0; %i < ClientGroup.getCount(); %i++) { %client = ClientGroup.getObject(%i); commandToClient(%client, 'DBoneControl', %flag); } }P.S. This code is written by hands directly in browser, so I can't promise it will work as expected :)
well... at least some hints are presented!
P.P.S. Of course in final it would be good to implement ghosting the value together with the rest stuff, and per-object (player), just add code to the packUpdate / unpackUpdate.