[Plib-users] R: R: Matrices and sgCoord
Brought to you by:
sjbaker
|
From: Paolo L. <p.l...@ci...> - 2007-07-25 10:30:36
|
Dimitris,=20
> -----Messaggio originale-----
> Da: pli...@li...=20
> [mailto:pli...@li...] Per conto=20
> di Dimitris Mexis
> Inviato: mercoled=EC 25 luglio 2007 11.47
> A: PLIB Users
> Oggetto: Re: [Plib-users] R: Matrices and sgCoord
>=20
> Thank you Paolo, for the clarification, so it is right to=20
> handle the last row, and it wasn't accident.
> I liked your second option of working with the coords.
> By the way...What is an xform? What do the function do in=20
> plib about sgxform*?
> They are not matrices right? ( plib has sgMat for them...no?)
'xform' is a way 3D graphics programmers use to refer to 2D/3D
transformations in variable names ('x' stands for 'trans'). There should =
be
also a class method in SG (IIRC XformVec3 and XformPnt) with this =
prefix.
Using it makes me feeling a very english/american 3D programmer.
There's no sgxform in the code I wrote, unless an error were introduced =
when
the e-mail systems formatted my message.
> Thank you
Greetings,
Paolo
> ----- Original Message ----
> From: Paolo Leoncini <p.l...@ci...>
> To: PLIB Users <pli...@li...>
> Sent: Wednesday, July 25, 2007 12:33:55 PM
> Subject: [Plib-users] R: Matrices and sgCoord
>=20
> Dimitris,
>=20
> > -----Messaggio originale-----
> > Da: pli...@li...
> > [mailto:pli...@li...] Per conto di=20
> > Dimitris Mexis
> > Inviato: marted=EC 24 luglio 2007 16.26
> > A: pli...@li...
> > Oggetto: [Plib-users] Matrices and sgCoord
> >=20
> > The following code has been a success in order to make the=20
> object move=20
> > at a constant speed.
> >=20
> > sgCoord stigma;
> >=20
> > void GLObject::setStigma( sgMat4 & objDst){
> > sgSetCoord( & stigma, objDst);
> > }
> >=20
> > GLObject::move(){
> > //The rotation matrix for moving around trireme.
> > sgMat4 RotateMatrix =3D {
> > 1, 0, 0, 0,
> > 0, 1, 0, 0,
> > 0, 0, 1, 0,
> > 0,( getSpeed()), 0, 1
> > };
> > =20
> > sgMakeCoordMat4( SHIPSRC, &trireme->getStigma());=20
> sgMultMat4( SHIPDST,=20
> > SHIPSRC, RotateMatrix); setStigma( SHIPDST);
> >=20
> > What I don;t understand is that I took the usual matrix and instead=20
> > tweaking the last column element by the second row, I=20
> inversed it and=20
> > put the getSpeed() which is <>0 in the bottom row! Why? this?
>=20
> I hope to have understood correctly your perplexity.
>=20
> First, SSG has a different coord reference system wrt OpenGL.=20
> Both have the same handness, so x+ is along right in both,=20
> yet OpenGL is y+ -up, z+ -going outside the screen, whilst=20
> SSG is z+ -up, y+ -going into the screen.
>=20
> Second, SG's sgMat4 is a 4x4 homogeneous matrix for=20
> specifying projection, viewing, modelling and/or object=20
> position. For old, nostalgic programmers, it's a-la-IrisGL.=20
> The fourth row is the translation.
>=20
> Then, when your ship moves on the sea plane, it actually=20
> moves on the x-y plane (z=3D0), and hence elements of a sgMat4=20
> ship_xform to change are ship_xform [3][0], ship_xform[3][1]=20
> (ship_xform[3] can be pointed to by a
> sgVec3 to set a transformation vector xyz).
>=20
> That's the reason why you put getSpeed() for setting=20
> RotateMatrix[3][1]. In a un-rotated viewing, you should see=20
> the ship entering/exiting into/out the screen.
>=20
> > I made then the matrix multiplications, and took the result to=20
> > sgCoord.
> > Is this right approach? Ok it works, but it worths?
>=20
> You don't specify what you do with sgCoord stigma after the=20
> last set. If you need to move it I assume your ship is a=20
>=20
> ssgTransform *ship;
>=20
> So you'll probably call
>=20
> ship->setTransform( /* sgCoord* */ stigma ); // one of the several=20
> ship->forms
> to set a xform
>=20
>=20
> Alternatively I could have done this way:
>=20
> void move_ship( ssgTransform *ship )
> {
> sgMat4 ship_xform;
> ship->getTransform( ship_xform );
> sgVec3 ship_pos =3D { 0, getSpeed(), 0 }; // don't know if=20
> getSpeed is directly callable, or an object method
> sgAddVec3( ship_xform[3], ship_pos ); // just increment=20
> the position
> coords, resembles sgMultMat4 for the translation part only
> ship->setTransform( ship_xform ); // set the updated=20
> matrix back to
> the object
> }
>=20
> Greetings,
>=20
> Paolo Leoncini
>=20
>=20
> --------------------------------------------------------------
> -----------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and=20
> a browser.
> Download your FREE copy of Splunk now >> =20
> http://get.splunk.com/ _______________________________________________
> plib-users mailing list
> pli...@li...
> https://lists.sourceforge.net/lists/listinfo/plib-users
>=20
>=20
>=20
>=20
>=20
> =20
> ______________________________________________________________
> ______________________
> Take the Internet to Go: Yahoo!Go puts the Internet in your=20
> pocket: mail, news, photos & more.=20
> http://mobile.yahoo.com/go?refer=3D1GNXIC
>=20
> --------------------------------------------------------------
> -----------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and=20
> a browser.
> Download your FREE copy of Splunk now >> =20
> http://get.splunk.com/ _______________________________________________
> plib-users mailing list
> pli...@li...
> https://lists.sourceforge.net/lists/listinfo/plib-users
>=20
|