Jump to content

  • Log In with Google      Sign In   
  • Create Account


luckyyyyyy

Member Since 20 Jan 2008
Offline Last Active Nov 12 2012 02:07 PM

Posts I've Made

In Topic: Loading 3ds Model (MultiObjects)

13 October 2012 - 12:29 PM

I can successfully read and load the objects like ur code. But I am unable to read Color info.. means color of objects that we reading from the file.
actually there are many ways to read 3DS chunks on the internet but in our way how can we read color info ?
U can see my code here..
//OBJ_TRIMESH
//TRI_VERTEXL
//TRI_FACEL1
//TRI_MAPPINGCOORS
case 0xa020: // diffuse color
if(1)
{
case 0×0010: // Color F
fread (&red, sizeof(float), 1, l_file);
fread (&green, sizeof(float), 1, l_file);
fread (&blue, sizeof(float), 1, l_file);
//if (!ReadFloat(fp, red)) return FALSE;
//if (!ReadFloat(fp, green)) return FALSE;
//if (!ReadFloat(fp, blue)) return FALSE;
break;
case 0×0011: // Color 24
fread (&red, sizeof(float), 1, l_file);
fread (&green, sizeof(float), 1, l_file);
fread (&blue, sizeof(float), 1, l_file);
//if (!ReadUByte(fp, tmp)) return FALSE;
//red = (float) tmp / (float) 255.0;
//if (!ReadUByte(fp, tmp)) return FALSE;
//green = (float) tmp / (float) 255.0;
//if (!ReadUByte(fp, tmp)) return FALSE;
//blue = (float) tmp / (float) 255.0;
break;
}
break;



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


In Topic: Incorrect 3D coordinates from 2D mouse click ?

13 October 2012 - 10:28 AM

haha.. NO i dont have any issue now... working like charm..
thanks to u.



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


In Topic: Loading 3ds Model (MultiObjects)

13 October 2012 - 10:09 AM

.

In Topic: Incorrect 3D coordinates from 2D mouse click ?

12 October 2012 - 03:06 AM

Thanks for your precious time. Now its solved. I mention the problem below. Usually we used to ignore (float or double) variables during programming, I think we should not.

GLpoint GetOGLMousePos(GLint x, GLint y)
{
GLfloat winX = 0.0, winY = 0.0, winZ = 0.0;	   // never ever make a mistake between float and double.
I wasted my 4 days to solve this and the problem was, I was using GLdouble here instead of GLfloat.
Try GLdouble here you will see a hell difference in output values.


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

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


In Topic: Incorrect 3D coordinates from 2D mouse click ?

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

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


PARTNERS