Heres the scenario:
I’v loaded an object from a object file (.obj).The vetex information are stored in a vertex array, and using the information, I’v calculated the edges and stored in an edge array.
After I load the object, I can perform translate, roatate,scale to the object.
Heres the problem, after performing the transformations, how to I retrieve the current value of all vextex/edges?
Or in another way of saying? how to I apply the transformation so that my array always have the updated values?
Heres part of my codes in java opengl(the display function only).
public void display(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
gl.glColor3f(1.0f, 0.0f, 0.0f);
this.calObjectCoor(gl,mouse_x,mouse_y,0.0f);
//Do not clear screen when drawing the stroke, clear otherwise
if (clearBuf == true) {
gl.glClear(GL.GL_COLOR_BUFFER_BIT|GL.GL_DEPTH_BUFFER_BIT);
}
//Only initialized the values of the mouse x, y coordindate upon user's mouse click
// where tmpX and tmpY are temporary holding ground for starting valus X,Y of the stroke
if (initStartCoord == true) {
tmpX = (float) wcoord[0];
tmpY = (float) wcoord[1];
initStartCoord = false;
}
//set up camera position and looking direction
setCamera(gl, glu, 4);
// Scene
gl.glPushMatrix();
if (todraw == true) {
gl.glDisable(gl.GL_DEPTH_TEST);
this.drawStroke(gl);
System.out.println("Line draw at: "+ mouse_x +", "+(viewport[3] - mouse_y));
gl.glEnable(gl.GL_DEPTH_TEST);
}
gl.glPopMatrix();
//Picking is done here
if(displayonce){
selectObject(gl,drawable);
displayonce=false;
}
gl.glPushMatrix();
gl.glTranslatef(movX, movY,1);
gl.glScalef(zoom, zoom, zoom);
gl.glRotated(scene_yaw * rad_to_deg, 0.0, 1.0, 0.0);
gl.glRotated(scene_pitch * rad_to_deg, 1.0, 0.0, 0.0);
//Display the Axis when the user clicks on the show Axis button
if (gridStatus == true) {
d.drawAxis(gl, false);
}
//draw the model
drawModel(gl,drawable,gl.GL_RENDER);
gl.glPopMatrix();
// Flush OpenGL pipeline
gl.glFlush();
}