🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

asc importer

Started by
13 comments, last by SKSlayer 24 years ago
Okay, here''s the part of the source code that concert my asc importer . But it doesn''t work :o(. Anyone can help ? Ne compilation error, but nothing show up at screen (if I just do a DrawFace(test->pFace[0]) I got a triangle showing up (as that''s what DrawFace is supposed to do) typedef struct tagVERTEX { double x,y,z; double u,v; } VERTEX; typedef struct tagFACE // face { VERTEX vertex[3]; } FACE; typedef struct tagSECTOR { int numface; int numvertex; VERTEX *pVertex; FACE *pFace; } SECTOR; double RANDOM_DOUBLE(double min, double max) { double x; double r=max-min; x=rand(); if (x>max) { while(x>max) { x=x-(r+1); } } else if (xx,pVertex1->y,pVertex1->z); glColor3d(((RANDOM_DOUBLE(0,100))/100),((RANDOM_DOUBLE(0,100))/100),((RANDOM_DOUBLE(0,100))/100)); // TEMPORARY RANDOM COLOR CODE glVertex3d(pVertex2->x,pVertex2->y,pVertex2->z); glColor3d(((RANDOM_DOUBLE(0,100))/100),((RANDOM_DOUBLE(0,100))/100),((RANDOM_DOUBLE(0,100))/100)); // TEMPORARY RANDOM COLOR CODE glVertex3d(pVertex3->x,pVertex3->y,pVertex3->z); glEnd(); } void DrawSector(SECTOR *pSector) { for (int drse=0; drse<=((pSector->numface)-1);drse++) { DrawFace(pSector->pFace[drse]); } } void VertexBind(FACE *pFace, VERTEX *pVertex1, VERTEX *pVertex2, VERTEX *pVertex3) { pFace->vertex[0].x=pVertex1->x; pFace->vertex[0].y=pVertex1->y; pFace->vertex[0].z=pVertex1->z; pFace->vertex[1].x=pVertex2->x; pFace->vertex[1].y=pVertex2->y; pFace->vertex[1].z=pVertex2->z; pFace->vertex[2].x=pVertex3->x; pFace->vertex[2].y=pVertex3->y; pFace->vertex[2].z=pVertex3->z; } void VertexBindn(FACE pFace, VERTEX pVertex1, VERTEX pVertex2, VERTEX pVertex3) { pFace.vertex[0].x=pVertex1.x; pFace.vertex[0].y=pVertex1.y; pFace.vertex[0].z=pVertex1.z; pFace.vertex[1].x=pVertex2.x; pFace.vertex[1].y=pVertex2.y; pFace.vertex[1].z=pVertex2.z; pFace.vertex[2].x=pVertex3.x; pFace.vertex[2].y=pVertex3.y; pFace.vertex[2].z=pVertex3.z; } void readstr(FILE *f,char *string) { do { fgets(string, 255, f); } while ((string[0] == ''/'') // (string[0] == ''\n'')); return; } void Create(SECTOR *pSector, char path[255]) { double fx, fy, fz, u, v; int fnumvertex; int fnumface; int fvertactu; int ffaceactu; FILE *filein; char oneline[255]; filein = fopen(path, "rt"); // File To Load World Data From readstr(filein,oneline); // sscanf(oneline, "i-mesh, Vertices: %o Faces: %o\n", &fnumvertex, &fnumface); sscanf(oneline, "Tri-mesh, Vertices: %d Faces: %d\n", &fnumvertex, &fnumface); //MessageBox(NULL,oneline,oneline,MB_OK); pSector->numvertex=fnumvertex; pSector->numface=fnumface; pSector->pVertex = new VERTEX[((pSector->numvertex)+1)]; pSector->pFace = new FACE[((pSector->numface)+1)]; //pSector->pVertex = new VERTEX[((pSector->numvertex))]; //pSector->pFace = new FACE[((pSector->numface))]; for(int loop=0; loop < pSector->numvertex;loop++) // Get Vertex into Sector { readstr(filein,oneline); sscanf(oneline, "Vertex %d: X: %f Y: %f Z: %f", &fvertactu, &fx, &fy, &fz); pSector->pVertex[fvertactu].x=fx; pSector->pVertex[fvertactu].y=fy; pSector->pVertex[fvertactu].z=fz; } int fver1,fver2,fver3,fake; for(int loop2=0; loop2 < pSector->numface;loop2++) // Get Faces into Sector { readstr(filein,oneline); sscanf(oneline, "Face %d: A:%d B:%d C:%d AB:%d BC:%d CA:%d", &ffaceactu, &fver1, &fver2, &fver3, &fake, &fake, &fake); VertexBindn(pSector->pFace[ffaceactu], pSector->pVertex[fver1], pSector->pVertex[fver2], pSector->pVertex[fver3]); } fclose(filein); return; } void DrawingStuff() { SECTOR *test=new SECTOR; Create(test,"data/model/bio.vfm"); glTranslatef(0.0f,0.0f,-50.0f); DrawSector(test); delete test; test=0; // .vfm is a renamed .asc }
(you can find me on IRC : #opengl on undernet)
Advertisement
where did u get the information for the asc file type?

~prevail by daring to fail~
Just export a model from 3D studio max to the ASC file format....then open the file with a word editor

This way you can see the values of each vertex, face, material, texture(U/V) etc etc etc.....

You don''t really need a file explaining the ASC format...you can just reed it yourself

Phantom
Yeah, that''s why it''s called asc :o) (ascii)

So, where''s the error ?
(you can find me on IRC : #opengl on undernet)
Still got no idea ???
(you can find me on IRC : #opengl on undernet)
i did notice oone thing while working on the asc importer you have 2 drawface(); functions!

~prevail by daring to fail~
Yeah, I do, one to draw a face with 3 vertex and one with the face, is there a problem about it ?

Edited by - SKSlayer on June 1, 2000 6:49:22 AM
(you can find me on IRC : #opengl on undernet)
being as computers are a bit thick how do they know whichone to choose?

~prevail by daring to fail~
It''s called function overloading. There are no problems as long as the inputs and returns to the function don''t match exactly (in other words the prototypes don''t match).

Morgan
Yeah, That is really cool

But, what about my asc importer
(you can find me on IRC : #opengl on undernet)

This topic is closed to new replies.

Advertisement