Archived

This topic is now archived and is closed to further replies.

colinisinhere

milkshape with textures???

Recommended Posts

I know nehe has a tut on it but it i dont like how it is in like 5 different files.... anyway.... im useing the source from the nehe game model loader.... here is the code
typedef struct MS3D_HEADER_TYP
{
   	char id[10];
	int  version;
} MS3D_HEADER, *MS3D_HEADER_PTR;

typedef struct MS3D_VERTEX_TYP
{
	unsigned char flags;
	unsigned char refCount;
	char boneID;
	float vertex[3];
} MS3D_VERTEX, *MS3D_VERTEX_PTR;

typedef struct MS3D_TRIANGLE_TYP
{
	unsigned short flags;
	unsigned short vertexIndices[3];
	float vertexNormals[3][3];
	float u[3];
	float v[3];
	unsigned char smoothingGroup;
	unsigned char groupIndex;
} MS3D_TRIANGLE, *MS3D_TRIANGLE_PTR;

typedef struct MS3D_GROUP_TYP
{
   	unsigned char	flags;
   	char name[32];
   	unsigned short	numTriangles;
	unsigned short*	triangleIndices;
	char materialIndex;
} MS3D_GROUP, *MS3D_GROUP_PTR;

class MS3D
{
	public:
		unsigned short	numVertices;
		MS3D_VERTEX*	vertices;
		unsigned short	numTriangles;
		MS3D_TRIANGLE*	triangles;
		unsigned short	numGroups;
		MS3D_GROUP*	groups;

	bool Load(char* filename);
	void Render(void);

	MS3D()
	{	}

	~MS3D()
	{	
		if(vertices)
			delete vertices;		
		if(triangles)
			delete triangles;
		if(groups)
			delete groups;
	}
};

bool MS3D::
	Load(char* filename)
	{
	FILE* file;
	MS3D_HEADER header;
	int loop;
    if((file= fopen(filename, "rb"))==NULL)
    {
	   
	   return false;
    }
    fread(&header.id, sizeof(char), 10, file);
    fread(&header.version, 1, sizeof(int), file);
    fread(&numVertices, sizeof(unsigned short), 1, file);
    vertices= new MS3D_VERTEX [numVertices];
    for(loop=0; loopvertexIndices[loop3];

					glNormal3fv( tri->vertexNormals[loop3]);
					glTexCoord2f(tri->u[loop3], tri->v[loop3]);
					glVertex3fv(vertices[index].vertex);
				}
			}
			glEnd();
		}
	}

 
can someone please help me get it to render the textures???? thanks a lot!

Share this post


Link to post
Share on other sites
u wanna use multiple textures? if so, u could bind textures before rendering the next group, but then u have to know what texture that group gets....
i''ve recently bought ms but i don''t know how to get the texture info either. i''m just binding the textures when i write the loader..

Share this post


Link to post
Share on other sites