Hi All,
I recently started using lib3ds, 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]
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.\n");
}
else
{
printf("Model Loaded \n");
}
/******************************************************************************/
printf("Model Name %s\n",file->name);
printf("Model Version %lX\n",file->mesh_version);
/******************************************************************************/
/**********************Step through attributes*********************************/
for (mesh = file->meshes; mesh; mesh = mesh->next)
{
printf("Object name %s\n",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 \n",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 \n",i,*value,*(value+1),*(value+2))
}
if(p==3) exit(0);
}
}
}
[/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,1,1 is repeated for the rest of the model, can anyone give me a pointer in the right direction? Thanks.