Archived

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

MGS3

3ds file structure

Recommended Posts

Hi every Body ; i have read from some time code that helped to read 3ds file and draw its object in my opengl project ; this function i called it load3ds() and it loads 3ds files ver 3 or higher ; the main problem that it reads some 3ds files ok but not all 3ds files ; i have used only chunks that create polygons of the object ,mapcoordinates for texture mapping , but didn,t read any things on material keyframes , lighting and so on cause it is not important to me ;i need to know from the following code why it does not read all 3ds filessuccessfully particulary those complex 3ds files ;in addition when i read one of those 3ds files that does work correctlly in my code using a utility i found there is about 18466 polygons in its object ; while in my code it reads only 16 polygons !!! please help me if you know some thing on the 3ds file structure so here is the code ; Ooh i remember to say that i use opengl under c# using csgl not vc++ : public struct Vertex_type { public float x,y,z; } public struct Polygon_Type { public int a,b,c; } public struct Mapcoord_Type { public float u,v; } public struct Obj_Type { public int vertices_qty; public int polygons_qty; public uint id_texture; public char[] name; public Vertex_type[] Vertex; public Polygon_Type[] Polygon; public Mapcoord_Type[] Mapcoord; public UInt16[] Flag; } public void Load3DS(ref Obj_Type p_object,string FileName) { Int32 i=0; UInt16 l_chunk_id=0; UInt32 l_chunk_lenght=0; //UInt32 temp; char l_char; ushort l_qty; //ushort l_face_flags; FileStream f= new FileStream (FileName,FileMode.Open ,FileAccess.Read ); BinaryReader stream= new BinaryReader (f); while (stream.BaseStream .Position =l_char; i++; } while((l_char!='\0') && (i<20)); break; ////////// ////////// case 0x4100: break; ////////// ////////// case 0x4110 : /* Vertex List for x,y,z vertices position */ l_qty = stream.ReadUInt16 (); p_object . vertices_qty = l_qty; for(i=0;i New Trend Toward emulation [edited by - MGS3 on March 19, 2004 6:40:47 AM] [edited by - mgs3 on March 19, 2004 6:42:45 AM] [edited by - mgs3 on March 19, 2004 6:45:34 AM]

Share this post


Link to post
Share on other sites