Re: [Plib-users] R: R: R: Matrices and sgCoord
Brought to you by:
sjbaker
From: Dimitris M. <dm...@ya...> - 2007-07-25 12:07:35
|
What seems to me Paolo, Joe and Tinoshy, I have to work a bit, and I am wor= king on my next questions :-)=0A=0AThank you for your time, people...=0ADim= itris=0A=0A----- Original Message ----=0AFrom: Paolo Leoncini <p.leoncini@c= ira.it>=0ATo: PLIB Users <pli...@li...>=0ASent: Wednesd= ay, July 25, 2007 2:51:22 PM=0ASubject: [Plib-users] R: R: R: Matrices a= nd sgCoord=0A=0ADimistris, =0A=0A> -----Messaggio originale-----=0A> Da: pl= ib-...@li... =0A> [mailto:plib-users-bounces@list= s.sourceforge.net] Per conto =0A> di Dimitris Mexis=0A> Inviato: mercoled= =EC 25 luglio 2007 12.39=0A> A: PLIB Users=0A> Oggetto: Re: [Plib-users] R:= R: Matrices and sgCoord=0A> =0A> No there was not in your code but in plib= I have found these =0A> functions and I don't understand them :=0A> void o= rthoXform ( sgMat4 m ) in Sphere code, and in sg.h=0A> void sgXformVec3 = ( sgVec3 dst, sgMat4 mat ) ;=0A> void sgXformVec3 ( sgVec3 dst, sgVe= c3 src, sgMat4 mat ) ;=0A> =0A> void sgXformPnt3 ( sgVec3 dst, sgMat4 = mat ) ;=0A> void sgXformPnt3 ( sgVec3 dst, sgVec3 src, sgMat4 mat ) ;= =0A> =0A> void sgFullXformPnt3 ( sgVec3 dst, sgMat4 mat ) ; void =0A> sgF= ullXformPnt3 ( sgVec3 dst, sgVec3 src, sgMat4 mat ) ;=0A> =0A> void sgXfor= mVec4 ( sgVec4 dst, sgMat4 mat ) ;=0A> void sgXformVec4 ( sgVec4 d= st, sgVec4 src, sgMat4 mat ) ;=0A> =0A> void sgXformPnt4 ( sgVec4 dst,= sgMat4 mat ) ;=0A> void sgXformPnt4 ( sgVec4 dst, sgVec4 src, sgMat4 = mat ) ;=0A> =0A> void sgFullXformPnt4 ( sgVec4 dst, sgMat4 mat ) ; void = =0A> sgFullXformPnt4 ( sgVec4 dst, sgVec4 src, sgMat4 mat ) ;=0A> =0A> ????= ?=0A=0AOk, these are all functions, not class methods. Just try to read 'tr= ansform'=0Ain place of 'xform', and you'll get a plenty of ways to transfor= m a point or=0Aa vector, 3- or 4-dims, by a transformation matrix.=0A=0AFor= example, sgXformVec3 will multiply a sgVec3 by the 3x3 rotation section=0A= of a sgMat4, whilst sgXformPnt3 does what sgXformVec3 does + adds the=0Amat= rix's translation row to the resuling vector (i.e. treats it as an actual= =0A'point').=0A=0AThe 'Full' versions transform vecs and pnts 'homogeneousl= y'.=0A=0APaolo=0A=0A=0A> ----- Original Message ----=0A> From: Paolo Leonci= ni <p.l...@ci...>=0A> To: PLIB Users <pli...@li...= t>=0A> Sent: Wednesday, July 25, 2007 1:30:17 PM=0A> Subject: [Plib-users] = R: R: Matrices and sgCoord=0A> =0A> Dimitris, =0A> =0A> > -----Messaggio = originale-----=0A> > Da: pli...@li...=0A> > [ma= ilto:pli...@li...] Per conto di =0A> > Dimitris= Mexis=0A> > Inviato: mercoled=EC 25 luglio 2007 11.47=0A> > A: PLIB Users= =0A> > Oggetto: Re: [Plib-users] R: Matrices and sgCoord=0A> > =0A> > Thank= you Paolo, for the clarification, so it is right to =0A> handle the =0A> >= last row, and it wasn't accident.=0A> > I liked your second option of work= ing with the coords.=0A> > By the way...What is an xform? What do the funct= ion do in =0A> plib about =0A> > sgxform*?=0A> > They are not matrices righ= t? ( plib has sgMat for them...no?)=0A> =0A> 'xform' is a way 3D graphics p= rogrammers use to refer to =0A> 2D/3D transformations in variable names ('x= ' stands for =0A> 'trans'). There should be also a class method in SG (IIRC= =0A> XformVec3 and XformPnt) with this prefix.=0A> Using it makes me feeli= ng a very english/american 3D programmer.=0A> =0A> There's no sgxform in th= e code I wrote, unless an error were =0A> introduced when the e-mail system= s formatted my message.=0A> =0A> > Thank you=0A> =0A> Greetings,=0A> =0A> P= aolo=0A> =0A> =0A> > ----- Original Message ----=0A> > From: Paolo Leoncini= <p.l...@ci...>=0A> > To: PLIB Users <pli...@li...= t>=0A> > Sent: Wednesday, July 25, 2007 12:33:55 PM=0A> > Subject: [Plib-us= ers] R: Matrices and sgCoord=0A> > =0A> > Dimitris,=0A> > =0A> > > -----Me= ssaggio originale-----=0A> > > Da: pli...@li...= =0A> > > [mailto:pli...@li...] Per conto di =0A= > > > Dimitris Mexis=0A> > > Inviato: marted=EC 24 luglio 2007 16.26=0A> > = > A: pli...@li...=0A> > > Oggetto: [Plib-users] Matrice= s and sgCoord=0A> > > =0A> > > The following code has been a success in ord= er to make the=0A> > object move=0A> > > at a constant speed.=0A> > > =0A> = > > sgCoord stigma;=0A> > > =0A> > > void GLObject::setStigma( sgMat4 & obj= Dst){=0A> > > sgSetCoord( & stigma, objDst);=0A> > > }=0A> > > =0A> > >= GLObject::move(){=0A> > > //The rotation matrix for moving around trir= eme.=0A> > > sgMat4 RotateMatrix =3D {=0A> > > 1, 0, 0, 0,=0A= > > > 0, 1, 0, 0,=0A> > > 0, 0, 1, 0,=0A> > > 0,( g= etSpeed()), 0, 1=0A> > > };=0A> > > =0A> > > sgMakeCoordMat4( SHIPS= RC, &trireme->getStigma());=0A> > sgMultMat4( SHIPDST,=0A> > > SHIPSRC, Rot= ateMatrix); setStigma( SHIPDST);=0A> > > =0A> > > What I don;t understand i= s that I took the usual matrix =0A> and instead =0A> > > tweaking the last = column element by the second row, I=0A> > inversed it and=0A> > > put the g= etSpeed() which is <>0 in the bottom row! Why? this?=0A> > =0A> > I hope to= have understood correctly your perplexity.=0A> > =0A> > First, SSG has a d= ifferent coord reference system wrt OpenGL. =0A> > Both have the same handn= ess, so x+ is along right in both, =0A> yet OpenGL =0A> > is y+ -up, z+ -go= ing outside the screen, whilst SSG is z+ -up, y+ =0A> > -going into the scr= een.=0A> > =0A> > Second, SG's sgMat4 is a 4x4 homogeneous matrix for speci= fying =0A> > projection, viewing, modelling and/or object position. For old= , =0A> > nostalgic programmers, it's a-la-IrisGL.=0A> > The fourth row is t= he translation.=0A> > =0A> > Then, when your ship moves on the sea plane, i= t actually =0A> moves on the =0A> > x-y plane (z=3D0), and hence elements o= f a sgMat4 ship_xform =0A> to change =0A> > are ship_xform [3][0], ship_xfo= rm[3][1] (ship_xform[3] can =0A> be pointed =0A> > to by a=0A> > sgVec3 to = set a transformation vector xyz).=0A> > =0A> > That's the reason why you pu= t getSpeed() for setting =0A> > RotateMatrix[3][1]. In a un-rotated viewing= , you should see =0A> the ship =0A> > entering/exiting into/out the screen.= =0A> > =0A> > > I made then the matrix multiplications, and took the result= to =0A> > > sgCoord.=0A> > > Is this right approach? Ok it works, but it w= orths?=0A> > =0A> > You don't specify what you do with sgCoord stigma after= the =0A> last set. =0A> > If you need to move it I assume your ship is a= =0A> > =0A> > ssgTransform *ship;=0A> > =0A> > So you'll probably call=0A> = > =0A> > ship->setTransform( /* sgCoord* */ stigma ); // one of =0A> the = several =0A> > ship->forms=0A> > to set a xform=0A> > =0A> > =0A> > Alterna= tively I could have done this way:=0A> > =0A> > void move_ship( ssgTransfor= m *ship )=0A> > {=0A> > sgMat4 ship_xform;=0A> > ship->getTransform( sh= ip_xform );=0A> > sgVec3 ship_pos =3D { 0, getSpeed(), 0 }; // don't kno= w if =0A> getSpeed =0A> > is directly callable, or an object method=0A> > = sgAddVec3( ship_xform[3], ship_pos ); // just increment =0A> > the posi= tion=0A> > coords, resembles sgMultMat4 for the translation part only=0A> >= ship->setTransform( ship_xform ); // set the updated =0A> > matri= x back to=0A> > the object=0A> > }=0A> > =0A> > Greetings,=0A> > =0A> > Pao= lo Leoncini=0A> > =0A> > =0A> > -------------------------------------------= -------------------=0A> > -----------=0A> > This SF.net email is sponsored = by: Splunk Inc.=0A> > Still grepping through log files to find problems? S= top.=0A> > Now Search log events and configuration files using AJAX and a = =0A> > browser.=0A> > Download your FREE copy of Splunk now >> http://get.s= plunk.com/ =0A> > _______________________________________________=0A> > pli= b-users mailing list=0A> > pli...@li...=0A> > https://l= ists.sourceforge.net/lists/listinfo/plib-users=0A> > =0A> > =0A> > =0A> > = =0A> > =0A> > =0A> > _______________________________________________= _______________=0A> > ______________________=0A> > Take the Internet to Go:= Yahoo!Go puts the Internet in your=0A> > pocket: mail, news, photos & more= . =0A> > http://mobile.yahoo.com/go?refer=3D1GNXIC=0A> > =0A> > -----------= ---------------------------------------------------=0A> > -----------=0A> >= This SF.net email is sponsored by: Splunk Inc.=0A> > Still grepping throug= h log files to find problems? Stop.=0A> > Now Search log events and config= uration files using AJAX and a =0A> > browser.=0A> > Download your FREE cop= y of Splunk now >> http://get.splunk.com/ =0A> > __________________________= _____________________=0A> > plib-users mailing list=0A> > plib-users@lists.= sourceforge.net=0A> > https://lists.sourceforge.net/lists/listinfo/plib-use= rs=0A> > =0A> =0A> =0A> ---------------------------------------------------= -----------=0A> -----------=0A> This SF.net email is sponsored by: Splunk I= nc.=0A> Still grepping through log files to find problems? Stop.=0A> Now S= earch log events and configuration files using AJAX and =0A> a browser.=0A>= Download your FREE copy of Splunk now >> http://get.splunk.com/=0A> _____= __________________________________________=0A> plib-users mailing list=0A> = pli...@li...=0A> https://lists.sourceforge.net/lists/li= stinfo/plib-users=0A> =0A> =0A> =0A> =0A> =0A> =0A> _________________= _____________________________________________=0A> ______________________=0A= > Fussy? Opinionated? Impossible to please? Perfect. Join =0A> Yahoo!'s us= er panel and lay it on us. =0A> http://surveylink.yahoo.com/gmrs/yahoo_pane= l_invite.asp?a=3D7 =0A> =0A> =0A> -----------------------------------------= ---------------------=0A> -----------=0A> This SF.net email is sponsored by= : Splunk Inc.=0A> Still grepping through log files to find problems? Stop.= =0A> Now Search log events and configuration files using AJAX and =0A> a br= owser.=0A> Download your FREE copy of Splunk now >> http://get.splunk.com/= =0A> _______________________________________________=0A> plib-users mailing= list=0A> pli...@li...=0A> https://lists.sourceforge.ne= t/lists/listinfo/plib-users=0A> =0A=0A=0A----------------------------------= ---------------------------------------=0AThis SF.net email is sponsored by= : Splunk Inc.=0AStill grepping through log files to find problems? Stop.= =0ANow Search log events and configuration files using AJAX and a browser.= =0ADownload your FREE copy of Splunk now >> http://get.splunk.com/=0A_____= __________________________________________=0Aplib-users mailing list=0Aplib= -u...@li...=0Ahttps://lists.sourceforge.net/lists/listinfo= /plib-users=0A=0A=0A=0A=0A=0A ________________________________________= ____________________________________________=0APark yourself in front of a = world of choices in alternative vehicles. Visit the Yahoo! Auto Green Cente= r.=0Ahttp://autos.yahoo.com/green_center/ |