load 3ds max models into opengl program
#1
Posted 21 January 2006 - 07:05 PM
#2
Posted 21 January 2006 - 07:11 PM
#3
Posted 22 January 2006 - 03:37 AM
#4
Posted 22 January 2006 - 09:04 AM
Search for 3d studio max exporter in google. Theres plenty of results on the first page.
#5
Posted 22 January 2006 - 05:16 PM
-si
#6
Posted 18 February 2006 - 06:10 AM
Any others way that can get know about loading 3ds model into openGL program?
#7
Posted 18 February 2006 - 07:12 AM
Have you looked at lib3ds, suggested by Vandervecken?
#8
Posted 18 February 2006 - 01:11 PM
I had looked at lib3ds, and even downloaded, but I don't know how to make it useful for me. I'm so stuck. Kindly give me some directions?
Thanks.
#9
#10
Posted 20 February 2006 - 02:03 AM
:)
#11
Posted 20 February 2006 - 02:10 AM
I already trial and trial to load model, but still fail. Anyone can tell me what to do??:wallbash: I'm really so stuck.
Thanks to those suggestions provided.
Any information are still welcome.
Thanks.
#12
Posted 20 February 2006 - 05:15 AM
#13
Posted 20 February 2006 - 01:11 PM
Thanks.
#14
Posted 20 February 2006 - 05:18 PM
/* #include <config.h> */
That's called commenting out.
#15
Posted 21 February 2006 - 10:33 AM
http://www.spacesimu..._3dsloader.html
And the source code for windows-
http://www.spacesimu...t-tutorial4.zip
#16
Posted 21 February 2006 - 03:52 PM
Reedbeta said:
/* #include <config.h> */
That's called commenting out.
Ya, Reedbeta, I already comment out that.
But, i still can't figure out the problem.
Your kindness are appreciated.
Ideas and suggestions are still welcoming.
Thanks.
#17
Posted 21 February 2006 - 03:58 PM
I haven't try it, but I hope it can help me a lot. Coz I have just left a bit time to complete my project. I'm so nervous now. Thus, anyone got any idea about my problem, kindly suggest here or send me via email.
A lots of thanks here.
#18
Posted 21 February 2006 - 05:05 PM
I have a great little sample on loading 3ds models that i wrote myself. It covers the loading as well as the displaying of the mesh. Its very short and to the point. I wanted to e-mail the full source but i don't have your e-mail id.
#19
Posted 21 February 2006 - 05:11 PM
----------------------------------------------------
//Basic Classes:
//Required for representing the loaded model
class vertex{
public:
float x,y,z;
};
//MapCoord - for storing texture mapping coords
class mapcoord{
public:
float u,v;
};
//The three ints for the polygon
//represent the no.s(or rank) of it's 3 vertices
class polygon{
public:
int a,b,c;
};
class object{
public:
char name[20];
int numVerts,numPolys;
vertex v[3000];
polygon p[3000];
mapcoord m[3000];
};
//-----------------------------------------------------------------------------
// Name: Load3dsObject (object *, char *)
// Desc: Loads a 3ds object given a filename
//-----------------------------------------------------------------------------
void Load3dsObject (object *obj, char *filename)
{
FILE *file; //Our file pointer
char temp; //Temporary char for reading name of object
short chunkID; //Stores ID of current chunk.
int chunkLength;
short useless;
//Open our file for reading(r) and in binary mode(b)- "rb"
file=fopen (filename, "rb");
int i;
//While current position is lesser than the total length
while (ftell(file) < filelength (fileno (file)))
{
fread (&chunkID, 2, 1, file);
fread (&chunkLength, 4, 1,file);
switch (chunkID)
{
case 0x4d4d: //Skip these chunks
break;
case 0x3d3d:
break;
case 0x4000: //Chunk containing name
for(i=0;i<20;i++)
{
fread (&temp, 1, 1, file);
obj->name[i]=temp;
if(temp == '\0')break;
}
break;
case 0x3f80: //Skip again
break;
case 0x4100:
break;
case 0x4110: //Chunk with num of vertices
//followed by their coordinates
fread (&obj->numVerts, sizeof (unsigned short), 1, file);
for (i=0; i<obj->numVerts; i++)
{
fread (&obj->v[i].x, sizeof(float), 1, file);
fread (&obj->v[i].y, sizeof(float), 1, file);
fread (&obj->v[i].z, sizeof(float), 1, file);
}
break;
case 0x4120: //Chunk with numPolys and
//the indices
fread (&obj->numPolys, sizeof (unsigned short), 1, file);
for (i=0; i<obj->numPolys; i++)
{
fread (&obj->p[i].a, sizeof (unsigned short), 1, file);
fread (&obj->p[i].b, sizeof (unsigned short), 1, file);
fread (&obj->p[i].c, sizeof (unsigned short), 1, file);
fread (&useless, sizeof (unsigned short), 1, file);
}
break;
case 0x4140: //Chunk with texture coords
fread (&useless, sizeof (unsigned short), 1, file);
for (i=0; i<obj->numVerts; i++)
{
fread (&obj->m[i].u, sizeof (float), 1, file);
fread (&obj->m[i].v, sizeof (float), 1, file);
}
break;
default:
fseek(file,chunkLength-6, SEEK_CUR);
}
}
fclose (file);
}
//-----------------------------------------------------------------------------
// Name: DrawObject(object *obj)
// Desc: Draws our loaded 3ds object
//-----------------------------------------------------------------------------
void DrawObject(object *obj)
{
glBegin(GL_TRIANGLES);
for (int i=0;i<obj->numPolys;i++)
{
glTexCoord2f( obj->m[ obj->p[i].a ].u,
obj->m[ obj->p[i].a ].v);
glVertex3f( obj->v[ obj->p[i].a ].x,
obj->v[ obj->p[i].a ].y,
obj->v[ obj->p[i].a ].z);
glTexCoord2f( obj->m[ obj->p[i].b ].u,
obj->m[ obj->p[i].b ].v);
glVertex3f( obj->v[ obj->p[i].b ].x,
obj->v[ obj->p[i].b ].y,
obj->v[ obj->p[i].b ].z);
glTexCoord2f( obj->m[ obj->p[i].c ].u,
obj->m[ obj->p[i].c ].v);
glVertex3f( obj->v[ obj->p[i].c ].x,
obj->v[ obj->p[i].c ].y,
obj->v[ obj->p[i].c ].z);
}
glEnd();
}
It would be more helpful to you if I could attach the file and e-mail it to you.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












