Thread: [Plib-users] OpenGL primitives
Brought to you by:
sjbaker
From: Stafford G. <su...@ma...> - 2000-06-09 01:30:45
|
Hi, Im trying to debug some physics code i have, and i would like to draw a 'force vector' (GL_LINE) indicating where the force is applied. However, when i do, it does not show. (Yes i did it between glBegin/glEnd pairs) I think it is because im also using the ssg library to draw the main scene. Is it possible to draw using both OpenGL and ssg scenes at the same time? Also, the reason i need to debug this code so intensely is because it seems that the axes are different depending on if you are rotating or translating... for translating x appears to be -, y is |, and z is . (into the screen), but for rotations, x is around |, y is around -, and z is the same. For example: an object at (0, 0, 0): -. an object at (0, -2, 5): -. an object at (0, -4, 0), rotated by (180, 0, 0): .- . the last one should be '- ' if the coordinate systems were the same. Is this a bug in plib, or some strange 'feature' of OpenGL? I have tried both plib 1.0.20, and 1.1.11, and they are the same in this respect. This anomaly is giving me much trouble in creating rotations relative to an object (as one needs in physics). For example i can only get a helicopter to rotate around the global y axis (|) not its own y axis, which may be totally different. See http://marys.dyndns.org/~surge/geome/ for some pictures of this. Thanks for any help. -- Stafford Goodsell <su...@po...> _ C") Programmer, administrator, avid gamer and all-round computer geek (_) http://www.marys.dyndns.org/ -"- |
From: Land T. S. <lan...@am...> - 2000-06-09 02:05:04
|
Hello Stafford, I don't know about 2d drawing, but I have a starfield in the back of one of my menus -- here is the code I use: void StarField::Draw() { int i; float *px, *py, *pz; static float c = 0.0f; glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective(90.0f, 640.0f/480.0f, 1.0, 500.0); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); gluLookAt( 0.0, 0.0, -5.0f, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ); px = x; py = y; pz = z; glDisable(GL_LIGHTING); glPointSize(1.0f); glBegin( GL_POINTS ); for( i=0; i<numStars; i++ ) { glColor3f( 1.0f - *pz / STAR_MAXZ, 1.0f - *pz / STAR_MAXZ, 1.0f - *pz / STAR_MAXZ); glVertex3f( *px, *py, *pz ); px++; py++; pz++; } glEnd(); glEnable(GL_LIGHTING); glDisable(GL_BLEND); } Stafford Goodsell wrote: > Hi, > > Im trying to debug some physics code i have, and i would like to draw a > 'force vector' (GL_LINE) indicating where the force is applied. However, when > i do, it does not show. (Yes i did it between glBegin/glEnd pairs) I think it > is because im also using the ssg library to draw the main scene. > > Is it possible to draw using both OpenGL and ssg scenes at the same time? > > Also, the reason i need to debug this code so intensely is because it seems > that the axes are different depending on if you are rotating or translating... > for translating x appears to be -, y is |, and z is . (into the screen), but > for rotations, x is around |, y is around -, and z is the same. > For example: > > an object at (0, 0, 0): > -. > an object at (0, -2, 5): > -. > an object at (0, -4, 0), rotated by (180, 0, 0): > .- > . > the last one should be '- ' if the coordinate systems were the same. > > Is this a bug in plib, or some strange 'feature' of OpenGL? I have tried both > plib 1.0.20, and 1.1.11, and they are the same in this respect. This anomaly > is giving me much trouble in creating rotations relative to an object (as one > needs in physics). For example i can only get a helicopter to rotate around the > global y axis (|) not its own y axis, which may be totally different. > See http://marys.dyndns.org/~surge/geome/ for some pictures of this. > > Thanks for any help. > > -- > Stafford Goodsell <su...@po...> _ > C") > Programmer, administrator, avid gamer and all-round computer geek (_) > http://www.marys.dyndns.org/ -"- > > _______________________________________________ > plib-users mailing list > pli...@li... > http://lists.sourceforge.net/mailman/listinfo/plib-users -- +-------------------------+--------------------------------------------+ | Landshark (dave) | Visio clone for *nix? It's in the works: | | lan...@am... | http://queesio.sourceforge.net | +-------------------------+--------------------------------------------+ | X10 GUI Device Controller for *nix? http://q10.phlan.net | +----------------------------------------------------------------------+ |
From: Norman V. <nh...@ca...> - 2000-06-09 02:14:08
|
Stafford Goodsell writes >Sent: Thursday, June 08, 2000 9:28 PM >To: pli...@li... >Subject: [Plib-users] OpenGL primitives > > > >Hi, > >Also, the reason i need to debug this code so intensely is >because it seems that the axes are different depending on >if you are rotating or translating... >for translating x appears to be -, y is |, and z is . (into >the screen), but for rotations, x is around |, y is around -, and z is the same. My guess is that you are confused by the difference between the coordinate systems used by SSG and OpenGL. In OpenGL Z is going in and out of the screen whereas in SSG Z is up down or Y in OpenGL To convert from SSG to OpenGL you can use the following // hack sgMat4 copy_of_ssgOpenGLAxisSwapMatrix = { { 1.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, -1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 1.0f } } ; sgMat4 vm_tmp, view_mat; sgTransposeNegateMat4 ( vm_tmp, current_view.VIEW ) ; sgCopyMat4( view_mat, copy_of_ssgOpenGLAxisSwapMatrix ) ; sgPreMultMat4( view_mat, vm_tmp ) ; glLoadMatrixf( (float *)view_mat ); Nice Looking Helicopter :-)) Have you checked out FlightGear. http://www.flightgear.otg It is using SSG for the majority of its rendering and comes with source. Norman Vine |
From: Steve B. <sjb...@ai...> - 2000-06-09 13:28:06
|
Stafford Goodsell wrote: > Im trying to debug some physics code i have, and i would like to draw a > 'force vector' (GL_LINE) indicating where the force is applied. However, when > i do, it does not show. (Yes i did it between glBegin/glEnd pairs) I think it > is because im also using the ssg library to draw the main scene. Well for starters, you need GL_LINES the 'S' is important! It's *really* annoying that OpenGL defines a valid token 'GL_LINE' - but it's not the token you pass to glBegin() - always use 'GL_LINES' - even if you are only drawing one line! However, that may not be your only problem because SSG generally leaves OpenGL in an unspecified state - texture might be enabled - or lighting might be turned on with the glMaterial specifying an alpha of zero (hence invisible lines)...you really don't know...but we've thought about this, so... > Is it possible to draw using both OpenGL and ssg scenes at the same time? Yes - I do that all the time. You'll probably need to do things like disabling texture, make sure that the modelview and projection matrices are what you want (SSG has functions to help with that). The easiest way to get the OpenGL state to be what you want is to define an ssgSimpleState object for your GL_LINES and to call: my_state->apply () ; ...just before you start drawing. That way, SSG will change the current state to do what you want without you having to worry about what states SSG might have messed with. > Also, the reason i need to debug this code so intensely is because it seems > that the axes are different depending on if you are rotating or translating... > for translating x appears to be -, y is |, and z is . (into the screen), but > for rotations, x is around |, y is around -, and z is the same. SSG uses a Z-is-up, X-is-right and Y-is-into-the-screen coordinate system, with heading, pitch and roll defined appropriately for that coordinate system. > For example i can only get a helicopter to rotate around the > global y axis (|) not its own y axis, which may be totally different. > See http://marys.dyndns.org/~surge/geome/ for some pictures of this. I think you need to read my paper: http://web2.airmail.net/sjbaker1/matrices_can_be_your_friends.html -- Steve Baker http://web2.airmail.net/sjbaker1 sjb...@ai... (home) http://www.woodsoup.org/~sbaker sj...@ht... (work) |