Re: [Plib-users] axes, OpenGL primitives and other confusion.
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2000-06-10 05:10:21
|
Stafford Goodsell wrote: > 1) > I am having major trouble with this coordinate system stuff. I did some more > tests, and i really must insist that the axis of rotation is different to the > axis of translation in plib. No - your error is in assuming that the two three element float arrays are: translation in X/Y/Z and rotation around X/Y/Z - that is NOT the case. The rotation array is H/P/R (Heading/Pitch/Roll) - which is rotation about (respectively) Z,X,Y. This may seem a little strange - but I always think of Euler angle rotations as 'Heading', 'Pitch' and 'Roll' and *NOT* as rotations about the three axes. Since people generally talk about "Heading/Pitch/Roll" and not "Pitch/Roll/Heading", the order of elements in the array seems "appropriate". Some people prefer the term "Yaw" rather than "Heading" - but I dislike using a word that begins with X,Y or Z since that prohibits the use of single letter variables! > Here is the startup code i use for the position of my helicopter: > > model_obj->lin_p[0] = 0.0; // model_obj can be considered a structure that > model_obj->lin_p[1] = 0.0; // holds the angle (ang_p), and position > model_obj->lin_p[2] = 90.0; // (lin_p) values of the model. > model_obj->ang_p[0] = 0.0; > model_obj->ang_p[1] = 0.0; > model_obj->ang_p[2] = 0.0; > > Then later on, every frame calls this: > sgSetCoord(&modelpos, model_obj->lin_p, model_obj->ang_p); > model -> setTransform(&modelpos); > ssgCullAndDraw ( scene ) ; // model is a ssgTransform in scene Seems reasonable. > This puts the helicopter at 90 units above the 'ground' (which is at 0,0,0), ...indeed. > and indicates as you have all pointed out that the z is up axis for plib. Correct. > Now, suppose i want to rotate around z? This would be equivalent to the > helicopter spinning as if its tail rotor were being activated. Yep - this is a change in the helicopter's heading - which is the first element in the 'hpr' array. (That's why it's called 'hpr' - to remind you of the order of the elements!) > Since z is up, > and the axis i want to rotate around, i should be able to do this: > > model_obj->lin_p[0] = 0.0; > model_obj->lin_p[1] = 0.0; > model_obj->lin_p[2] = 90.0; > model_obj->ang_p[0] = 0.0; > model_obj->ang_p[1] = 0.0; > model_obj->ang_p[2] = 90.0; Yep - so the third element of the ang_p array is 'Roll'... > But alas, the helicopter then ends up rotated 90 degrees around the axis going > into the screen (y?), not z. Yep - it rolled - just like you told it to. > This indicates to me that the axis of rotation is > different than the axis of translation. It's just a matter of convention. I'm used to using SGI's Performer scene graph library - and if you've ever used that, you'll notice a rather strong resemblence to my own SG library in Performer's linear math functions. > If i am mistaken anywhere here please point out where im wrong, but if this is > true... well im stumped as to how to do rotations relative to the object > properly :( Just remember 'hpr' and you'll be OK...or just forget the whole thing and use Matrices or Quaternions. > 2) > On Steve's note about drawing with both opengl and ssg, I tried using a > ssgSimpleState method, but it just produced lots of red flashes. (my lines > are supposed to be red) I will continue to work on it, since i suspect it is > a problem with my lines being in the wrong place or something like that, but > in the process, i think i found a another bug in plib :) When i call > ssgSimpleState->disable(), it produces a message: > > 'Illegal mode passed to ssgSimpleState::disable(X)' > > where 'X' is the mode given to the call. (I tried this with modes 0, 2 and 5 > (SSG_GL_TEXTURE_EN, SSG_GL_COLOR_MATERIAL_EN, SSG_GL_LIGHTING_EN; probably > not in that order :) The ssgSimpleState::enable/disable functions now take regular OpenGL tokens. eg my_state -> enable ( GL_LIGHTING ) ; > Oh btw, if you feel like being a hero and playing with the whole code :), you > can get it from anonymous cvs at sourceforge under the geome project: > ano...@cv...:/cvsroot/geome > checkout the 'demos' module I'm *way* too busy right now - sorry. -- Steve Baker http://web2.airmail.net/sjbaker1 sjb...@ai... (home) http://www.woodsoup.org/~sbaker sj...@ht... (work) |