Results 1 to 3 of 3

Thread: ASC importer

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2000
    Posts
    8

    ASC importer

    Okay, here's the part of the source code that concert my asc importer . But it doesn't work (. Anyone can help ? No 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). Does anyone know why isn't this stuff working ?

    Code :
    [PRE]
     
    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 (x while(x {
    x=x+(r-1);
    }
     
    } else {
    x=x; // Already in range
    }
     
    return x;
    }
     
     
    void DrawFace(FACE pFace)
    {
    glBegin(GL_TRIANGLES); 
    glColor3d(((RANDOM_DOUBLE(0,100))/100),((RANDOM_DOUBLE(0,100))/100),((RANDOM_DOUBLE(0,100))/100)); // TEMPORARY RANDOM COLOR CODE
    glVertex3d(pFace.vertex[0].x,pFace.vertex[0].y,pFace.vertex[0].z);
    glColor3d(((RANDOM_DOUBLE(0,100))/100),((RANDOM_DOUBLE(0,100))/100),((RANDOM_DOUBLE(0,100))/100)); // TEMPORARY RANDOM COLOR CODE 
    glVertex3d(pFace.vertex[1].x,pFace.vertex[1].y,pFace.vertex[1].z);
    glColor3d(((RANDOM_DOUBLE(0,100))/100),((RANDOM_DOUBLE(0,100))/100),((RANDOM_DOUBLE(0,100))/100)); // TEMPORARY RANDOM COLOR CODE 
    glVertex3d(pFace.vertex[2].x,pFace.vertex[2].y,pFace.vertex[2].z);
     
    glEnd();
    }
     
    void DrawFace(VERTEX *pVertex1,VERTEX *pVertex2, VERTEX *pVertex3)
    {
    glBegin(GL_TRIANGLES);
    glColor3d(((RANDOM_DOUBLE(0,100))/100),((RANDOM_DOUBLE(0,100))/100),((RANDOM_DOUBLE(0,100))/100)); // TEMPORARY RANDOM COLOR CODE 
    glVertex3d(pVertex1->x,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", &amp;fnumvertex, &amp;fnumface);
    sscanf(oneline, "Tri-mesh, Vertices: %d Faces: %d\n", &amp;fnumvertex, &amp;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", &amp;fvertactu, &amp;fx, &amp;fy, &amp;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", &amp;ffaceactu, &amp;fver1, &amp;fver2, &amp;fver3, &amp;fake, &amp;fake, &amp;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
     
    }
    [/PRE]

  2. #2

    Re: ASC importer

    LOL you get around alot sky, im going to start work again on it. patients is a vertue

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2000
    Posts
    8

    Re: ASC importer

    huh ), yes I know.

Similar Threads

  1. Unreal importer bug
    By Zoltan in forum COLLADA
    Replies: 10
    Last Post: 11-12-2007, 03:02 AM
  2. maya 1.1 importer
    By joeante in forum COLLADA
    Replies: 1
    Last Post: 12-06-2004, 03:59 PM
  3. Maya Importer Bug
    By AndyM in forum COLLADA
    Replies: 3
    Last Post: 11-29-2004, 07:07 PM
  4. Writing .obj importer, please advise.
    By RobertSI in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-02-2001, 04:24 AM
  5. 3DSMAX ASCII Importer
    By gts2000 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 07-06-2000, 10:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean