Re: [Plib-users] R: R: Matrices and sgCoord
Brought to you by:
sjbaker
From: Dimitris M. <dm...@ya...> - 2007-07-25 10:38:43
|
No there was not in your code but in plib I have found these functions and = I don't understand them :=0Avoid orthoXform ( sgMat4 m ) in Sphere code,=0A= and=0Ain sg.h=0A void sgXformVec3 ( sgVec3 dst, sgMat4 mat ) ;=0A void = sgXformVec3 ( sgVec3 dst, sgVec3 src, sgMat4 mat ) ;=0A=0A void sgXform= Pnt3 ( sgVec3 dst, sgMat4 mat ) ;=0A void sgXformPnt3 ( sgVec3 dst,= sgVec3 src, sgMat4 mat ) ;=0A=0A void sgFullXformPnt3 ( sgVec3 dst, sgMat4= mat ) ;=0A void sgFullXformPnt3 ( sgVec3 dst, sgVec3 src, sgMat4 mat ) ;= =0A=0A void sgXformVec4 ( sgVec4 dst, sgMat4 mat ) ;=0A void sgXformVec= 4 ( sgVec4 dst, sgVec4 src, sgMat4 mat ) ;=0A=0A void sgXformPnt4 (= sgVec4 dst, sgMat4 mat ) ;=0A void sgXformPnt4 ( sgVec4 dst, sgVec4 sr= c, sgMat4 mat ) ;=0A=0A void sgFullXformPnt4 ( sgVec4 dst, sgMat4 mat ) ;= =0A void sgFullXformPnt4 ( sgVec4 dst, sgVec4 src, sgMat4 mat ) ;=0A=0A????= ?=0A=0A----- Original Message ----=0AFrom: Paolo Leoncini <p.leoncini@cira.= it>=0ATo: PLIB Users <pli...@li...>=0ASent: Wednesday, = July 25, 2007 1:30:17 PM=0ASubject: [Plib-users] R: R: Matrices and sgCoo= rd=0A=0ADimitris, =0A=0A> -----Messaggio originale-----=0A> Da: plib-users-= bo...@li... =0A> [mailto:pli...@li...urcef= orge.net] Per conto =0A> di Dimitris Mexis=0A> Inviato: mercoled=EC 25 lugl= io 2007 11.47=0A> A: PLIB Users=0A> Oggetto: Re: [Plib-users] R: Matrices a= nd sgCoord=0A> =0A> Thank you Paolo, for the clarification, so it is right = to =0A> handle the last row, and it wasn't accident.=0A> I liked your secon= d option of working with the coords.=0A> By the way...What is an xform? Wha= t do the function do in =0A> plib about 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 2D/3D=0Atransformations in variable names ('x' = stands for 'trans'). There should be=0Aalso a class method in SG (IIRC Xfor= mVec3 and XformPnt) with this prefix.=0AUsing it makes me feeling a very en= glish/american 3D programmer.=0A=0AThere's no sgxform in the code I wrote, = unless an error were introduced when=0Athe e-mail systems formatted my mess= age.=0A=0A> Thank you=0A=0AGreetings,=0A=0APaolo=0A=0A=0A> ----- Original M= essage ----=0A> From: Paolo Leoncini <p.l...@ci...>=0A> To: PLIB User= s <pli...@li...>=0A> Sent: Wednesday, July 25, 2007 12:= 33:55 PM=0A> Subject: [Plib-users] R: Matrices and sgCoord=0A> =0A> Dimitr= is,=0A> =0A> > -----Messaggio originale-----=0A> > Da: plib-users-bounces@l= ists.sourceforge.net=0A> > [mailto:pli...@li...= ] Per conto di =0A> > Dimitris Mexis=0A> > Inviato: marted=EC 24 luglio 200= 7 16.26=0A> > A: pli...@li...=0A> > Oggetto: [Plib-user= s] Matrices and sgCoord=0A> > =0A> > The following code has been a success = in order to make the =0A> object move =0A> > at a constant speed.=0A> > =0A= > > sgCoord stigma;=0A> > =0A> > void GLObject::setStigma( sgMat4 & objDst)= {=0A> > sgSetCoord( & stigma, objDst);=0A> > }=0A> > =0A> > GLObject::m= ove(){=0A> > //The rotation matrix for moving around trireme.=0A> > = sgMat4 RotateMatrix =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( SHIPDST= );=0A> > =0A> > What I don;t understand is that I took the usual matrix and= instead =0A> > tweaking the last column element by the second row, I =0A> = inversed it and =0A> > put the getSpeed() which is <>0 in the bottom row! W= hy? this?=0A> =0A> I hope to have understood correctly your perplexity.=0A>= =0A> First, SSG has a different coord reference system wrt OpenGL. =0A> Bo= th have the same handness, so x+ is along right in both, =0A> yet OpenGL is= y+ -up, z+ -going outside the screen, whilst =0A> SSG is z+ -up, y+ -going= into the screen.=0A> =0A> Second, SG's sgMat4 is a 4x4 homogeneous matrix = for =0A> specifying projection, viewing, modelling and/or object =0A> posit= ion. For old, nostalgic programmers, it's a-la-IrisGL. =0A> The fourth row = is the translation.=0A> =0A> Then, when your ship moves on the sea plane, i= t actually =0A> moves on the x-y plane (z=3D0), and hence elements of a sgM= at4 =0A> ship_xform to change are ship_xform [3][0], ship_xform[3][1] =0A> = (ship_xform[3] can be pointed to by a=0A> sgVec3 to set a transformation ve= ctor 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 s= hip entering/exiting into/out the screen.=0A> =0A> > I made then the matrix= multiplications, and took the result to =0A> > sgCoord.=0A> > Is this righ= t approach? Ok it works, but it worths?=0A> =0A> You don't specify what you= do with sgCoord stigma after the =0A> last set. If you need to move it I a= ssume your ship is a =0A> =0A> ssgTransform *ship;=0A> =0A> So you'll proba= bly call=0A> =0A> ship->setTransform( /* sgCoord* */ stigma ); // one of = the several =0A> ship->forms=0A> to set a xform=0A> =0A> =0A> Alternatively= I could have done this 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> getSpee= d is directly callable, or an object method=0A> sgAddVec3( ship_xform[3],= ship_pos ); // just increment =0A> the position=0A> coords, resembles s= gMultMat4 for the translation part only=0A> ship->setTransform( ship_xfor= m ); // 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> Still grepping through log files to = find problems? Stop.=0A> Now Search log events and configuration files usi= ng AJAX and =0A> a browser.=0A> Download your FREE copy of Splunk now >> = =0A> http://get.splunk.com/ _______________________________________________= =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://mo= bile.yahoo.com/go?refer=3D1GNXIC=0A> =0A> ---------------------------------= -----------------------------=0A> -----------=0A> This SF.net email is spon= sored 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 browser.=0A> Download your FREE copy of Splunk now >> =0A> http://g= et.splunk.com/ _______________________________________________=0A> plib-use= rs mailing list=0A> pli...@li...=0A> https://lists.sour= ceforge.net/lists/listinfo/plib-users=0A> =0A=0A=0A------------------------= -------------------------------------------------=0AThis SF.net email is sp= onsored by: Splunk Inc.=0AStill grepping through log files to find problems= ? Stop.=0ANow Search log events and configuration files using AJAX and a b= rowser.=0ADownload your FREE copy of Splunk now >> http://get.splunk.com/= =0A_______________________________________________=0Aplib-users mailing lis= t=0Ap...@li...=0Ahttps://lists.sourceforge.net/lists/= listinfo/plib-users=0A=0A=0A=0A=0A=0A ________________________________= ____________________________________________________=0AFussy? Opinionated? = Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us. = http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=3D7 =0A |