Jump to content
  • Advertisement
Sign in to follow this  
irdalama

Scene Graph and the inverse

This topic is 4240 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im trying to really grasp the idea of using a graph system so i can better control the interaction between objects and their space realtionships. I understand the basic idea of simple graph systems like this one
glpushmatrix();
glMultMatrix(rotateboxmatrix);
drawbox();
glpushmatrix();
glTranslate(box-part-to-box_matrix);
glPopmatrix();
glPOpMatrix();
But i cant completely understand how inverse matrices come into play so i can setup a any object and do rotations with respect to anything anywhere. I cant attain complete functionailty of my graph system when using inverses cause i dont understand the inverse realtionship with respect to the modelview. I want to have the viewing transform attached to an object, and then have that object translate through the world. When the object translates, the viewing transform should stay with it, giving it a camera effect if you will. If the first thing i do is place the inverse camera postion&orientation, then i should be ablt to draw the object. Next i would have to multiply the modelview by the objects inverse to be able to manipulate/draw on the world. I understand this in theory, but i need help with the actual implementation. Can anyone give me some sort of scene graph similar to this (actual code or ideas? I ma using gmtl to invert and store matrices, if nayone could give me any help whatsoever, feel free. thanks [Edited by - irdalama on October 17, 2006 9:45:55 PM]

Share this post


Link to post
Share on other sites
Advertisement
From what I understand from your post is that all objects has a transformation matrix. Are all those matrices transformation relative to the parent node in the scenegraph or are they world transformation?

If they are transformation relative to the parent then you'll have to load the matrix from the first node and then push it. Multiply the current transformation by the transformation of the children your going to draw then draw the children. And so on...

EDIT: And you pop the transformation when your going back in the hierarchy (to reload the transformation of the parent).

If all the transformations are stored as world transformations. Load the transformation before each draw.

I'm not sure on the OpenGL functions to do that though... probably something like glMultMatrix and glLoadMatrix.

JFF

Share this post


Link to post
Share on other sites
The way i want to implement it is that the camera node is attached to the object.
And i want to able to rotate hte camera around the object.

The parent is the world node, but traversal starts from the camera by adding to the modelview the inverse of the camera pose multiplied by the inverse of the helicoptor pose. By doing this ill be able to rotate and translate the object in the world by having the camera always fixed on that object.

I have tried this over and over again. But the implmentation never seems to work right, so im thinking thati dont udnerstand whats going on.

ALso, yes, i will be doing world tansformations only to make it appear that hte helicoptor is rotating with a fixed camera but actually i want to rotae the world to make it appear that way. if there is even a difference.

Share this post


Link to post
Share on other sites
And being tired I forgot something in my post ;)... about the transformations themselves.

First imagine the object at the initial position (centered at 0,0,0). Rotate it, stretch it then translate it. Then you'll have the object at the final position. If you don't have the object positioned at (0,0,0) the rotation and stretching might not have the effect you'd expect.

To manage all that I'm using a transformation class I made. All my objects are centered to (0,0,0) at first and each node in the scenegraph can return a transformation object than I use to get the transformation matrix (all that in DirectX but it would be really easy to port to OpenGL).

I'm using the transformation matrices to draw the objects like I said in the previous post.

JFF

Share this post


Link to post
Share on other sites
Quote:
Original post by irdalama
The way i want to implement it is that the camera node is attached to the object.
And i want to able to rotate hte camera around the object.


You should separate the camera from the object. Create a viewing matrix which will be the transformation for the camera. When you draw your object you multiply its transformation by the transformation for the camera (If I understood correctly than OpenGL has to transformation for the camera and only for the objects).

Your free to set the camera's transformation to whatever you want depending on the use (like tracking an object like you said). When you move the camera you just update that matrix and all will be updated.


JFF

Share this post


Link to post
Share on other sites
in case anyone had similar problems as me i found a great abstrac talking exactly about what i want.

Thanks j for the help!

http://www.cs.csustan.edu/~rsc/Scenegraph.pdf

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!