Re: [Plib-users] R: Matrices and sgCoord
Brought to you by:
sjbaker
From: Dimitris M. <dm...@ya...> - 2007-07-25 09:47:05
|
Thank you Paolo, for the clarification, so it is right to handle the last r= ow, and it wasn't accident.=0AI liked your second option of working with th= e coords.=0ABy the way...What is an xform? What do the function do in plib = about sgxform*?=0AThey are not matrices right? ( plib has sgMat for them...= no?)=0A=0AThank you=0A=0A----- Original Message ----=0AFrom: Paolo Leoncini= <p.l...@ci...>=0ATo: PLIB Users <pli...@li...>= =0ASent: Wednesday, July 25, 2007 12:33:55 PM=0ASubject: [Plib-users] R: M= atrices and sgCoord=0A=0ADimitris,=0A=0A> -----Messaggio originale-----=0A>= Da: pli...@li... =0A> [mailto:plib-users-bounc= es...@li...] Per conto =0A> di Dimitris Mexis=0A> Inviato: mar= ted=EC 24 luglio 2007 16.26=0A> A: pli...@li...=0A> Ogg= etto: [Plib-users] Matrices and sgCoord=0A> =0A> The following code has bee= n a success in order to make the =0A> object move at a constant speed.=0A> = =0A> sgCoord stigma;=0A> =0A> void GLObject::setStigma( sgMat4 & objDst){= =0A> sgSetCoord( & stigma, objDst);=0A> }=0A> =0A> GLObject::move(){=0A= > //The rotation matrix for moving around trireme.=0A> sgMat4 Rotat= eMatrix =3D {=0A> 1, 0, 0, 0,=0A> 0, 1, 0, 0,=0A> = 0, 0, 1, 0,=0A> 0,( getSpeed()), 0, 1=0A> };=0A> =0A> sgMa= keCoordMat4( SHIPSRC, &trireme->getStigma()); sgMultMat4( =0A> SHIPDST, SHI= PSRC, RotateMatrix); setStigma( SHIPDST);=0A> =0A> What I don;t understand = is that I took the usual matrix and =0A> instead tweaking the last column e= lement by the second row, I =0A> inversed it and put the getSpeed() which i= s <>0 in the bottom =0A> row! Why? this?=0A=0AI hope to have understood cor= rectly your perplexity.=0A=0AFirst, SSG has a different coord reference sys= tem wrt OpenGL. Both have the=0Asame handness, so x+ is along right in both= , yet OpenGL is y+ -up, z+ -going=0Aoutside the screen, whilst SSG is z+ -u= p, y+ -going into the screen.=0A=0ASecond, SG's sgMat4 is a 4x4 homogeneous= matrix for specifying projection,=0Aviewing, modelling and/or object posit= ion. For old, nostalgic programmers,=0Ait's a-la-IrisGL. The fourth row is = the translation.=0A=0AThen, when your ship moves on the sea plane, it actua= lly moves on the x-y=0Aplane (z=3D0), and hence elements of a sgMat4 ship_x= form to change are=0Aship_xform [3][0], ship_xform[3][1] (ship_xform[3] can= be pointed to by a=0AsgVec3 to set a transformation vector xyz).=0A=0AThat= 's the reason why you put getSpeed() for setting RotateMatrix[3][1]. In=0Aa= un-rotated viewing, you should see the ship entering/exiting into/out the= =0Ascreen.=0A=0A> I made then the matrix multiplications, and took the resu= lt =0A> to sgCoord.=0A> Is this right approach? Ok it works, but it worths?= =0A=0AYou don't specify what you do with sgCoord stigma after the last set.= If you=0Aneed to move it I assume your ship is a =0A=0AssgTransform *ship;= =0A=0ASo you'll probably call=0A=0Aship->setTransform( /* sgCoord* */ stigm= a ); // one of the several forms=0Ato set a xform=0A=0A=0AAlternatively I= could have done this way:=0A=0Avoid move_ship( ssgTransform *ship )=0A{=0A= sgMat4 ship_xform;=0A ship->getTransform( ship_xform );=0A sgVec3 ship_= pos =3D { 0, getSpeed(), 0 }; // don't know if getSpeed is=0Adirectly call= able, or an object method=0A sgAddVec3( ship_xform[3], ship_pos ); // j= ust increment the position=0Acoords, resembles sgMultMat4 for the translati= on part only=0A ship->setTransform( ship_xform ); // set the update= d matrix back to=0Athe object=0A}=0A=0AGreetings,=0A=0APaolo Leoncini=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 configurati= on files using AJAX and a browser.=0ADownload your FREE copy of Splunk now = >> http://get.splunk.com/=0A______________________________________________= _=0Aplib-users mailing list=0Ap...@li...=0Ahttps://li= sts.sourceforge.net/lists/listinfo/plib-users=0A=0A=0A=0A=0A=0A =0A__= ___________________________________________________________________________= _______=0ATake the Internet to Go: Yahoo!Go puts the Internet in your pocke= t: mail, news, photos & more. =0Ahttp://mobile.yahoo.com/go?refer=3D1GNXIC |