[Plib-users] R: R: R: Matrices and sgCoord
Brought to you by:
sjbaker
From: Paolo L. <p.l...@ci...> - 2007-07-25 11:51:43
|
Dimistris,=20 > -----Messaggio originale----- > Da: pli...@li...=20 > [mailto:pli...@li...] Per conto=20 > di Dimitris Mexis > Inviato: mercoled=EC 25 luglio 2007 12.39 > A: PLIB Users > Oggetto: Re: [Plib-users] R: R: Matrices and sgCoord >=20 > No there was not in your code but in plib I have found these=20 > functions and I don't understand them : > void orthoXform ( sgMat4 m ) in Sphere code, and in sg.h > void sgXformVec3 ( sgVec3 dst, sgMat4 mat ) ; > void sgXformVec3 ( sgVec3 dst, sgVec3 src, sgMat4 mat ) ; >=20 > void sgXformPnt3 ( sgVec3 dst, sgMat4 mat ) ; > void sgXformPnt3 ( sgVec3 dst, sgVec3 src, sgMat4 mat ) ; >=20 > void sgFullXformPnt3 ( sgVec3 dst, sgMat4 mat ) ; void=20 > sgFullXformPnt3 ( sgVec3 dst, sgVec3 src, sgMat4 mat ) ; >=20 > void sgXformVec4 ( sgVec4 dst, sgMat4 mat ) ; > void sgXformVec4 ( sgVec4 dst, sgVec4 src, sgMat4 mat ) ; >=20 > void sgXformPnt4 ( sgVec4 dst, sgMat4 mat ) ; > void sgXformPnt4 ( sgVec4 dst, sgVec4 src, sgMat4 mat ) ; >=20 > void sgFullXformPnt4 ( sgVec4 dst, sgMat4 mat ) ; void=20 > sgFullXformPnt4 ( sgVec4 dst, sgVec4 src, sgMat4 mat ) ; >=20 > ????? Ok, these are all functions, not class methods. Just try to read = 'transform' in place of 'xform', and you'll get a plenty of ways to transform a = point or a vector, 3- or 4-dims, by a transformation matrix. For example, sgXformVec3 will multiply a sgVec3 by the 3x3 rotation = section of a sgMat4, whilst sgXformPnt3 does what sgXformVec3 does + adds the matrix's translation row to the resuling vector (i.e. treats it as an = actual 'point'). The 'Full' versions transform vecs and pnts 'homogeneously'. Paolo > ----- Original Message ---- > From: Paolo Leoncini <p.l...@ci...> > To: PLIB Users <pli...@li...> > Sent: Wednesday, July 25, 2007 1:30:17 PM > Subject: [Plib-users] R: R: Matrices and sgCoord >=20 > Dimitris,=20 >=20 > > -----Messaggio originale----- > > Da: pli...@li... > > [mailto:pli...@li...] Per conto di=20 > > 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=20 > > 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=20 > > sgxform*? > > They are not matrices right? ( plib has sgMat for them...no?) >=20 > 'xform' is a way 3D graphics programmers use to refer to=20 > 2D/3D transformations in variable names ('x' stands for=20 > 'trans'). There should be also a class method in SG (IIRC=20 > XformVec3 and XformPnt) with this prefix. > Using it makes me feeling a very english/american 3D programmer. >=20 > There's no sgxform in the code I wrote, unless an error were=20 > introduced when the e-mail systems formatted my message. >=20 > > Thank you >=20 > Greetings, >=20 > Paolo >=20 >=20 > > ----- 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 > > object move > > > 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()); > > sgMultMat4( SHIPDST, > > > SHIPSRC, RotateMatrix); setStigma( SHIPDST); > > >=20 > > > What I don;t understand is that I took the usual matrix=20 > and instead=20 > > > tweaking the last column element by the second row, I > > inversed it and > > > 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=20 > > is y+ -up, z+ -going outside the screen, whilst SSG is z+ -up, y+=20 > > -going into the screen. > >=20 > > Second, SG's sgMat4 is a 4x4 homogeneous matrix for specifying=20 > > projection, viewing, modelling and/or object position. For old,=20 > > nostalgic programmers, it's a-la-IrisGL. > > The fourth row is the translation. > >=20 > > Then, when your ship moves on the sea plane, it actually=20 > moves on the=20 > > x-y plane (z=3D0), and hence elements of a sgMat4 ship_xform=20 > to change=20 > > are ship_xform [3][0], ship_xform[3][1] (ship_xform[3] can=20 > be pointed=20 > > 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=20 > > 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.=20 > > If you need to move it I assume your ship is a > >=20 > > ssgTransform *ship; > >=20 > > So you'll probably call > >=20 > > ship->setTransform( /* sgCoord* */ stigma ); // one of=20 > 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=20 > > 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 a=20 > > browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/=20 > > _______________________________________________ > > 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 > > 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 a=20 > > browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/=20 > > _______________________________________________ > > plib-users mailing list > > pli...@li... > > https://lists.sourceforge.net/lists/listinfo/plib-users > >=20 >=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 >> http://get.splunk.com/ > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users >=20 >=20 >=20 >=20 >=20 > =20 > ______________________________________________________________ > ______________________ > Fussy? Opinionated? Impossible to please? Perfect. Join=20 > Yahoo!'s user panel and lay it on us.=20 > http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=3D7=20 >=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 >> http://get.splunk.com/ > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users >=20 |