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 :slight_smile:

without creating everytime a new object

What do you mean ? Simply redraw using the VBO containing the model data.

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

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).

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