I have a number of objects which belong to the same group.
I want do some manipulation on the group, i.e. translate, rotate, scale.
How can I get it done?
what changes are needed if I want to know the status of individual objects also, i.e. position.
thanks for anyone who can help.
OpenGL doesn’t operate with notions of “objects”, it renders primitives. An “object” is what your application makes of it. Similar, it is teh task of your application to set up and maintain state for this objects. Usually you want to keep some data (position, orientation) associated with an object and set the corresponding modelview matrix (via glTranslate, glRotate etc.) when rendering it. Same goes for groups of objects. You could do it like this:
1. Apply group transformations
2. For each object:
2b) apply it's local transformation
3. Do the same for all other groups
Zengar is right; OpenGL only renders primitives you send it. You have to group those primitives to form objects yourself. In the upcomming OpenGL 3 the OpenGL matrix stack will be removed so you don’t have glRotate/glTranlate glPush/Pop any more and have to roll your own. Please correct me if I’m wrong here.
[ www.trenki.net | vector_math (3d math library) | software renderer ]
It’s fully a application’s stuff, you can use C++ STL to manage your all meshes in your scene, write some class/struct to keep your information, such as translation matrix etc.
In my programming, I pass the WorldTransMatrix into Texture Matrix 1, so, in my VS, I can simply get its world position:
vec4 WorldPos = gl_Vertex*gl_TexureMatrix;
use shader smart,you can get everying.
Thanks for the replies.
the actual application is a bit more complicated than this. I am afraid I didn’t state it clearly enough.
Here is an example scenario.
there will be 3 spheres in scene; one at origin; the other two as a group.
what I need to do is, to control transformation of the “two spheres” group using mouse.
( is it a good idea to use a display list? since there are 10s to 100s spheres in actual application.)
The problem i am facing now is how to group “two spheres” together. It really is a silly question, but I am beginner~.
further questions after sphere group transformation are like, how to get individual sphere center coordinates, how can I implemente it in a way that it can select both group object and individual sphere.
btw, I am writing it in C++.
graphics part done by openGL.
haptic part by openHaptics.
Just render them one after another… This way, it will be the same modelview matrix applied to both…