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 10 of 10

Thread: Convert from .X or .OBJ to openGL in C++

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2009
    Posts
    11

    Convert from .X or .OBJ to openGL in C++

    hiii
    i have a model in 3d max and a sample model from Maya, and i would like to convert it to opengl code in C++
    is there a possiblity to do that or no way at all and what do i need or is there a guide to do that
    thank you

  2. #2
    Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    356

    Re: Convert from .X or .OBJ to openGL in C++

    a- Study the .X format
    b- Study the .obj format
    c- write a loader for .x file
    d- write a writer for .obj file
    Job done.

    If you want the base things (vertex, normal and faces) both format are trivial and you can find loader and writer easily.
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2006
    Posts
    2

    Re: Convert from .X or .OBJ to openGL in C++

    The situation with OBJ is more simple, but there are some quirks you will need to handle. For example there were parts of objects with inverted faces.

    The X format is more complicated. The Maya XExporter() MEL script isn't writing D3D compliant X files, but it is possible to make an importer specifically for that exporter.

    I have importers for both the Maya OBJ and X exported models written in Java here:
    http://code.google.com/p/vlengine/source.../ObjLoader.java
    http://code.google.com/p/vlengine/source.../x/XLoader.java

  4. #4
    Advanced Member Frequent Contributor scratt's Avatar
    Join Date
    May 2008
    Location
    Thailand
    Posts
    556

    Re: Convert from .X or .OBJ to openGL in C++

    FWIW there are a lot of solutions out there for loading .3DS files.

    Working with various formats over the years I have looked at this many times, and much as I hate the .3DS format virtually everything will export to it...

    Most times if you look at the data you can see that all of it is there but often things like the rotation is wrong, or the UV coordinates are swapped in V when you put it through most import and export processes to get it to .3DS.

    Luckily these things are generally easy to solve by swapping, rotating, or otherwise altering the data with a modified .3DS loader.

    For this reason to date I have found the path of least resistance is to get things to .3DS and then import into projects from there with a small text header file which details the model to be loaded and any alterations to be made to it by your loader.

    Just my 2c.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    Re: Convert from .X or .OBJ to openGL in C++

    Also the free Autodesk FBX SDK has tools for importing/exporting all their various formats in addition to Collada dae. You can use it to load and traverse a model's data, neatly and conveniently bypassing the rigmarole of proprietary format specifics.

    Not much help with the 'X' format I'm afraid.

  6. #6

    Re: Convert from .X or .OBJ to openGL in C++

    Here is an online script to convert an OBJ text file to C++/OpenGL source code :
    http://www.jeffprod.com/obj2opengl.php?setlang=en

  7. #7
    Intern Newbie
    Join Date
    Apr 2002
    Location
    CO, USA
    Posts
    41

    Re: Convert from .X or .OBJ to openGL in C++

    Take a look at Open Asset Import Library. It looks like supports the file formats you need.
    Orhun Birsoy

  8. #8
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    10

    Re: Convert from .X or .OBJ to openGL in C++

    Hi Tazeg,

    After convert opengl file. how to run the program. any example.

  9. #9
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    10

    Re: Convert from .X or .OBJ to openGL in C++

    Hi Tazeg,

    I have to convert obj to c++/opengl used by jeffproc.com resources, how to run convert code through visuals studio. any example program.

    thanks,
    regards,

  10. #10

    Re: Convert from .X or .OBJ to openGL in C++

    I did it.
    Sample code for visual C++ available on :
    http://www.jeffprod.com/obj2opengl.php?setlang=en

    NB : it is based on NeHe's lesson 06
    http://nehe.gamedev.net/tutorial/les..._update/47002/

Posting Permissions

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