Importing Models Into A OpenGL Project

后端 未结 4 812
别那么骄傲
别那么骄傲 2021-02-04 08:41

I am taking an OpenGL course and we have the option to create models to use in our assignments with a 3D modeling application, like Maya or Blender.

I am not

相关标签:
4条回答
  • 2021-02-04 09:02

    One of the simplest formats that can be used to export meshes is Wavefront OBJ (please search for it on Wikipedia as I'm only allowed to post one link at the moment). It's basically a text file that shouldn't be too hard to parse.

    Or actually, if you're allowed to use GLUT, you could try and use its loader (as answered in OpenGL FAQ 24.040)

    Don't worry about the object scale at the moment, you can always scale your object later. Just make sure you export it with local coordinates, not global (e.g. [0,0,0] should be the center of the object, not the world you're modelling).

    0 讨论(0)
  • 2021-02-04 09:09

    I'd say that the Obj format is a good balance for readability and functionality if you want to parse it yourself.

    http://en.wikipedia.org/wiki/Obj

    The easiest way would to be to find a library to do it for you but the possibilities would be limited to your chosen language.

    You shouldn't be worrying about scale. OpenGL's matrices can easily rescale vertices.

    0 讨论(0)
  • 2021-02-04 09:10

    I'd suggest not worrying about the scale of the objects for right now.

    Now, the thing you're going to have to do is settle on a format for the 3D file. There are MANY options when exporting from a 3D program like Maya or Blender.

    Might I recommend attempting a simple COLLADA importer. Specification information is here: http://www.khronos.org/files/collada_spec_1_4.pdf

    Another spec I've been using lately would also probably be suitable for this is OBJ.

    The specification for OBJ is located here: http://local.wasp.uwa.edu.au/~pbourke/dataformats/obj/

    Also, there are several free sample 3D OBJ files located here. This will allow you to see the format of the files and really see how easy they can be to parse.

    Keep in mind, OBJ can not support animation, and it is rather inefficient for rendering large scenes.

    0 讨论(0)
  • 2021-02-04 09:22

    Blender can save files in .obj format, and a simple google search turns up several libraries for loading this into OpenGL. Here is one.

    0 讨论(0)
提交回复
热议问题