Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualluckyyyyyy

Posted 13 October 2012 - 07:12 AM

haha.. I like the way u teaching.. ;)

I got your point.. i do not want any kind of line intersection of whatever. I just want that when I click on model I get 3D coordinates.

I did what u said at the end. But didn't get this ?
(when want to click)
change perspective to 'nicest z_near/z_far aspect ratio)

now tell me where I am doing wrong?

void glPerspective()
{
glViewport(0, 0, WINDOW_SIZE_W, WINDOW_SIZE_H);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (GLdouble)WINDOW_SIZE_W / (GLdouble)WINDOW_SIZE_H, 0.1, 10000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, m_zoom,   0.0, 0.0, 0.0,   0.0, 1.0, 0.0);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glPerspective();

glPushMatrix();
  glTranslatef(screenX, 0.0, 0.0);
  glTranslatef(0.0, screenY, 0.0);
  glRotatef(spin_y, 1.0, 0.0, 0.0);
  glRotatef(spin_x, 0.0, 1.0, 0.0);
  glRotatef(spin_z, 0.0, 0.0, 1.0);
  glGetDoublev( GL_MODELVIEW_MATRIX, OGLMmodelview );
  glGetDoublev( GL_PROJECTION_MATRIX, OGLMprojection );
  glGetIntegerv( GL_VIEWPORT, OGLMviewport );

  Render_Triangular_model();
glPopMatrix();
glutSwapBuffers();
}
GLpoint GetOGLMousePos(GLint x, GLint y)
{
GLdouble winX = 0.0, winY = 0.0, winZ = 0.0;
GLdouble posX = 0.0, posY = 0.0, posZ = 0.0;
winX = (float)x;
winY = (float)OGLMviewport[3] - (float)y - 1;   // invert winY so that down lowers value
glReadPixels( x, GLint(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );
gluUnProject( winX, winY, winZ, OGLMmodelview, OGLMprojection, OGLMviewport, &posX, &posY, &posZ);
return GLpoint(posX, posY, posZ);
}

Think of Design with Dimensions
http://real3d.pk


#1luckyyyyyy

Posted 10 October 2012 - 11:45 PM

haha.. I like the way u teaching.. ;)

I got your point.. i do not want any kind of line intersection of whatever. I just want that when I click on model I get 3D coordinates.

I did what u said at the end. But didn't get this ?
(when want to click)
change perspective to 'nicest z_near/z_far aspect ratio)

now tell me where I am doing wrong?

void glPerspective()
{
glViewport(0, 0, WINDOW_SIZE_W, WINDOW_SIZE_H);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (GLdouble)WINDOW_SIZE_W / (GLdouble)WINDOW_SIZE_H, 0.1, 10000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, m_zoom,   0.0, 0.0, 0.0,   0.0, 1.0, 0.0);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glPerspective();

glPushMatrix();
  glTranslatef(screenX, 0.0, 0.0);
  glTranslatef(0.0, screenY, 0.0);
  glRotatef(spin_y, 1.0, 0.0, 0.0);
  glRotatef(spin_x, 0.0, 1.0, 0.0);
  glRotatef(spin_z, 0.0, 0.0, 1.0);
  glGetDoublev( GL_MODELVIEW_MATRIX, OGLMmodelview );
  glGetDoublev( GL_PROJECTION_MATRIX, OGLMprojection );
  glGetIntegerv( GL_VIEWPORT, OGLMviewport );

  Render_Triangular_model();
glPopMatrix();
glutSwapBuffers();
}
GLpoint GetOGLMousePos(GLint x, GLint y)
{
GLdouble winX = 0.0, winY = 0.0, winZ = 0.0;
GLdouble posX = 0.0, posY = 0.0, posZ = 0.0;
winX = (float)x;
winY = (float)OGLMviewport[3] - (float)y - 1;   // invert winY so that down lowers value
glReadPixels( x, GLint(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );
gluUnProject( winX, winY, winZ, OGLMmodelview, OGLMprojection, OGLMviewport, &posX, &posY, &posZ);
return GLpoint(posX, posY, posZ);
}

PARTNERS