Two gluProject points?

Member
Posts: 281
Joined: 2009.04
Post: #1
Hi all,

I have been using gluProject in my 3D scene with the following code:


Code:
gluProject(x_position,
y_position, z_position, model_view_matrix, projection_matrix, viewport, &label_position_x, &label_position_y, &label_position_z);
        
            

print("Marker" ,label_position_x,label_position_y);

Code:
    glGetDoublev(GL_MODELVIEW_MATRIX, model_view_matrix);
    glGetDoublev(GL_PROJECTION_MATRIX, projection_matrix);
    glGetIntegerv(GL_VIEWPORT, viewport);
(Please let me know if you think you need more code)

The problem is that the label 'Marker' is being drawn twice, once where it is supposed to be at (3D Object) and then again when the user is facing away from the object, but in the right position. That is, when I face the real marker, then turn exactly 180 degrees around there is another fake marker.

I think this may have something to do with a Z coordinate from gluProject, but I tried only drawing the marker when label_position_z was less than 0 and then only when more than 0; no results, still two markers.

Any help is greatly appreciated,

mikey

~ Bring a Pen ~
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
z_position is a window z coordinate. How are you getting it?
Quote this message in a reply
Member
Posts: 281
Joined: 2009.04
Post: #3
What do you mean? I am inputting the x_position, y_position and z_position as geographical locations in my world.

Quote:GLint gluProject( GLdouble objX,
GLdouble objY,
GLdouble objZ,
const GLdouble * model,
const GLdouble * proj,
const GLint * view,
GLdouble* winX,
GLdouble* winY,
GLdouble* winZ);

...

objX, objY, objZ
Specify the object coordinates.
- OpenGL Wiki

~ Bring a Pen ~
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
oh yeah, sorry, I'm backward, despite having worried that I might be backward :/

How are you drawing the marker at the calculated window coords?
Quote this message in a reply
Member
Posts: 281
Joined: 2009.04
Post: #5
Here's the function call in the previous code:

Code:
print("Marker",label_position_x,label_position_y);
And the function defenition:

Code:
int print(string printstring, float cursorx, float cursory)
{
    
    int qs;
    
        glRasterPos2f(cursorx, cursory);
    

    for (qs = 0; qs < printstring.length(); qs++)
    {
        
        glutBitmapCharacter(GLUT_BITMAP_8_BY_13, printstring.at(qs));
        cursorx += glutBitmapWidth(GLUT_BITMAP_8_BY_13, printstring.at(qs));
        
    //    cout << "printing " << printstring.at(qs) << ". \n";
        
    }
    
    
    
    
}

I am also drawing a circle at the same position (label_position_x,label_position_y). This behaves with the text.

~ Bring a Pen ~
Quote this message in a reply
Member
Posts: 281
Joined: 2009.04
Post: #6
The label_x and label_y coordinates are definetly right, I think that somewhere a Z coordinate is being neglected, but I can't find any appropriate... n.b. label_position_z is always 1.0, is this correct?

~ Bring a Pen ~
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Hierarchy, gluProject and collision detection lemtoo 3 4,719 Nov 30, 2007 09:26 AM
Last Post: lemtoo
  surface rendering from data points mc1961 6 5,124 Nov 15, 2007 03:37 PM
Last Post: TomorrowPlusX
  ordering of control points in glMap1f(...data) WhatMeWorry 10 6,987 Mar 11, 2006 08:36 PM
Last Post: WhatMeWorry
  gluProject &lt;-&gt; gluUnproject help please szgezu 9 7,270 Feb 26, 2006 11:50 AM
Last Post: szgezu
  Cocoa and OpenGL entry points? napthali 5 4,006 Dec 31, 2003 06:22 PM
Last Post: AnotherJake