PDA

View Full Version : Need a Hint in Lib3ds



best4gotten
02-01-2009, 01:14 PM
Hi guys I know its not the Very right place to ask this question but I just need a small hint..
I am making my 3ds Loader using Lib3ds

I have extracted Vertex data from Meshes and stored into Arrays

I have Extraceted Normal Data and Stored in Arrays

I have Extracted U-V coordinate data and stored in Arrays

However my Models Have texture from Diffuse color of the materials in form of BMP files

I Have Extracted File names for Materials Like this


m_model = lib3ds_file_load(filename.c_str());
for(Lib3dsMaterial* index=m_model->materials;Index!=0;Index=Index->next)
{
printf("\n %s Map Name",Index->texture1_map.name);
// Here I can Use GLAUX Library to convert my BMP files into textures
}


Now I dont know How would I know which BMP file belongs to Which mesh??

Secondly How can I Map It On onto my meshes?


I am using glDrawArray to Draw my MEshes with corresponding Normals/Vertex/U-V Tex Arrays..

Kindly give me some clue about it.

Thanks IN advance

Mars_999
02-01-2009, 10:00 PM
Use classes, make a class that has the texture ID you use with glGenTextures and glBindTexture. With this class you can load each mesh into its own object. You can then Draw() the mesh within the class and keep everything nice and neat.

_NK47
02-02-2009, 03:14 AM
3ds files stores so called material groups which tell you which mesh has which material properties. look for material groups inside your loader it should read them out automatically i hope then just assign those materials by indices to your meshes.

best4gotten
02-02-2009, 06:50 AM
Hi Guys
Thank you very much for help.
Yes I found out about the Material groups and its properties.
Though I have some problem finding out what to do with some materials which show up without any name but I will manage it.

My second Problem is about applying these textures to the mesh.
My Data goes like this...

I read each mesh and store its Vertex Normals and Tex coords in 3 1D Vectors of float
then I put them in my three MAIN vectors for vertex/normal/coord
this forms a 2d Vectors for each type of data.
Then I Use For loop to go through these 2d Vectors and then Display it using glDrawArrays with corresponding vertex/normal/Texcoord Pointers. My Question is When I have figured out which texture belongs to which mesh All I have to do is convert the BMP file in it into OpenGL texture ( I know some libraries for that) and then BIND this texture before the display Array call for corresponding mesh???