can’t seems to be able to insert the image here…
but this is my source code for the display method.
Notice the codes between the //------------------------
Here I am rite these just for testing purposese. I am drawing a line on a specific location. but after I roate the teapot object and draw this line again. It its not visiable anymore. I understand that this is happening because I am actually drawing on the coordinates wrt to the object(local coordinate).
I’ll try to post an image of it as soon as I find out how to do so.
================================================================================
public void display(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
gl.glColor3f(1.0f, 0.0f, 0.0f);
this.calObjectCoor(gl);
if (test == true) {
System.out.println(wcoord[0] + ", " + wcoord[1]);
test = false;
}
//Do not clear screen when drawing the stroke, clear otherwise
if (clearBuf == true) {
gl.glClear(GL.GL_COLOR_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;
}
//When user Draws stroke with mouse
if (todraw == true) {
this.drawStroke(gl);
//------------------------------------------------------------------------------------------------------------------
gl.glBegin(GL.GL_LINE_STRIP);
gl.glVertex3f(-0.7295918367346939f, 0.46139359698681726f, 1.0000000596f);
gl.glVertex3f(0.5535714285714286f, 0.6384180790960452f, 1.0000000596f);
gl.glEnd();
//-------------------------------------------------------------------------------------------------------------------
}
//Display the Axis when the user clicks on the show Axis button
if (gridStatus == true) {
d.drawAxis(gl, false);
}
//Sets color to green and draw object
gl.glColor3f(0.0f, 1.0f, 0.0f);
model.draw(gl);
// Setup modelview matrix (model and viewing transformation)
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
// Camera
glu.gluLookAt(camera_x,camera_y,camera_z, 0,0,0, 0,1,0);
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);
// Flush OpenGL pipeline
gl.glFlush();
}