Hello,
I was wondering if some one could help me please as I new to openGL and still trying to figure my way around. I’m working on win98 with VC++ ver 6, what I done so far is to taken the example “Cube” (rotating 3d cube demo) and made some changes so I can draw an x,y,z axis, a cone and a shear.
Also from the mouse position returned as a “Point” I can calculate the selected view position using gluUnProject() so as to draw one of the above object shapes at the mouse location etc tec….
What I would like to do now is to draw a cone at the end of an axis line as it is rotated…
That is to say that after I have drawn a vertex line of the axis I need to find its position so I can start to draw the cone.
// Y line pair
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 1.0f, 0.0f);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, -1.0f, 0.0f); …… Would like to draw at cone at this translated position…………
I have spent days trying to figure it out, and the closest I have come to a solution is to use gluUnProject() but know matter how I try I find I can get it to work right… See my code below
GLdouble d_win_x_y_z[3];
CPoint point;
GLdouble modelMatrix[16];
GLdouble projMatrix[16];
GLint viewport[4];
glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
glGetIntegerv(GL_VIEWPORT, viewport);
CRect rect;
GetClientRect(&rect);
int y = rect.Height() - point.y;
glGetDoublev( GL_CURRENT_NORMAL , d_win_x_y_z );
gluUnProject( d_win_x_y_z[0] , d_win_x_y_z[1] , m_fRadius / 7 , modelMatrix, projMatrix, viewport, &objx, &objy, &objz);
Any Ideas please.
Ian Knight