I have a object class that imports .Ase files from 3DS Max 2.5…
the arrays I have is this
struct sFace {
int v[3]; // 3 vertices for one triangle
};
struct sVertex3f {
float x,y,z; // vertex coordinates
};
struct sTexcoord {
float s,t;
};
class cObject {
sFace *Faces; // Triangle index
sVertex3f *vertices; // vertex list
sVertex3f *normals; // vertex normal list
sFace *tFaces; // texture coord index
sTexcoords *texcoords; // texture coord list
};
I’m using glDrawElement(…); to render the object
when I read from the ase file the texture coordinates gets a different index list then the vertex-array… if I use the same indexlist for the vertex and texture array then I only get the front face of my cube to have the proper texture…
can’t I share vertices like this when using textures and glDrawElement()? do I have to duplicate all vertices and normals?
maybe create one new struct and a function that stores every vertex, normal and tex-coord into it
struct sVertex8f {
float x,y,z; // vertex
float nx,ny,nz; // normal
float s,t; // tex coord
};
but this will take alot of memory space becouse I will have alot more vertices stored in memory then before… and there will be no index becouse the vertices can be stored in correct draw order… can I use glDrawArrays then?
but if I do this on a cube I will have a change something like this on a cube
before :
8 vertices (one for each corner)
8 vertex normals
24 texture coordinates
after :
24 vertices
24 normals
24 tex-coords
that will make my vertex and normal storage be 4 times bigger then it was before.