Game Development Community

Passing rotation information through packUpdate

by Steve Lamperti · in Torque Game Engine · 03/15/2005 (2:35 pm) · 0 replies

I am trying to pass object rotation information through packUpdate, unpackUpdate, and am having quite a bit of trouble figuring out how to do it.
My C++ object is a descendent of ShapeBase. (It was based on Item, but I moved away from that, as Item includes restrictions in rotation that limit it to rotating around the z axis.)

I don't have a mRot instance variable, which is involved in the packUpdate code of both Player, and Camera. I just want to work with passing the information from the transform that is associated with rotation, but whatever code I try seems to do weird things to the object.

Here's the code from Item::packUpdate, which restricts rotation to the z:

if (stream->writeFlag(mask & RotationMask)) {
      // Assumes rotation is about the Z axis
      AngAxisF aa(mObjToWorld);
      stream->writeFlag(aa.axis.z < 0);
      stream->write(aa.angle);
   }

Here's one of my attempts that didn't work.

if (stream->writeFlag(mask & RotationMask))
       {
       Point3F rot;
       mObjToWorld.getColumn(1,&rot);
       mathWrite(*stream, rot);
       }

If someone would let me know what I am missing, I would appreciate it.