Hi All,
I recently started using lib3ds as my model loader for OpenGL, after a few attempts I got it working with models, lights and textures. I then got updated my Debian system to Etch and found my code didn’t draw any models, that is exactly the same code I was using beforehand. On much testing it seemed that lib3ds was not producing any vertexes? I wrote this bit of test code to view the model, can anyone tell me if what I’m doing is right or is there a problem with Etch and lib3ds?
[source lang=“cpp”]
void LoadModel(char filename)
{
Lib3dsFile file = 0;
Lib3dsMesh *mesh;
Lib3dsFace *face;
unsigned int p,loop=0,i;
float *value;
/Load the model file/
file=lib3ds_file_load(filename);
if ( ! file )
{
printf(" Loading 3DS file failed.
");
}
else
{
printf("Model Loaded
");
}
//
printf("Model Name %s
",file->name);
printf("Model Version %lX
",file->mesh_version);
/***/
/Step through attributes***********/
for (mesh = file->meshes; mesh; mesh = mesh->next)
{
printf("Object name %s
",mesh->name);
for (p = 0; p < mesh->faces; p++) /* step through mesh list */
{
face = &mesh->faceL[p];
printf("%d Material name %s",++loop,face->material);
printf(" points %o %o %o",face->points[0],face->points[1],face->points[2]);
printf(" flags %o ",face->flags);
printf(" smoothing %lX", face->smoothing);
printf(" normal %f %f %f
",face->normal[0],face->normal[1],face->normal[2]);
/**********************Vertex ******************************************************/
for (i=0; i<3; ++i)
{
value=mesh->pointL[face->points[i]].pos;
printf("vertex point %d %f %f %f
",i,value,(value+1),*(value+2))
}
}
}
}
[/source]
This produces the following output
Model Loaded
Model Name MAXSCENE
Model Version 3
Object name Sphere01
1 Material name blueShine points 0 1 2 flags 7 smoothing 1 normal 1.000000 0.000000 0.000000
vertex point 0 0.000000 0.000000 0.000000
vertex point 1 0.000000 0.000000 0.000000
vertex point 2 0.000000 0.000000 0.000000
2 Material name blueShine points 742 2 3 flags 7 smoothing 1 normal 1.000000 0.000000 0.000000
vertex point 0 0.000000 0.000000 0.000000
vertex point 1 0.000000 0.000000 0.000000
vertex point 2 0.000000 0.000000 0.000000
The vertex 0,0,0 is repeated for the rest of the model, can anyone give me a pointer in the right direction? Thanks.
I should add I’ve tried loads of models all are the same. I’ve now also a built in function from lib3ds to show the vertexes and it also shows all zeros.
Sorry if this is not the correct forum, I’ve tried everywhere else with no answers, so I’m hoping some other opengl linux programmer also uses this libary and can give me a poiner.