Hey all
I’m new here and while I’ve done some openGL stuff before, there are a couple of basic things I fail to understand still haha
I have a program that reads in a .obj file and stores all the object groupings together as a modelObject made up of multiple entities, where entities can be something about the model that moves independently of the other model parts(eg a tanks turret rotating at the top of the tank), and it should display each entity per modelObject when i run the draw for that MO (abbreviated because i dont wanna have to keep typing it out :P) by running a draw in the entity class, hope youre with me so far
what it is doing however is drawing only the turret which is the last one stored from the model, so my thought is its doing something along the lines of overwriting the last thing it drew, which is what i dont understand, uni never really explained how i should do this to let me draw multiple things
my other question is about texturing but thats no good until i have the model drawing eh
heres the code i use in display (im using JOGL, but ignore the gl. and you have plain openGL :)):
gl.glMatrixMode(gl.GL_MODELVIEW);
gl.glPushMatrix();
//gl.glRotatef(rotate, 1.0f, 1.0f, 0.0f);
gl.glColor3f(0.0f, 0.0f, 0.0f);
one.draw(gl);
gl.glPopMatrix();
Heres the code for draw in modelObject:
public GL draw(GL gl)
{
gl.glMatrixMode(gl.GL_MODELVIEW);
for(int i = 0; i < entities.size(); i++)
{
entities.get(i).draw(gl);
}
return gl;
}
And heres the draw code for entity:
public void draw(GL gl)
{
//gl.glBindTexture(GL.GL_TEXTURE_2D, texture);
for(int i = 0; i < facets.size(); i++)
{
Vertex[] v = facets.get(i).getVerts();
//gl.glMatrixMode(gl.GL_MODELVIEW);
//gl.glPushMatrix();
gl.glColor3f(1.0f, 1.0f, 1.0f);
gl.glBegin(GL.GL_TRIANGLES);
gl.glNormal3f(v[0].nmX, v[0].nmY, v[0].nmZ);
gl.glVertex3f(v[0].posX, v[0].posY, v[0].posZ);
gl.glNormal3f(v[1].nmX, v[1].nmY, v[1].nmZ);
gl.glVertex3f(v[1].posX, v[1].posY, v[1].posZ);
gl.glNormal3f(v[2].nmX, v[2].nmY, v[2].nmZ);
gl.glVertex3f(v[2].posX, v[2].posY, v[2].posZ);
gl.glEnd();
//gl.glPopMatrix();
}
}
sorry this is so long :(, its been bugging me for a couple of days though heh