Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Import and interpret 3D files

  1. #1
    Junior Member Regular Contributor
    Join Date
    Oct 2004
    Posts
    153

    Import and interpret 3D files

    i have been working on a game for some days...
    i programmed a interpreter for RTG and VRML files. Now i have a problem with dynamic arrays.
    My program reads a line and saves the result into a array. When i declare the array i don't know the number of elements of the array. I have to use dynamic arrays but the should be more dimensional
    x,y,z,frame

    So my question: does anybody know a interpreter of vrml 2.0 files or stuff like that.. i only need some short examples

    sorry for my bad english
    I hope y understand me....

    thanks

  2. #2
    Guest

    Re: Import and interpret 3D files

    This hasnt anything to do with OpenGL.

    You did not say what programming language you are using, nor which compiler. I assume you are talking about a modern C++ compiler, to solve your problem generate a STL vector that contains STL vectors as elements...

    Simple eh?

    In the future please just ask questions that are related to OpenGL and not basic coding.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Oct 2004
    Posts
    153

    Re: Import and interpret 3D files

    yes c++, in XCode and on MS Visual C++
    sorry

    thank you

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Kingston, ON, Canada
    Posts
    7

    Re: Import and interpret 3D files

    Don't be sorry, since when does loading 3D objects have nothing to do with opengl?

    Anyhow...

    You need to use structs. First you have one to define your vertex...

    typedef struct
    {
    float x, y, z;
    } VERTEX;

    Then you have a struct for your object...

    typedef struct
    {
    int verts;
    VERTEX *points;
    } OBJECT;

    You create something to hold your object info...

    OBJECT MyObject;

    Somewhere in your code you will read in your object file, find out how many vertices it has and store that in:

    MyObject->verts = NumberOfVertices

    Then allocate space for those vertices with...

    MyObject->points = (VERTEX*)malloc(sizeof(VERTEX)*MyObject->verts);

    Once you do this you can store and access your objects vertex info like so:

    MyObject->points[i].x
    MyObject->points[i].y
    MyObject->points[i].z

    ...where i equals the vertex you want, and you tack on a .x, .y or .z.

    If you wanted to do something with all the verts (like render them of course ) you would use a loop like so:

    for (i=0; i<MyObject->verts; i++) {
    // do stuff with...
    // MyObject->points[i].x
    // MyObject->points[i].y
    // MyObject->points[i].z
    }

    That's a very breif explanation, hope it helps.

  5. #5
    Junior Member Regular Contributor
    Join Date
    Oct 2004
    Posts
    153

    Re: Import and interpret 3D files

    Thank you.. i solved the problem... but anther problem:
    i also solved the problem with the texture mapping but does anybody know some tuts for UV mapping in opengl? How should i interpret the vrml/rtg to use the uv texture mapping?

    thanks!
    h.stony

  6. #6
    Junior Member Regular Contributor
    Join Date
    Oct 2004
    Posts
    153

    Re: Import and interpret 3D files

    My problem is solved! sorry for the sensless posting...my texturcoordinates were in a wrong order (the texture was flipped)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •