Jump to content
  • Advertisement
Sign in to follow this  
Utkarsh

Obj file not being loaded

This topic is 4028 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I am trying to load an obj file thru nate robbins Object loader code. The model is being loaded but its whole white in color as i suppose the material properties are not benig loaded(the mtl file is in the same directory). How can i debug this error ? Also, i need to rotate and translate the model with the help of my mouse to view it 3 dimensionally. How can i accomplish that. I am using numerous "if-else" stmts to achieve this. Is there an efficient way to do that ?

Share this post


Link to post
Share on other sites
Advertisement
I did not u'stand what u r trying to say

This is how the object is being loaded through GLM. It has nothing to do with the .mtl file as it is included from within the .obj file. So we have no hold on it.

sphere = malloc(sizeof(GLMmodel));
sphere = glmReadOBJ("r177772.obj"); // create sphere render list
glmList(sphere, GLM_SMOOTH); // create smoothed render list
glmUnitize(sphere);

In the mouse handler i am having several if else to manipulate rotation and translation to handle the model. But cudnt do it properly. Do u have any code which can do that or some hint regarding that.
It'd really be appreciated

Thanks

Utkarsh

Share this post


Link to post
Share on other sites
If you want the camera to rotate around the object and be able to zoom in and out, you can implement what's known as arc-ball rotation. There's a tutorial here, and you can find more information in google.

About the model loading, all I can say is, use the debugger to go through the code and see if anything looks "fishy". Adding a few well-placed asserts might also help. If you want more focused advice you'll have to post the source code (at least the part that you think isn't working).

Share this post


Link to post
Share on other sites
Hey
Iam looking into the arcball tutorial.
Meanwhile this is the code i am working on .

The glm.h and glm.c can be found from these links

http://www.cs.kent.edu/~farrell/cg05/progs/nate_tutor/glm.h
http://www.cs.kent.edu/~farrell/cg05/progs/nate_tutor/glm.c

This is what the code does.
It loads an obj file but does not displays it in a correct manner. Material properties do not seem to come up. Its all white


#include "glm.h"

GLMmodel* sphere;


void loadGeometry()
{
sphere = malloc(sizeof(GLMmodel));
sphere = glmReadOBJ("r177772.obj"); // create sphere render list
glmList(sphere, GLM_SMOOTH); // create smoothed render list
glmUnitize(sphere);
}


static void Display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glmDraw(sphere, GLM_COLOR );
glutSwapBuffers();
glutPostRedisplay();
}

void myMouseMotion(GLint x, GLint y)
{
static GLint presentX;
static GLint presentY;
static GLint actualY;

actualY = 600 - y;
// Handle mouse motion events


// all the mouse handling but dont worry abt this its all not working

if((actualY > presentY) && (x == presentX ) )
glRotatef(1, 1.0, 1.0, 1.0);

else if((actualY > presentY) && (x > presentX))
glRotatef(1, 1.0, 1.0, 0.0);

else if((actualY < presentY) && (x == presentX))
glRotatef(1, -1.0, 0.0, 0.0);

else if((actualY < presentY) && (x > presentX))
glRotatef(1, 0.0, -1.0, 0.0);

else if((x > presentX) && (actualY == presentY ) )
glRotatef(1, 0.0, 1.0, 0.0);

else if((x < presentX) && (actualY == presentY))
glRotatef(1, 0.0, -1.0, 1.0);

else if((x < presentX) && (actualY > presentY))
glRotatef(1, 1.0, -1.0, 1.0);

else if((x < presentX) && (actualY < presentY))
glRotatef(1, -1.0, -1.0, 1.0);

//glPopMatrix();
presentX = x;
presentY = y;
glutPostRedisplay();
}


int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(800, 600);
glutInitWindowPosition(50,50);
glutCreateWindow(argv[0]);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

loadGeometry();
glutDisplayFunc(Display);
glutMotionFunc(myMouseMotion);
glutMainLoop();
return 0;
}

Share this post


Link to post
Share on other sites
from NeHe's lesson 48 this line of my code is giving the following error

sphere = malloc(sizeof(GLMmodel));

error C2440: '=' : cannot convert from 'void *' to 'GLMmodel *'

if i typecast the code like

sphere = (GLMmodel*)malloc(sizeof(GLMmodel));

it starts giving "unresolved external symbols......" the standalone works fine. But when iuntegrated with NeHe's code it gives this error..

What cud be the problem. Do i need to change some settings ?

Please reply

Utkarsh


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!