Author Topic: RotateMesh() and addChild()  (Read 2251 times)

Offline ToddMcF2002

  • long
  • ***
  • Posts: 103
    • View Profile
RotateMesh() and addChild()
« on: April 12, 2007, 03:48:36 am »
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.
Code: [Select]
         
          // 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!


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: RotateMesh() and addChild()
« Reply #1 on: April 12, 2007, 05:27:17 pm »
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... ;)

Offline ToddMcF2002

  • long
  • ***
  • Posts: 103
    • View Profile
Re: RotateMesh() and addChild()
« Reply #2 on: April 12, 2007, 08:02:36 pm »
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.