Results 1 to 9 of 9

Thread: How to group objects together?

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2007
    Location
    Singapore
    Posts
    3

    How to group objects together?

    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.

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: How to group objects together?

    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:

    Code :
       1. Apply group transformations
       2. For each object:
         2a) glPushMatrix()
         2b) apply it's local transformation
         2c) render
         2d) glPopMatrix
       3. Do the same for all other groups

  3. #3
    Senior Member Regular Contributor
    Join Date
    Feb 2005
    Location
    South Tyrol, Italy
    Posts
    107

    Re: How to group objects together?

    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 ]

  4. #4
    Senior Member Regular Contributor
    Join Date
    Aug 2007
    Location
    USA
    Posts
    243

    Re: How to group objects together?

    Originally posted by Trenki:
    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.
    The matrix stack will most likely be moved into a utility library (such as GLU) instead of being the driver's responsibility.

  5. #5

    Re: How to group objects together?

    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.

  6. #6

    Re: How to group objects together?

    PS:
    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[1];

    use shader smart,you can get everying.

  7. #7
    Junior Member Newbie
    Join Date
    Aug 2007
    Location
    Singapore
    Posts
    3

    Re: How to group objects together?

    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.

  8. #8
    Junior Member Newbie
    Join Date
    Aug 2007
    Location
    Singapore
    Posts
    3

    Re: How to group objects together?

    Originally posted by Jedimaster:
    PS:
    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[1];

    use shader smart,you can get everying.
    cool.
    this may solve my coordinate problem.

  9. #9
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: How to group objects together?

    Just render them one after another... This way, it will be the same modelview matrix applied to both...

Similar Threads

  1. Replies: 1
    Last Post: 02-17-2015, 11:38 AM
  2. Replies: 5
    Last Post: 03-16-2011, 12:33 PM
  3. Do Vertex Array Objects 'group' also glUniform?
    By imported_tobindax in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-23-2011, 07:45 AM
  4. Group Objects
    By truetaurus in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-26-2009, 11:17 AM
  5. Replies: 17
    Last Post: 06-15-2006, 12:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean