R: [Plib-users] ssg camera woes / tranformation/coordsystem confusion
Brought to you by:
sjbaker
From: Paolo L. <p.l...@ci...> - 2006-02-13 09:56:35
|
> -----Messaggio originale----- > Da: pli...@li... [mailto:pli...@li...]=20 > Per conto di Eduardo Alberto Hern=E1ndez Mu=F1oz > Inviato: domenica 12 febbraio 2006 21.49 > A: pli...@li... > Oggetto: Re: [Plib-users] ssg camera woes / tranformation/coordsystem confusion >=20 >=20 > > Hi. I have some pre-SSG/own code, I'm trying to migrate to SSG.=20 > > However, my camera code screws up; it's as if the axes are switched, = or > > worse. > >=20 > > For example, my code has a direction/rotation matrix, that indicates > > the users' rotation around the y axis (it could be a rotation angle instead,=20 > > but I'm exploiting that it's a matrix). > >=20 > > However, when I multiply this matrix onto the ssg camera, it rotates around > > the _Z_ axis instead! > > Similar problems happen with other parts of the transform (which = I've=20 > > commented out to dissect the problem). >=20 >=20 > This is a quote from a page at Steve Baker's tuxkart site at > http://tuxkart.sourceforge.net/trackdesign.html : >=20 > "I come from a flight-simulation background where we use the = convention that Z-is-up - so all my > software works like that. However, the PLIB loaders know that some modellers use Y-is-up and do > the axis swap as needed. Hence, in AC3D, Y-is-up - but in the game, = your models will be converted > to Z-is-up. If you find this confusing, forget I mentioned it - = everything comes out OK automagically." >=20 > So I would beleive the Z axis is the Y axis are swapped in plib, so = just swapping these values when you > load models and in your coordinate handling code would do the trick. >=20 > -Coz To be more precise, the matrix used for such SSG to OpenGL coordinate adaption can be found in ssg.cxx: sgMat4 _ssgOpenGLAxisSwapMatrix =3D { { 1.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, -1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 1.0f } } ; This actually describes a 90=B0 rotation around the x-axis, in such a = way that SSG is "z+ is up, y+ points towards the observer", OpenGL is "y+ is up, = z+ points inside the screen" (I think it's the same handness). Greetings - Paolo Leoncini |