| 1 | //////////////////////////////////////////////////////////////////////////////// | 
|---|
| 2 | // material.h | 
|---|
| 3 | // Author     : Francesco Giordana | 
|---|
| 4 | // Start Date : January 13, 2005 | 
|---|
| 5 | // Copyright  : (C) 2006 by Francesco Giordana | 
|---|
| 6 | // Email      : fra.giordana@tiscali.it | 
|---|
| 7 | //////////////////////////////////////////////////////////////////////////////// | 
|---|
| 8 |  | 
|---|
| 9 | /********************************************************************************* | 
|---|
| 10 | *                                                                                * | 
|---|
| 11 | *   This program is free software; you can redistribute it and/or modify         * | 
|---|
| 12 | *   it under the terms of the GNU Lesser General Public License as published by  * | 
|---|
| 13 | *   the Free Software Foundation; either version 2 of the License, or            * | 
|---|
| 14 | *   (at your option) any later version.                                          * | 
|---|
| 15 | *                                                                                * | 
|---|
| 16 | **********************************************************************************/ | 
|---|
| 17 |  | 
|---|
| 18 | #ifndef _MATERIAL_H | 
|---|
| 19 | #define _MATERIAL_H | 
|---|
| 20 |  | 
|---|
| 21 | #include "mayaExportLayer.h" | 
|---|
| 22 | #include "paramList.h" | 
|---|
| 23 |  | 
|---|
| 24 | namespace OgreMayaExporter | 
|---|
| 25 | { | 
|---|
| 26 |  | 
|---|
| 27 |         typedef enum {MT_SURFACE_SHADER,MT_LAMBERT,MT_PHONG,MT_BLINN,MT_CGFX} MaterialType; | 
|---|
| 28 |  | 
|---|
| 29 |         typedef enum {TOT_REPLACE,TOT_MODULATE,TOT_ADD,TOT_ALPHABLEND} TexOpType; | 
|---|
| 30 |  | 
|---|
| 31 |         typedef enum {TAM_CLAMP,TAM_BORDER,TAM_WRAP,TAM_MIRROR} TexAddressMode; | 
|---|
| 32 |  | 
|---|
| 33 |         class Texture | 
|---|
| 34 |         { | 
|---|
| 35 |         public: | 
|---|
| 36 |                 //constructor | 
|---|
| 37 |                 Texture() { | 
|---|
| 38 |                         scale_u = scale_v = 1; | 
|---|
| 39 |                         scroll_u = scroll_v = 0; | 
|---|
| 40 |                         rot = 0; | 
|---|
| 41 |                         am_u = am_v = TAM_CLAMP; | 
|---|
| 42 |                 } | 
|---|
| 43 |                 //destructor | 
|---|
| 44 |                 ~Texture(){}; | 
|---|
| 45 |          | 
|---|
| 46 |                 //public members | 
|---|
| 47 |                 MString filename; | 
|---|
| 48 |                 MString absFilename; | 
|---|
| 49 |                 TexOpType opType; | 
|---|
| 50 |                 MString uvsetName; | 
|---|
| 51 |                 int uvsetIndex; | 
|---|
| 52 |                 TexAddressMode am_u,am_v; | 
|---|
| 53 |                 double scale_u,scale_v; | 
|---|
| 54 |                 double scroll_u,scroll_v; | 
|---|
| 55 |                 double rot; | 
|---|
| 56 |         }; | 
|---|
| 57 |  | 
|---|
| 58 |  | 
|---|
| 59 |         /***** Class Material *****/ | 
|---|
| 60 |         class Material | 
|---|
| 61 |         { | 
|---|
| 62 |         public: | 
|---|
| 63 |                 //constructor | 
|---|
| 64 |                 Material(); | 
|---|
| 65 |                 //destructor | 
|---|
| 66 |                 ~Material(); | 
|---|
| 67 |                 //get material name | 
|---|
| 68 |                 MString& name(); | 
|---|
| 69 |                 //clear material data | 
|---|
| 70 |                 void clear(); | 
|---|
| 71 |                 //load material data | 
|---|
| 72 |                 MStatus load(MFnDependencyNode* pShader,MStringArray& uvsets,ParamList& params); | 
|---|
| 73 |                 //load a specific material type | 
|---|
| 74 |                 MStatus loadSurfaceShader(MFnDependencyNode* pShader); | 
|---|
| 75 |                 MStatus loadLambert(MFnDependencyNode* pShader); | 
|---|
| 76 |                 MStatus loadPhong(MFnDependencyNode* pShader); | 
|---|
| 77 |                 MStatus loadBlinn(MFnDependencyNode* pShader); | 
|---|
| 78 |                 MStatus loadCgFxShader(MFnDependencyNode* pShader); | 
|---|
| 79 |                 //write material data to Ogre material script | 
|---|
| 80 |                 MStatus writeOgreScript(ParamList ¶ms); | 
|---|
| 81 |                 //copy textures to path specified by params | 
|---|
| 82 |                 MStatus copyTextures(ParamList ¶ms); | 
|---|
| 83 |         public: | 
|---|
| 84 |                 //load texture data | 
|---|
| 85 |                 MStatus loadTexture(MFnDependencyNode* pTexNode,TexOpType& opType,MStringArray& uvsets,ParamList& params); | 
|---|
| 86 |  | 
|---|
| 87 |                 MString m_name; | 
|---|
| 88 |                 MaterialType m_type; | 
|---|
| 89 |                 MColor m_ambient, m_diffuse, m_specular, m_emissive; | 
|---|
| 90 |                 bool m_lightingOff; | 
|---|
| 91 |                 bool m_isTransparent; | 
|---|
| 92 |                 bool m_isTextured; | 
|---|
| 93 |                 bool m_isMultiTextured; | 
|---|
| 94 |                 std::vector<Texture> m_textures; | 
|---|
| 95 |         }; | 
|---|
| 96 |  | 
|---|
| 97 | };      //end of namespace | 
|---|
| 98 |  | 
|---|
| 99 | #endif | 
|---|