Jump to content
  • Advertisement
Sign in to follow this  
Tokage

OpenGL Blender Models and OpenGL

This topic is 5203 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm writing a game in OpenGL (Win32, C++) and I want to include some models that have been constructed in Blender. I have essentially no experience in this area. I have tried to find a good tutorial on this subject but have failed. Does anyone know of some Web site somewhere that would explain how this is done?

Share this post


Link to post
Share on other sites
Advertisement
Hi!

You can create a plugin for blender using its python API. It's simple, and you can create an exporter for your model format very quickly.
You can also search in Google for an exporter for some format in particular. There are exporters for almost all formats.

Gretz,

Share this post


Link to post
Share on other sites
Thanks, I had thought about using the Python API for that, but I didn't think it was actually possible. I also need something to show me how to load and draw a model in OpenGL.

Share this post


Link to post
Share on other sites
There are exporters from Blender to various formats, including a few simple text formats. If you have Blender 2.34, you'll see a lot of these in the Export menu (they weren't bundled with earlier versions). You can download a few others on www.blender3d.com.

You can find tutorials on loading and displaying certain formats here.

Personally, though, I just ended up writing my own exporter in Python, to a very simple text format. I stared by modifying the AC3D script and the Wavefront OBJ script. My script is about 150 lines long and exports locations, normals, texture coordinates and bone names for each vertex, and materials and texture names for each face. The Python language is very simple, so it isn't hard at all to create your own script.

As for actually drawing the object, at the most basic level you just draw each triangle using glBegin(GL_TRIANGLE), glVertex3f, glNormal3f, etc. For a bit more speed, you can put your vertices into a vertex array, and the indices of the corners of each triangle in an index array, and then use glDrawElements. Also, if you have multiple materials and textures, group together vertices with the same material and texture so you switch states as little as possible.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!