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: How load a 3d model

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2004
    Posts
    8

    How load a 3d model

    I need help to load a 3d model

    the file format is:

    x y z

    0 0 0
    0 1 0 -> a rectangle
    1 1 0
    1 0 0

    0 x x
    0 x -> another rectangle

    ....

    0 0 0
    0 ... -> n rectangles

    please can me help :'(

  2. #2
    Intern Newbie
    Join Date
    Mar 2004
    Location
    Sheffield, Yorkshire, UK
    Posts
    31

    Re: How load a 3d model

    It'd help if you told us what language you're working in, and whether the file you're trying to load is binary or text.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2004
    Posts
    8

    Re: How load a 3d model

    I am programin in Dev C++ , and is a text file .

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    570

    Re: How load a 3d model

    assuming you know how to parse a text file:

    you'll probably need to scan the text file a total of 2 times.

    The first time counting the number of rectangles you have. keep a running sum of those.
    after the first pass you'll need to allocate an array of 3D point structures of size num_rectangles*4 (4 vertices to each rectangle). after that you need to scan the file again reading in the vertices into your vertex array.

    now you have all your vertices in a vertex array.

    look up using vertex arrays and pass this to a glDrawArrays function to draw your 3D model.

    cheers!

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2004
    Posts
    8

    Re: How load a 3d model

    Thanks for the help

  6. #6
    Intern Newbie
    Join Date
    Mar 2004
    Location
    Poland
    Posts
    31

    Re: How load a 3d model

    You may not scan file, but check it's size. If every rectangle is written with same number of bytes, it would be easy to count number of rectangles.

    The other way to load this file is loading rectangles to a stack (with counting them). Then you will not need to load bytes from file twice.
    One star? I am learning, and not giving bad advices. So: WHY?

Posting Permissions

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