[Plib-users] R: R: R: R: Matrices and sgCoord
Brought to you by:
sjbaker
From: Paolo L. <p.l...@ci...> - 2007-07-27 07:50:30
|
Dimitris,=20 > -----Messaggio originale----- > Da: pli...@li...=20 > [mailto:pli...@li...] Per conto=20 > di Dimitris Mexis > Inviato: gioved=EC 26 luglio 2007 17.04 > A: PLIB Users > Oggetto: Re: [Plib-users] R: R: R: Matrices and sgCoord >=20 > Paolo, > The code worked almost without any problem... > I do wish only if you could provide more information what=20 > these functions do... > not the general idea, but how the mechanism works... > Can you give details? Please be more specific. What functions, mechanism do you refer to? =20 > Especially, this Vtx and Leaf thing is something that I don't=20 > catch up... ssgLeaf is an abstract class for holding actual geometric data (i.e. triangles or other graphics primitives in terms of vertices, normals, triangle indices into the vertex array, colors), and a pointer to the "state" (i.e. the material in terms of OpenGL modes activated, texture, = and other attributes). Among derived classes the most modern and efficient = is the ssgVtxArray, which implements primitive drawing in terms of OpenGL Vertex Arrays, which is a fast way to transfer and draw geometry in = OpenGL especially when used in conjuction with display lists (VBO, Vertex = Buffer Objects, are even faster in immediate mode yet don't take advantage of = being put in the graphics memory in form of display list, and are not = presently implemented in Plib SSG). There are methods to put your geometry into a ssgLeaf/ssgVtxArray, as = well as to query whatever Leaf data. In a Leaf you can have control of the = pre- and the post-draw stages through user-definable callbacks, which, along = with a similar mechanism for states, allows to implement custom advanced rendering techniques or object highlighting (e.g. when you pick it). Multitexturing is not natively supported in SSG but one can write = compact pre/post-draw callbacks for doing it, just look at the Steve's 'water' = demo. There could be much more to say about all the key classes in SSG, but I think the best place to go for learning, after the Web docs, is the = ssg.h file (and the sg.h too). > Also! > Is this code part of PLIB ? or Should I mention you OR=20 > SOMEBODY ELSE in the code ? or somewhere else? Ah, probably you are replying in the "Matrices and sgCoord" thread with = the "Help for code that is not documented and isconfusing" thread in mind = (then focused on object picking), isn't it? Is this the code do you refer to? It would be appropriate to equip SSG with native picking functions = (object, or other lower level primitives). There are good reasons for letting = them away from SSG, but even for putting them into SSG or in the SSG = Auxiliary library. Anyway for me don't worry about credits. > Thank you! You're welcome, Paolo > ----- Original Message ---- > From: Paolo Leoncini <p.l...@ci...> > To: PLIB Users <pli...@li...> > Sent: Wednesday, July 25, 2007 2:51:22 PM > Subject: [Plib-users] R: R: R: Matrices and sgCoord >=20 > Dimistris,=20 >=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 > > ????? >=20 > Ok, these are all functions, not class methods. Just try to=20 > read 'transform' > in place of 'xform', and you'll get a plenty of ways to=20 > transform a point or > a vector, 3- or 4-dims, by a transformation matrix. >=20 > For example, sgXformVec3 will multiply a sgVec3 by the 3x3=20 > rotation section > of a sgMat4, whilst sgXformPnt3 does what sgXformVec3 does + adds the > matrix's translation row to the resuling vector (i.e. treats=20 > it as an actual > 'point'). >=20 > The 'Full' versions transform vecs and pnts 'homogeneously'. >=20 > Paolo >=20 >=20 > > ----- 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 >=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 > ______________________________________________________________ > ______________________ > Be a better Globetrotter. Get better travel answers from=20 > someone who knows. Yahoo! Answers - Check it out. > http://answers.yahoo.com/dir/?link=3Dlist&sid=3D396545469 >=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 |