Game Development Community

setTransform / packUpdate not propagating position to World Editor

by ArchieMD User · in Torque 3D Professional · 02/04/2010 (6:26 pm) · 5 replies

I have an object derived from SceneObject, let's call it MySceneObject. Its position and orientation are being updated by a 6 dof input device, calling setTransform on MySceneObject. I want MySceneObject to take on the pose reported by the 6 dof input device.

However, when I check if this is occurring (inside of World Editor), ONLY the rotation is being updated and the position is NOT being updated.

The pipeline is:
6dof input device --> (quat, vec) --> MyManager::get6DOF_callback --> thread-safe call to update a datastructure in the manager class --> MyManager::onProcessTick --> passes transform to scene object by calling MySceneObject::setTransform on the server copy of MySceneObject. This all works. MySceneObject's objToWorld and worldToObj matrices are successfully updated in setTransform. However, only the orientation component makes it to the clients, and only the orientation is visibly changed.

Edit: scale also gets changed. Position stays at 0,0,0 no matter what values are in the actual matrix.

For clarity (i hope):

setTransform:
// Let SceneObject handle all of the matrix manipulation
   Parent::setTransform( mat );

   // Dirty our network mask so that the new transform gets
   // transmitted to the client object
   setMaskBits( TransformMask );

packUpdate does get called:
// Allow the Parent to get a crack at writing its info
   U32 retMask = Parent::packUpdate( conn, mask, stream );

   // Write our transform information
   if ( stream->writeFlag( mask & TransformMask ) )
   {
      mathWrite(*stream, getTransform());
      mathWrite(*stream, getScale());
   }
   return retMask;

and the result is the object's rotation gets updated in the scene, but the position does not. I've tried setting the typeMask on the object to all kinds of different types, because every related thread I've found ends with a non-helpful person saying "you made it a static object, that's why it doesn't move you moron", but that has no effect.

Suggestions, comments, pointers to helpful threads?
Thanks

#1
02/05/2010 (11:27 am)

What does your corresponding code in unpackUpdate look like?
#2
02/05/2010 (11:48 am)
// Let the Parent read any info it sent
   Parent::unpackUpdate(conn, stream);

   if ( stream->readFlag() )  // TransformMask
   {
      mathRead(*stream, &mObjToWorld);
      mathRead(*stream, &mObjScale);

      setTransform( mObjToWorld );
   }

I am able to get the position to update by calling (in a separate method mimicking setTransform) SceneObject::setPosition(...). Of course setPosition ends up calling setTransform so it's kind of inefficient at the moment. I think I was setting the translation vector of the matrix incorrectly before... though it boggles the mind that MatrixF did not ship with a setTranslation or makeTranslationMatrix method in box. The quaternion and matrix math support is "light" to be polite. That's what I get for using a game engine to make something that's not a traditional game
#3
02/05/2010 (12:04 pm)
Yep, it's 3,7,11 not 12,13,14. That's exactly why every matrix class needs a setTranslation method.
#4
02/05/2010 (12:19 pm)

MarixF::setPosition is probably what you're looking for.

Generally, you shouldn't directly read into mObjToWorld or mObjScale since these are supposed to be set by setTranform and setScale, so in this case, setTransform will be overwriting the matrix with itself--which, of course, shouldn't do any harm here.
#5
02/05/2010 (12:23 pm)
ah, I see it now. Thanks Rene.