Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Drawing one Model more than one time

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2012
    Posts
    6

    Drawing one Model more than one time

    HI there,

    i want to draw a model which i created more than one time, without creating everytime a new object.

    i know there is a technique for it, but i don't know the name..... so is there a possibilty in openGL for it and whats the name for it? thanks :-)

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Drawing one Model more than one time

    without creating everytime a new object
    What do you mean ? Simply redraw using the VBO containing the model data.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2012
    Posts
    6

    Re: Drawing one Model more than one time

    currently i am not working with VBO.

    >> wouldn't be the objects on the same position if i just simply redraw them?


    but i've got an idea, i think i might just re-call the draw func, just with other coords

  4. #4
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,171

    Re: Drawing one Model more than one time

    use glpushmatrix to save the current modelview matrix (aka the camera) then use glTranslatef (x,y,z) to move the object into a position to draw. Finish by calling glPopMatrix to restore the modelview matrix.

    Remember the key to OpenGL is understanding the transform matricies - particulary the modelview matrix. This matrix transforms (moves, if you will) the verticies of the drawn object into worldspace (the Model part of the modelview) and then into camera space (the view part of modelview).

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2012
    Posts
    6

    Re: Drawing one Model more than one time

    so basicly i do (in pseudo c):

    Draw
    {
    glPushMatrix;
    ApplyTransformation(translate, rotate, world);
    Model->Draw;
    glPopMatrix;


    glPushMatrix;
    ApplyTransformation(translate, rotate, world);
    ApplyTransformation(translate, rotate, model); // other coords and rotationvectors
    Model->Draw;
    glPopMatrix;
    }

    (in ApplyTransform there are rotation and translation calls)
    which is build like this:

    void Renderer::ApplyTransformation(int rendermode)
    {
    if (rendermode == RENDERMODE_WORLD)
    {
    // scale, rotate, translate
    glRotatef(cam->rotationX->W, cam->rotationX->X, cam->rotationX->Y, cam->rotationX->Z);
    glRotatef(cam->rotationY->W, cam->rotationY->X, cam->rotationY->Y, cam->rotationY->Z);
    glRotatef(cam->rotationZ->W, cam->rotationZ->X, cam->rotationZ->Y, cam->rotationZ->Z);

    glTranslatef(cam->translation->X, cam->translation->Y, cam->translation->Z);
    }

    if (rendermode == RENDERMODE_MODEL)
    {
    glRotatef(model->rotationX->W, model->rotationX->X, model->rotationX->Y, model->rotationX->Z);
    glRotatef(model->rotationY->W, model->rotationY->X, model->rotationY->Y, model->rotationY->Z);
    glRotatef(model->rotationZ->W, model->rotationZ->X, model->rotationZ->Y, model->rotationZ->Z);

    glTranslatef(model->translation->X, model->translation->Y, model->translation->Z);

    }
    }



    did i get it right that now:

    the 2nd model is calculated with the "world" coords,too and after that it's own transformation?


    i'm just confused of my self, since in no draw i set matrixMode(GL_MODELVIEW).... only in inits mhmm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •