[Plib-users] Matrix rotation question
Brought to you by:
sjbaker
From: McEvoy, N. <nic...@ds...> - 2001-07-12 07:18:02
|
Sorry matrix operations are not my strong point ... can somebody please point out my stupid mistake !? I'm developing a space sim with PLIB ... and I have a problem where my spaceship behaves in a crazy manner when its heading is directly 'UP' and tries to roll to the left or right. // Say my initial my position is as follows: (ie. I'm pointing directly up ... NOTE: this only happens when pointing directory UP !!!) sgCoord mPosition; sgSetCoord(&mPosition, 0.0f, 0.0f, 0.0f, 0.0f, 90.0f, 0.0f); // Say my direction change is as follows: (ie. I'm rolling to the left) sgVec3 mDirChange; sgSetVec3(mDirChange, 0.0f, 0.0f, -0.01f); // I have a loop where the direction change is applied as follows to update the hpr: sgMat4 POS, ROT; sgMakeCoordMat4(POS, &mPosition); sgMakeRotMat4(ROT, mDirChange); sgPreMultMat4(POS, ROT); sgSetCoord(&mPosition, POS); // Why does this loop toggle the hpr part of my mPosition as follows: (causing the model to FREAK OUT flipping between ~0 and 90) hpr: 0, 90, 0 hpr: 0, 90, 90.01 hpr: 0, 90, 6.18986e-006 hpr: 0, 90, 90.01 hpr: 0, 90, 1.38196e-005 hpr: 0, 90, 90.01 hpr: 0, 90, 1.38196e-005 etc ... Any help appreciated, Nick mailto:nic...@as... http://members.ozemail.com.au/~ndmcevoy/ |