Results 1 to 7 of 7

Thread: Writing to a file

  1. #1
    Member Contributor
    Join Date
    Oct 2002
    Posts
    55

    Writing to a file

    Alright, i imported verticies, faces, and normals from a .ase file, and now i want to spit them out into my own (.dan) file... but, when its writing the normals to the file, it stops early... for no reason... it just stops writing... like, in the middle of a line... I have a for() loop to get thru all the normals (in a class)... and then when it gets to like the last 1.. it displays only the x,y coords, no z.... but if i stop it sooner, it just writes part of the next line... should be "misslemodel (missle)". It only writes "misslemod".. but the part where it writes that line, is all in one fprintf() line...
    Any ideas? Can windows only write so much, or so many chars to a .txt file? (.dan)??
    Thanks in advance,
    Dan Sherman

  2. #2
    Senior Member Regular Contributor
    Join Date
    Oct 2002
    Location
    King George, Virginia
    Posts
    132

    Re: Writing to a file

    post some code. w/out seeing your code, no one can really help you.

    jebus

  3. #3
    Member Contributor
    Join Date
    Oct 2002
    Posts
    55

    Re: Writing to a file

    Sorry, at home right now, code at school... it'll be up tomorrow... Check back for me?

  4. #4
    Member Contributor
    Join Date
    Oct 2002
    Posts
    55

    Re: Writing to a file

    fprintf(s, "#ifndef vect1\ntypedef float vect1;\n#endif\n\n#ifndef vect3\ntypedef vect1 vect3[3];\n#endif\n\n#ifndef triangle\ntypedef vect1 triangle[3];\n#endif\n\n");
    fprintf(s, "#ifndef %smodel\ntypedef struct\n{\n", mn);
    fprintf(s, "\tvect3 verticies[%i] = {\n\t", p->numVertex);
    for (int a=0; a<(p->numVertex-1); a++){
    fprintf(s, "{%f,%f,%f}, ", p->verts[a][0], p->verts[a][1], p->verts[a][2]);
    if (a%2 == 0){
    fprintf(s, "\n\t");
    }
    }
    fprintf(s, "{%f,%f,%f}};\n", p->verts[p->numVertex-1][0], p->verts[p->numVertex-1][1], p->verts[p->numVertex-1][2]);

    fprintf(s, "\ttriangle faces[%i] = {\n\t", p->numFaces);
    for (a=0; a<(p->numFaces-1); a++){
    fprintf(s, "{%i,%i,%i}, ", p->faces[a].vertIndex[0], p->faces[a].vertIndex[1], p->faces[a].vertIndex[2]);
    if (a%2 == 0){
    fprintf(s, "\n\t");
    }
    }
    fprintf(s, "{%i,%i,%i}};\n", p->faces[p->numFaces-1].vertIndex[0], p->faces[p->numFaces-1].vertIndex[1], p->faces[p->numFaces-1].vertIndex[2]);

    fprintf(s, "\tvect3 facenormal[%i] = {\n\t", p->numFaces);
    for (a=0; a<(p->numFaces-14); a++){
    fprintf(s, "{%f,%f,%f}, ", p->faces[a].normal[0][0], p->faces[a].normal[0][1], p->faces[a].normal[0][2]);
    if (a%2 == 0){
    fprintf(s, "\n\t");
    }
    }

    the output from this section looks like this (importing a cube from .ase)
    OK, WTF, i run my program on a huge .ase file, and the above happens... i run it on a cube... and it exports NOTHING, absolutly NOTHING...

  5. #5
    Member Contributor
    Join Date
    Oct 2002
    Posts
    55

    Re: Writing to a file

    wierd, after bugging around with it... my order of opps is
    Read in;
    Export to file;
    display model;
    If i take out the Displaying.. it runs fine, and exports everything...
    but if i leave in the displaying... it stops short on the exporting.. even though the whole export function is called before the display is ever even mentioned...

  6. #6
    Senior Member Regular Contributor
    Join Date
    Oct 2002
    Location
    King George, Virginia
    Posts
    132

    Re: Writing to a file

    are you flushing your buffer and closing the file before you display? do you need the file open for some reason after you've written it?

    jebus

  7. #7
    Member Contributor
    Join Date
    Oct 2002
    Posts
    55

    Re: Writing to a file

    Aha, never closed the file... that prolly has something to do with it...
    Lol, just leaving school now... ill do it tomorrow.. thanks a ton man!

Similar Threads

  1. Writing out a FBO to image file issues
    By JohnMarkem in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 07-30-2014, 02:49 PM
  2. Writing a pbm file from buffer
    By mark g in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-26-2010, 04:49 AM
  3. Writing an AVI file of my openGL window
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-25-2003, 01:23 AM
  4. writing display lists to file
    By Trouvist in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 09-04-2000, 06:16 PM
  5. Writing OpenGL images into a PostScript File
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-28-2000, 10:39 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