Lib3DS question
As for documentation, I can't remember any sources exactly but if you google 3ds chunk format, I'm sure you can find some documentation on how it works which should help in learning how the library works.
./player "obelisk.3ds"
***ERROR*** No Camera found.
This appears for any .3ds or .3DS model, can anyone advise on this, do I need I certain kind of model? Thanks.
You can try taking the camera code out or you can look for 3ds files that have cameras in then.
Check out 3dsViewer. The 3dsViewer.zip file has a few models in it. The canyonRun1.3DS animation has a camera in it. It might work.
Quote:
Original post by Kestrel
raw3dsData=lib3ds_file_load(fileName);
for(Lib3dsMaterial* Index=raw3dsData->materials;Index!=0;Index=Index->next)
{
Index->;texture1_map;
}
lib3ds stores its material data in a link list.
of course! you're right! thanks...coding should stop when the brain is malfunctioning...
my big question for today is there some change in the way 3ds handles textures or does it not load some image formats. I wrote my own loader and couldn't get any of the models I downloaded to show textures, I thought it was me so tried to use lib3ds still no textures. Kestrel kindly pointed me in the direction of his 3dsviewer, this works with his example models. However when I try to load any models I've gotten of the net, they are like my code untextured. :s
I have used Blender to load the files and it works fine, fully textured. I'm rather at a loss. The images use .JPEG file extentions, don't work with my model loader, don't work with my 3ds code, don't work with Kestrels 3dsloader but do load on Blender. Any advise please! I'm at a loss.
I don't know what the problem is with the other stuff. The max length of a texture name in a 3ds file is 8 characters + a 3 character extension. If a texture name is longer than 8 characters it will truncate the name. 3ds also doesn't store path names.
Are you loading the texture correctly?
Are you loading the UV coords?
Am I correct in pesuming
file=lib3ds_file_load(filename);
loads all the data including the texture names from the .3ds, and generates an openGL texture number for each texture? Or do I have to do this the normal openGL way?
I have pretty much copied the code from player.c and can see nowhere where a texture is bound to the object? But perhaps I'm misunderstanding the libary. Can you give me a pointer in the right direction? Here's what I've done based on the player.c code, but I can see no glBindTexture for binding the textures to the objects. Thankyou.
(Sorry can't see any button to put code in box?)
GLuint displayId;
Lib3dsRgba ambiant={0.2f, 0.2f, 0.2f, 1.0f};
Lib3dsRgba diffuse={0.8f, 0.8f, 0.8f, 1.0f};
Lib3dsRgba spectal={0.0f, 0.0f, 0.0f, 1.0f};
static GLfloat a[4]={0.0f, 0.0f, 0.0f, 1.0f};
void LoadModel(char *filename)
{
Lib3dsFile* file = 0;
Lib3dsMesh *mesh;
Lib3dsFace *f;
Lib3dsMaterial *material;
unsigned int p;
float s;
unsigned int i;
file=lib3ds_file_load(filename);
if ( ! file )
{
printf(" Loading 3DS file failed.\n");
exit(1);
}
displayId = glGenLists(1); /* assign display list */
glNewList(displayId, GL_COMPILE);
glBegin(GL_TRIANGLES);
for (mesh = file->meshes; mesh; mesh = mesh->next)
{
for (p = 0; p < mesh->faces; p++) /* step through mesh list */
{
f = &mesh->faceL
;
material = 0;
if (f->material[0]) /* does it have a material? */
{
material = lib3ds_file_material_by_name(file, f->material);
}
if (material) /*if it does use it's values not sure why a?*/
{
glMaterialfv(GL_FRONT, GL_AMBIENT, a);
glMaterialfv(GL_FRONT, GL_DIFFUSE, material->diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, material->specular);
s = pow(2.0f, 10.0f*material->shininess); /* make shininess an openGL value */
if (s>128.0f)
{
s=128.0f;
}
glMaterialf(GL_FRONT, GL_SHININESS, s);
}
else /*assign default material values */
{
glMaterialfv(GL_FRONT, GL_AMBIENT, ambiant);
glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, spectal);
}
glNormal3fv(f->normal); /*use normals */
for ( i = 0; i < 3; i++)
{
glVertex3fv(mesh->pointL[f->points].pos); /*draw the triangle*/
}
}
}
glEnd(); /* end GL_TRIANGLES */
glEndList(); /* end display list */
lib3ds_file_free(file);
}
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.