problems with coordinates system

Well encountered some problems on the coordinates system that I am unable to solve for a couple of days.

I just loaded a obj file(teapot.obj) and have it displayed on screen. Then on the same canvas I am trying to draw lines on it. Well to map from world coordinates to the object coordinates, I use the glu.unproject(). The conversion does work, but when I rotate the object, my drawing screen would be rotated as well, causing problems to my drawing.

Does anyone have any idea on what is wrong or what slould I do to solve the problem?
I understand that currently I am drawing on the local coordinates since im using glu.unproject, but my aim is to do drawing on the global coordinates.
I hoped that someone can teach me how to do that…

Another thing is lets say my frame width is like 600, but when i convert to the object coordinates, the difference between the smallest x value and the biggers x
value is only less than 1. why is this so?

Thanks for the help…

What do u mean ur drawing screen would rotate ? Are u using a Lookat model or using glRotate? Can u provide a sreenshot?

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();
}

you are using glRotate without keeping the matrix state.

try glPushMatrix and glPopMatrix

wow…it works…

Thank you so much…

I find really tough to do these graphic stuff expecially when I know nothing about it. without your help, guess I am going to be stuck at this sate for a long long time.

once again… thank you~