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
a- Study the .X format
b- Study the .obj format
c- write a loader for .x file
d- write a writer for .obj file
If you want the base things (vertex, normal and faces) both format are trivial and you can find loader and writer easily.
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:
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.
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.
Here is an online script to convert an OBJ text file to C++/OpenGL source code :
After convert opengl file. how to run the program. any example.
I have to convert obj to c++/opengl used by jeffproc.com resources, how to run convert code through visuals studio. any example program.
I did it.
Sample code for visual C++ available on :
NB : it is based on NeHe’s lesson 06