How can I import 3D models from 3D modelling software like MAYA into OpenGL especially for PC rather than for Iphone development ?
相关问题
- Is GLFW designed to use without LWJGL (in java)?
- glDrawElements only draws half a quad
- Scaling png font down
- OpenGL buffer update [duplicate]
- How does gl_ClipVertex work relative to gl_ClipDis
相关文章
- Converting glm::lookat matrix to quaternion and ba
- Algorithm for partially filling a polygonal mesh
- Robust polygon normal calculation
- Behavior of uniforms after glUseProgram() and spee
- Keep constant number of visible circles in 3D anim
- GLEW and Qt5 redefinition of headers
- How do I remove axis from a rotation matrix?
- How to smooth the blocks of a 3D voxel world?
Maya can export to various formats. Nowadays, mainly FBX is used because it's supported by many art packages.
If you're writing an application in c++, there's a FBX Api you can use to read fbx files: http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=7478532
I think XNA uses this sdk in the background in it's content pipeline. (If you're familiar with xna)
There is also a Python library which can be handy to extract just the data you need from the fbx file: http://download.autodesk.com/us/fbx/20112/FBX_SDK_HELP/files/WS73099cc142f48755-751de9951262947c01c-6dc7.htm
You could also write your own export script in Maya using python, but be aware that this is not a straightforward task.
I'm sure if you google a bit, you'll find importers for other formats like
.obj
which is also commonly used.Maybe this surprises you, but OpenGL has no such thing qualifying as "models". What OpenGL does is, it accepts a bunch of data and it is upon you to make OpenGL access this data so that the operations it performs on that data will result in a nice image on the screen.
So after that introduction, let's say you got a model, like a cube. A cube consists of 6 faces with 4 corners each. While each corner positions is shared by 3 faces each, the face direction, the so called Normal, is very different on that corner depending which face you're looking at. Position, Normal and a few other attributes form what is known as a vertex. Thus for a cube we have 6 * 4 = 24 vertices (capital position, lower normal)
And so on, I hope you get the idea. Each line forms a vertex vector. The format of this vector is arbitrary. You can place those attributes (Position, Normal, etc.) in one common, interleaved array, or you use multiple arrays for each attribute in its own array. Interleaved arrays oftenly are more efficient though.
Together with the list of vertices you also have a list of faces, i.e. tuple of vertex indices, which for a face, so in the case of a cube those tuples, designating quadrilaterals would be
Loading a model means, you write some program that reads the data from a model file format (preferably a documented one, or one you came up with yourself and wrote an exporter for your modelling program for). The read data is then placed into memory in such a way as outlined above so that OpenGL can make use of it.
You then supply this data to OpenGL. There are two options: You keep the data in your program's process address space (Client Side Vertex Arrays), or you upload the data into a OpenGL buffer object (Vertex Buffer Object).
Then you tell OpenGL to fetch its geometry data.
In the case of Client Side Vertex Arrays this is done in the following way
It is upon you to either implement the model loader yourself, or use some third party library for this task.