RotateMesh() and addChild()

Started by ToddMcF2002, April 12, 2007, 03:48:36 AM

Previous topic - Next topic

ToddMcF2002

Just trying to verify something:

I have to rotate my MD2's in order to orient them properly on the X/Z plane otherwise they run sideways.
         
          // build character
          build()

          // fix mesh alignment on xz plane
  yRot = (float)Math.PI*1.5f;
  rotateY(yRot);
  rotateMesh();

          // this calls addChild() for weapons...
          checkLoadWeapons(c, w);

No matter what sequence combination I use of checkLoadWeapons(), build() and rotateMesh() I always end up having to manually adjust the weapon orientation since rotateMesh() seems to "break" the MD2's origin for the weapon.  In the sequence above I end up cloning the character's rotationMatrix for the weapon and then adjusting X and Z until the weapon matches the hand.  After that all is well.

This is hardly a showstopper since its pretty easy to translate the adjustment.  But - is this expected or am I doing something wrong?

Thanks!


EgonOlsen

That's because the rotation pivot in jPCT is based on the geometry, it's not derived from the MD2 (i'm not sure if it's even in there). Maybe there's a fixed pivot that's valid for all MD2s (like 0,0,0 or something) per definition. Maybe that's worth a try, but then again, i'm doing exactly the same thing... ;)

ToddMcF2002

If I don't rotate the mesh it lines up perfectly.  Like I said though - its a minor inconvenience since I just assume the parent rotation and adjust x/z on the sword until it looks right and write down the translation.  I'm loading from XML so I'm just putting the translation in there along with a bunch of other attributes.