Eddy

03-12-2000, 12:16 AM

> I have written this code to extract the vertices of 3ds file

> According to my documentation ,the vertices list begin to id

> TRI_VERTEXL ( 0x4110 ) : number of vertices (4octets),then vertex(array of

> three float(x,y,z,3x4octets)....

> but my code gives me the false values

> Someone can it do rectify my code ?

> thank you for all assistance

>

> #define TRI_VERTEX 0x4110

>

> FILE *binfile;

>

> unsigned char ReadChar (void)

> {

> return (fgetc (binfile));

> }

>

> unsigned int ReadInt (void)

> {

> unsigned int temp = ReadChar();

> return ( temp | (ReadChar () << 8));

> }

>

> int main(int argc, char* argv[])

> {

> int seek=0;

> unsigned int nbr_vertices;

> float vertices [3];

>

> binfile=fopen("tonneau.3ds","rb");

> if (binfile==NULL)return (-1);

>

> fseek(binfile,0L,SEEK_END);

> seek=ftell(binfile);

> printf("taille du fichier : %d \n",seek);

> seek=0;

>

> fseek(binfile,0L,SEEK_SET);

>

> while(ReadInt() != TRI_VERTEX)

>

>

> fseek(binfile,seek,SEEK_SET);

> seek++;

> }

> printf("TRI_VERTEX found at octet : %d ",seek);

>

> nbr_vertices=ReadInt();

> printf("nombres de vertices = %d\n",nbr_vertices);

>

> for (int i=0;i<nbr_vertices;i++)

> {

> fread (&(vertices [0]),sizeof (float),1,binfile);

> fread (&(vertices [1]),sizeof (float),1,binfile);

> fread (&(vertices [2]),sizeof (float),1,binfile);

>

> printf ("Vertex n° %d: X= %4.2f Y= %4.2f Z=%4.2f\n", i,

> vertices [0],

> vertices [1],

> vertices [2]);

> }

>

> return 0;

> }

>

> Didier

> According to my documentation ,the vertices list begin to id

> TRI_VERTEXL ( 0x4110 ) : number of vertices (4octets),then vertex(array of

> three float(x,y,z,3x4octets)....

> but my code gives me the false values

> Someone can it do rectify my code ?

> thank you for all assistance

>

> #define TRI_VERTEX 0x4110

>

> FILE *binfile;

>

> unsigned char ReadChar (void)

> {

> return (fgetc (binfile));

> }

>

> unsigned int ReadInt (void)

> {

> unsigned int temp = ReadChar();

> return ( temp | (ReadChar () << 8));

> }

>

> int main(int argc, char* argv[])

> {

> int seek=0;

> unsigned int nbr_vertices;

> float vertices [3];

>

> binfile=fopen("tonneau.3ds","rb");

> if (binfile==NULL)return (-1);

>

> fseek(binfile,0L,SEEK_END);

> seek=ftell(binfile);

> printf("taille du fichier : %d \n",seek);

> seek=0;

>

> fseek(binfile,0L,SEEK_SET);

>

> while(ReadInt() != TRI_VERTEX)

>

>

> fseek(binfile,seek,SEEK_SET);

> seek++;

> }

> printf("TRI_VERTEX found at octet : %d ",seek);

>

> nbr_vertices=ReadInt();

> printf("nombres de vertices = %d\n",nbr_vertices);

>

> for (int i=0;i<nbr_vertices;i++)

> {

> fread (&(vertices [0]),sizeof (float),1,binfile);

> fread (&(vertices [1]),sizeof (float),1,binfile);

> fread (&(vertices [2]),sizeof (float),1,binfile);

>

> printf ("Vertex n° %d: X= %4.2f Y= %4.2f Z=%4.2f\n", i,

> vertices [0],

> vertices [1],

> vertices [2]);

> }

>

> return 0;

> }

>

> Didier