Re: [Plib-users] R: R: R: Matrices and sgCoord
Brought to you by:
sjbaker
From: Dimitris M. <dm...@ya...> - 2007-07-26 15:03:38
|
Paolo,=0AThe code worked almost without any problem...=0AI do wish only if = you could provide more information what these functions do...=0Anot the gen= eral idea, but how the mechanism works...=0ACan you give details?=0A=0AEspe= cially, this Vtx and Leaf thing is something that I don't catch up...=0A=0A= Also!=0AIs this code part of PLIB ? or Should I mention you OR SOMEBODY ELS= E in the code ? or somewhere else?=0A=0AThank you!=0A=0A----- Original Mess= age ----=0AFrom: Paolo Leoncini <p.l...@ci...>=0ATo: PLIB Users <plib= -u...@li...>=0ASent: Wednesday, July 25, 2007 2:51:22 PM= =0ASubject: [Plib-users] R: R: R: Matrices and sgCoord=0A=0ADimistris, = =0A=0A> -----Messaggio originale-----=0A> Da: pli...@li...ur= ceforge.net =0A> [mailto:pli...@li...] Per cont= o =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> func= tions and I don't understand them :=0A> void orthoXform ( sgMat4 m ) in Sph= ere code, and in sg.h=0A> void sgXformVec3 ( sgVec3 dst, sgMat4 mat ) = ;=0A> void sgXformVec3 ( sgVec3 dst, sgVec3 src, sgMat4 mat ) ;=0A> = =0A> void sgXformPnt3 ( sgVec3 dst, sgMat4 mat ) ;=0A> void sgXformPn= t3 ( sgVec3 dst, sgVec3 src, sgMat4 mat ) ;=0A> =0A> void sgFullXformP= nt3 ( sgVec3 dst, sgMat4 mat ) ; void =0A> sgFullXformPnt3 ( sgVec3 dst, s= gVec3 src, sgMat4 mat ) ;=0A> =0A> void sgXformVec4 ( sgVec4 dst, sgMa= t4 mat ) ;=0A> void sgXformVec4 ( sgVec4 dst, sgVec4 src, sgMat4 mat )= ;=0A> =0A> void sgXformPnt4 ( sgVec4 dst, sgMat4 mat ) ;=0A> void sg= XformPnt4 ( sgVec4 dst, sgVec4 src, sgMat4 mat ) ;=0A> =0A> void sgFul= lXformPnt4 ( sgVec4 dst, sgMat4 mat ) ; void =0A> sgFullXformPnt4 ( sgVec4= dst, sgVec4 src, sgMat4 mat ) ;=0A> =0A> ?????=0A=0AOk, these are all func= tions, not class methods. Just try to read 'transform'=0Ain place of 'xform= ', and you'll get a plenty of ways to transform a point or=0Aa vector, 3- o= r 4-dims, by a transformation matrix.=0A=0AFor example, sgXformVec3 will mu= ltiply a sgVec3 by the 3x3 rotation section=0Aof a sgMat4, whilst sgXformPn= t3 does what sgXformVec3 does + adds the=0Amatrix's translation row to the = resuling vector (i.e. treats it as an actual=0A'point').=0A=0AThe 'Full' ve= rsions transform vecs and pnts 'homogeneously'.=0A=0APaolo=0A=0A=0A> ----- = Original Message ----=0A> From: Paolo Leoncini <p.l...@ci...>=0A> To:= PLIB Users <pli...@li...>=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: plib-u= ser...@li...=0A> > [mailto:plib-users-bounces@lists.s= ourceforge.net] 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 clarificati= on, so it is right to =0A> handle the =0A> > last row, and it wasn't accide= nt.=0A> > I liked your second option of working with the coords.=0A> > By t= he way...What is an xform? What do the function do in =0A> plib about =0A> = > sgxform*?=0A> > They are not matrices right? ( plib has sgMat for them...= no?)=0A> =0A> 'xform' is a way 3D graphics programmers use to refer to =0A>= 2D/3D transformations in variable names ('x' stands for =0A> 'trans'). The= re should be also a class method in SG (IIRC =0A> XformVec3 and XformPnt) w= ith this prefix.=0A> Using it makes me feeling a very english/american 3D p= rogrammer.=0A> =0A> There's no sgxform in the code I wrote, unless an error= were =0A> introduced when the e-mail systems formatted my message.=0A> =0A= > > Thank you=0A> =0A> Greetings,=0A> =0A> Paolo=0A> =0A> =0A> > ----- Orig= inal Message ----=0A> > From: Paolo Leoncini <p.l...@ci...>=0A> > To:= PLIB Users <pli...@li...>=0A> > Sent: Wednesday, July = 25, 2007 12:33:55 PM=0A> > Subject: [Plib-users] R: Matrices and sgCoord= =0A> > =0A> > Dimitris,=0A> > =0A> > > -----Messaggio originale-----=0A> > = > Da: pli...@li...=0A> > > [mailto:plib-users-b= ou...@li...] Per conto di =0A> > > Dimitris Mexis=0A> > > = Inviato: marted=EC 24 luglio 2007 16.26=0A> > > A: pli...@li...urcef= orge.net=0A> > > Oggetto: [Plib-users] Matrices and sgCoord=0A> > > =0A> > = > The following code has been a success in order to make the=0A> > object m= ove=0A> > > 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 Rota= teMatrix =3D {=0A> > > 1, 0, 0, 0,=0A> > > 0, 1, 0, 0,=0A= > > > 0, 0, 1, 0,=0A> > > 0,( getSpeed()), 0, 1=0A> > > = };=0A> > > =0A> > > sgMakeCoordMat4( SHIPSRC, &trireme->getStigma());= =0A> > sgMultMat4( SHIPDST,=0A> > > SHIPSRC, RotateMatrix); setStigma( SHIP= DST);=0A> > > =0A> > > What I don;t understand is that I took the usual mat= rix =0A> and instead =0A> > > tweaking the last column element by the secon= d row, I=0A> > inversed it and=0A> > > put the getSpeed() which is <>0 in t= he bottom row! Why? this?=0A> > =0A> > I hope to have understood correctly = your perplexity.=0A> > =0A> > First, SSG has a different coord reference sy= stem wrt OpenGL. =0A> > Both have the same handness, so x+ is along right i= n both, =0A> yet OpenGL =0A> > is y+ -up, z+ -going outside the screen, whi= lst SSG is z+ -up, y+ =0A> > -going into the screen.=0A> > =0A> > Second, S= G's sgMat4 is a 4x4 homogeneous matrix for specifying =0A> > projection, vi= ewing, modelling and/or object position. For old, =0A> > nostalgic programm= ers, it's a-la-IrisGL.=0A> > The fourth row is the translation.=0A> > =0A> = > Then, when your ship moves on the sea plane, it actually =0A> moves on th= e =0A> > x-y plane (z=3D0), and hence elements of a sgMat4 ship_xform =0A> = to change =0A> > are ship_xform [3][0], ship_xform[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 put 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 th= en the matrix multiplications, and took the result to =0A> > > sgCoord.=0A>= > > Is this right approach? Ok it works, but it worths?=0A> > =0A> > You d= on'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> > Alternatively I could have done t= his way:=0A> > =0A> > void 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 =0A> getSpeed =0A> > = is directly callable, or an object method=0A> > sgAddVec3( ship_xform[3],= ship_pos ); // just increment =0A> > the position=0A> > coords, resembl= es sgMultMat4 for the translation part only=0A> > ship->setTransform( shi= p_xform ); // set the updated =0A> > matrix back to=0A> > the object= =0A> > }=0A> > =0A> > Greetings,=0A> > =0A> > Paolo Leoncini=0A> > =0A> > = =0A> > --------------------------------------------------------------=0A> >= -----------=0A> > This SF.net email is sponsored by: Splunk Inc.=0A> > Sti= ll grepping through log files to find problems? Stop.=0A> > Now Search log= events and configuration files using AJAX and a =0A> > browser.=0A> > Down= load 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= /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.yaho= o.com/go?refer=3D1GNXIC=0A> > =0A> > --------------------------------------= ------------------------=0A> > -----------=0A> > This SF.net email is spons= ored by: Splunk Inc.=0A> > Still grepping through log files to find problem= s? Stop.=0A> > Now Search log events and configuration files using AJAX an= d a =0A> > browser.=0A> > Download your FREE copy of Splunk now >> http://g= et.splunk.com/ =0A> > _______________________________________________=0A> >= plib-users mailing list=0A> > pli...@li...=0A> > https= ://lists.sourceforge.net/lists/listinfo/plib-users=0A> > =0A> =0A> =0A> ---= -----------------------------------------------------------=0A> -----------= =0A> This SF.net email is sponsored by: Splunk Inc.=0A> Still grepping thro= ugh log files to find problems? Stop.=0A> Now Search log events and config= uration 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...urceforg= e.net=0A> https://lists.sourceforge.net/lists/listinfo/plib-users=0A> =0A> = =0A> =0A> =0A> =0A> =0A> ____________________________________________= __________________=0A> ______________________=0A> Fussy? Opinionated? Impos= sible to please? Perfect. Join =0A> Yahoo!'s user panel and lay it on us. = =0A> http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=3D7 =0A> =0A= > =0A> --------------------------------------------------------------=0A> -= ----------=0A> This SF.net email is sponsored by: Splunk Inc.=0A> Still gre= pping through log files to find problems? Stop.=0A> Now Search log events = and configuration files using AJAX and =0A> a browser.=0A> Download your FR= EE copy 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-users= =0A> =0A=0A=0A-------------------------------------------------------------= ------------=0AThis SF.net email is sponsored by: Splunk Inc.=0AStill grepp= ing 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=0Ap...@li...= =0Ahttps://lists.sourceforge.net/lists/listinfo/plib-users=0A=0A=0A=0A=0A= =0A =0A______________________________________________________________= ______________________=0ABe a better Globetrotter. Get better travel answer= s from someone who knows. Yahoo! Answers - Check it out.=0Ahttp://answers.y= ahoo.com/dir/?link=3Dlist&sid=3D396545469 |