Getting GLM

First of all what is GLM? Glm is a library that was provided in the examples folder of the GLUT source distribution. Basically it reads a Wavefront .OBJ file and knows how to draw it on the screen exactly the way it looked in 3D Studio Max. Well actually it can do a lot more....lots of calculations, reading material files from 3DS Max....

 The original files don't have the notion of multiple textures. What I mean is that you load a file, set a texture yourself in opengl and then call the draw function from GLM to put it on the screen textured. Now that is fine as long as what you are loading is not actualy a big scene with dosens of object each in need of a different texture. There would be the solution of exporting each object from your scene separatly but this could be a pain when you want to position them in the scene. 

 So I modified GLM and added a texture field for each model and material and made sure it was going to render them correctly. When you export from 3D Studio Max you also get a .MTL file that defines materials for objects in your scene. A material difines the properties of an object like how the light is going to fall on it (is it going to shine....what's it's color) and what texture it has. All this information is exported in the .MTL file so all we need to do is parse it. Luckily GLM allready knew how to parse MTL files so I only had to add understanding of textures.

The packedge containes 5 file:

  • glm.cpp - The code that manipulates 3D models
  • glm.h - The headers you will need to include in your project
  • glmimg.cpp - A small image and texture manipulation library (this is where the textures are binded to opengl)
  • Texture.cpp - A TGA texture loader
  • Texture.h - The headers for the TGA loader

 Download the new GLM 

All you have to do is copy these files in your project and use 2-3 function to display a beautiful 3DS Max model in your application 

Download the old original GLM for comparison or curiosity 

 
Copyright © 2010 Tudor Carean. All Rights Reserved.