1 | /*
|
---|
2 | ============================================================================
|
---|
3 | This source file is part of the Ogre-Maya Tools.
|
---|
4 | Distributed as part of Ogre (Object-oriented Graphics Rendering Engine).
|
---|
5 | Copyright (C) 2003 Fifty1 Software Inc., Bytelords
|
---|
6 |
|
---|
7 | This program is free software; you can redistribute it and/or
|
---|
8 | modify it under the terms of the GNU General Public License
|
---|
9 | as published by the Free Software Foundation; either version 2
|
---|
10 | of the License, or (at your option) any later version.
|
---|
11 |
|
---|
12 | This program is distributed in the hope that it will be useful,
|
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | GNU General Public License for more details.
|
---|
16 |
|
---|
17 | You should have received a copy of the GNU General Public License
|
---|
18 | along with this program; if not, write to the Free Software
|
---|
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
20 | or go to http://www.gnu.org/licenses/gpl.txt
|
---|
21 | ============================================================================
|
---|
22 | */
|
---|
23 | #ifndef _OGREMAYA_MAT_H_
|
---|
24 | #define _OGREMAYA_MAT_H_
|
---|
25 |
|
---|
26 | #include "OgreMayaCommon.h"
|
---|
27 |
|
---|
28 | #include <maya/MFnMesh.h>
|
---|
29 |
|
---|
30 | #include <fstream>
|
---|
31 |
|
---|
32 | #include <string>
|
---|
33 | #include <list>
|
---|
34 | #include <vector>
|
---|
35 |
|
---|
36 | namespace OgreMaya {
|
---|
37 |
|
---|
38 | // using namespace std;
|
---|
39 | using std::string;
|
---|
40 | using std::list;
|
---|
41 | using std::vector;
|
---|
42 |
|
---|
43 | struct TextureUnitState {
|
---|
44 |
|
---|
45 | TextureUnitState(string textureName, int uvSet):
|
---|
46 | textureName(textureName), uvSet(uvSet) {}
|
---|
47 |
|
---|
48 | string textureName;
|
---|
49 | int uvSet;
|
---|
50 | };
|
---|
51 |
|
---|
52 | typedef list<TextureUnitState> TextureLayerList;
|
---|
53 |
|
---|
54 |
|
---|
55 | struct Material {
|
---|
56 |
|
---|
57 | string name;
|
---|
58 | string shadingMode;
|
---|
59 |
|
---|
60 | ColourValue ambient;
|
---|
61 | ColourValue diffuse;
|
---|
62 | ColourValue selfIllumination;
|
---|
63 | ColourValue specular;
|
---|
64 |
|
---|
65 | Real shininess;
|
---|
66 |
|
---|
67 | TextureLayerList textureLayers;
|
---|
68 | };
|
---|
69 |
|
---|
70 | // ===========================================================================
|
---|
71 | /** \class MatGenerator
|
---|
72 | \author John Van Vliet, Fifty1 Software Inc.
|
---|
73 | \version 1.0
|
---|
74 | \date June 2003
|
---|
75 |
|
---|
76 | Generates an Ogre material file from a Maya scene.
|
---|
77 | */
|
---|
78 | // ===========================================================================
|
---|
79 | class MatGenerator {
|
---|
80 | public:
|
---|
81 |
|
---|
82 | /// Utility function for other classes
|
---|
83 | /// \return Name of the material attached to the given mesh
|
---|
84 | static MString getMaterialName(MFnMesh &fnMesh);
|
---|
85 |
|
---|
86 | /// Standard constructor.
|
---|
87 | MatGenerator();
|
---|
88 |
|
---|
89 | /// Destructor.
|
---|
90 | virtual ~MatGenerator();
|
---|
91 |
|
---|
92 | /// Export the complete Maya scene (called by OgreMaya.mll or OgreMaya.exe).
|
---|
93 | bool exportAll();
|
---|
94 |
|
---|
95 | /// Export selected parts of the Maya scene (called by OgreMaya.mll).
|
---|
96 | bool exportSelection();
|
---|
97 |
|
---|
98 | protected:
|
---|
99 | vector<Material*> materials;
|
---|
100 |
|
---|
101 | bool _extractMaterials();
|
---|
102 | void _makeMaterials(MObject &ShaderSet);
|
---|
103 | Material* _makePhongMaterial(MObject &ShaderNode);
|
---|
104 | Material* _makeBlinnMaterial(MObject &ShaderNode);
|
---|
105 | Material* _makeLambertMaterial(MObject &ShaderNode);
|
---|
106 | };
|
---|
107 |
|
---|
108 | } // namespace OgreMaya
|
---|
109 |
|
---|
110 | #endif
|
---|