Bright Ideas Software - Calculus Visualization Tools Click here to return to the BIS Home Page.

GLE32 Ver. 4 Manual

  Skip Navigation Links
Math ToolsExpand Math Tools
DevelopersExpand Developers
About BISExpand About BIS
  Skip Navigation LinksHome --> Developers --> GLE32 Version 4 --> GLE32 Manual --> MilkShape3D Model Class Search:
Skip Navigation Links

Skip Navigation Links

OpenGL® and OpenGL|ES are trademarks of Silicon Graphics, Inc.




MilkShape3D Model Class

MilkShape3D is a low-poly 3D modeling program written by Mete Ciragan. It can be found at www.milkshape3d.com. This class was based on Ver. 1.8.2 of the MilkShape SDK, released on 25 October 2007. While model loader classes are common, this one stands out in a few respects:

  • Mesh data is reorganized and rendered with glDrawArrays instead of discreet normal/texture coordinate/vertex calls;
  • Meshes are rendered sorted by material, potentially reducing the number of material changes and increasing rendering efficiency;
  • Support is provided for an app-supplied callback function that can be used to set material parameters (or override those stored with the model) for each mesh at run-time;
  • All bone and joint data required for animation is loaded and made available at run-time;
  • Models can be loaded from files or embedded resources;
  • Flexible system for associating run-time texture handles with design-time file/texture names.

The method for loading models from embedded resources assumes the model is stored as resource type 'MODEL'. See the 2D Texture class for a more complete discussion of loading embedded resources.

The following data structures encapsulate the raw model data:


struct CMilkShapeVertex
 
  unsigned char m_Flags
  float m_VertPos[3]
  char m_BoneID
  unsigned char m_ReferenceCount
struct CMilkShapeTriangle
 
  unsigned short m_Flags
  unsigned short m_VertexIndices[3]
  float m_VertexNormals[3][3]
  float m_TextureS[3]
  float m_TextureT[3]
  unsigned char m_SmoothingGroup
  unsigned char m_MeshIndex

struct CMilkShapeMesh
 
  unsigned char m_Flags
  char m_Name[32]
  unsigned short m_NumTriangles
  unsigned short* m_ptrTriangleIndices
  char m_MaterialIndex
 
 
  float* m_ptrTexCoords
  float* m_ptrNorms
  float* m_ptrVerts
struct CMilkShapeMaterial
 
  char m_Name[32]
  float m_Ambient[4]
  float m_Diffuse[4]
  float m_Specular[4]
  float m_Emissive[4]
  float m_Shininess
  float m_Transparency
  char m_Mode
  char m_TextureName[128]
  char m_AlphaMapName[128]
 
  int m_TexIndex

struct CMilkShapeKeyFrameRot
 
  float m_fTime
  float m_fRotation[3]
struct CMilkShapeKeyFrameTrans
 
  float m_fTime
  float m_fPosition[3]

struct CMilkShapeComment
 
  int m_Index
  int m_CommentLength
  char* m_ptrComment
struct CMilkShapeJoint
 
  BYTE m_Flags
  char m_Name[32]
  char m_ParentName[32]
  float m_Rotation[3]
  float m_Position[3]
  unsigned short m_NumRotations
  unsigned short m_NumTranslations
  CMilkShapeKeyFrameRot* m_ptrRotations
  CMilkShapeKeyFrameTrans* m_ptrTranslations

struct CMilkShapeVertexEx
 
  char m_BoneIds[3]
  BYTE m_Weights[3]
  unsigned int m_Extra
struct CMilkShapeModelEx
 
  float m_fJointSize
  int m_iTransparencyMode
  float m_fAlphaRef

struct CMilkShapeJointEx
 
  float m_Color[3]
struct CMilkShapeAABB
 
  float m_fMin[3]
  float m_fMax[3]

CgleMilkShapeModel

Methods

  

Description

 CgleMilkShapeModel ()   
virtual ~CgleMilkShapeModel ()   
 
BOOL LoadFromFile (char* fileName)  Load a file containing a single model.
BOOL LoadFromResource (HINSTANCE hAppInst, UINT ResID)  Load a model stored as an embedded resource. See above and the 2D Texture class for more information.
 
void AddTextureIndexToMap (char* texName, int texIndex)  Add the design-time texture file name and the run-time texture handle to a map so the materials can locate the correct texture at run-time.
void UpdateMaterialTextureIndices ()  Iterates through the materials and searches the texture index map for the handle associated with it's design-time texture file name. Call this after loading the texture indices w/ AddTextureIndexToMap, but before drawing.
 
void SetDrawCallback (DrawCallBack pfnCallBack)  This allows the user to define a callback function that wikk be called at the beginning of each mesh's rendering pass. This can be used to refine or override the material/texture information stored in the model file. The callback function prototype must have a void return type, accept as itr's single parameter a point to a CMilkShapeMesh object, and use the WINAPI macro to define it's calling convention; e.g., 'void WINAPI MeshCallBack(CMilkShapeMesh* mesh)'.
 
void SetUseCompiledVertexArrays (BOOL value)  The class can optionally use the GL_EXT_compiled_vertex_array extension. The application is responsible for first initializing the API (see InitializeCompiledArrays).
BOOL GetUseCompiledVertexArrays ()   
 
void BuildVertexArrays (char* meshName, BOOL bForceFlatShadedNormals = FALSE)  It is not normally necessary to call this; it is called internally as the model is loaded. If you want to override the MilkShape - generated normals and create true flat-shaded normals, this function is provided.
 
float GetAnimationFPS ()   
void SetAnimationFPS (float value)   
 
float GetAnimationCurrentTime ()   
void SetAnimationCurrentTime (float value)   
 
int GetAnimationFrameCount ()   
void SetAnimationFrameCount (int value)   
 
void Draw ()   
void DrawMesh (int index, BOOL bUseTexCoords)   
void DrawMesh (char* meshName, BOOL bUseTexCoords)   
 
int GetVertexCount ()   
CMilkShapeVertex* GetVertexPtr (int index)   
int GetVertexExVersion ()   
CMilkShapeVertexEx* GetVertexExPtr()   
 
int GetTriangleCount ()   
CMilkShapeTriangle* GetTrianglePtr (int index)   
 
int GetMeshCount ()   
CMilkShapeMesh* GetMeshPtr (char* meshName)   
CMilkShapeMesh* GetMeshPtr (int index)   
 
int GetMaterialCount ()   
CMilkShapeMaterial* GetMaterialPtr (char* materialName)   
CMilkShapeMaterial* GetMaterialPtr (int index)   
 
int GetJointCount ()   
CMilkShapeJoint* GetJointPtr (char* jointName)   
CMilkShapeJoint* GetJointPtr (int index)   
int GetJointExVersion ()   
CMilkShapeJointEx* GetJointExPtr (int index)   
 
int GetGroupCommentCount ()   
CMilkShapeComment* GetGroupCommentPtr (int index)   
 
int GetMaterialCommentCount ()   
CMilkShapeComment* GetMaterialCommentPtr (int index)   
 
int GetJointCommentCount ()   
CMilkShapeComment* GetJointCommentPtr (int index)   
 
CMilkShapeComment* GetModelCommentPtr ()   
 
CMilkShapeAABB* GetAABB ()   

Back To Top



Copyright© 2001-2010 by Bright Ideas Software®. All rights reserved.