~ubuntu-branches/ubuntu/wily/opencollada/wily

« back to all changes in this revision

Viewing changes to COLLADAMax/include/COLLADAMaxMaterialCreator.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2015-05-14 17:23:27 UTC
  • Revision ID: package-import@ubuntu.com-20150514172327-f862u8envms01fra
Tags: upstream-0.1.0~20140703.ddf8f47+dfsg1
ImportĀ upstreamĀ versionĀ 0.1.0~20140703.ddf8f47+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 2008-2009 NetAllied Systems GmbH
 
3
 
 
4
This file is part of COLLADAMax.
 
5
 
 
6
Portions of the code are:
 
7
Copyright (c) 2005-2007 Feeling Software Inc.
 
8
Copyright (c) 2005-2007 Sony Computer Entertainment America
 
9
 
 
10
Based on the 3dsMax COLLADASW Tools:
 
11
Copyright (c) 2005-2006 Autodesk Media Entertainment
 
12
 
 
13
Licensed under the MIT Open Source License, 
 
14
for details please see LICENSE file or the website
 
15
http://www.opensource.org/licenses/mit-license.php
 
16
*/
 
17
 
 
18
#ifndef __COLLADAMAX_MATERIALCREATOR_H__
 
19
#define __COLLADAMAX_MATERIALCREATOR_H__
 
20
 
 
21
#include "COLLADAMaxPrerequisites.h"
 
22
#include "COLLADAMaxImporterBase.h"
 
23
 
 
24
 
 
25
namespace COLLADAMax
 
26
{
 
27
 
 
28
    /** Creates and assigns all material previously been stored by the material and affect importers.*/
 
29
        class MaterialCreator : public ImporterBase 
 
30
        {
 
31
        public:
 
32
                /** A struct that uniquely identifies material created in Max.*/
 
33
                struct MaterialIdentifier
 
34
                {
 
35
                        MaterialIdentifier();
 
36
                        enum SlotFlags
 
37
                        {
 
38
                                NONE        = 0,
 
39
                                AMBIENT     = 1,
 
40
                                DIFFUSE     = 1<<1,
 
41
                                SPECULAR    = 1<<2,
 
42
                                SHININESS   = 1<<3,
 
43
                                EMISSION    = 1<<4,   //self-illumination
 
44
                                OPACITY     = 1<<5,
 
45
                                BUMP        = 1<<6
 
46
                        };
 
47
 
 
48
                        /** The unique id of the frame work effect this material has been created from.*/
 
49
                        COLLADAFW::UniqueId effectUniqueId;
 
50
 
 
51
                        /** Flags indication which slot uses a max channel.*/
 
52
                        unsigned char slotFlags;
 
53
 
 
54
                        unsigned char ambientMapChannel;
 
55
                        unsigned char diffuseMapChannel;
 
56
                        unsigned char specularMapChannel;
 
57
                        unsigned char shininessMapChannel;
 
58
                        unsigned char emissionMapChannel;
 
59
                        unsigned char opacityMapChannel;
 
60
 
 
61
                        unsigned char bumpMapChannel;
 
62
 
 
63
                        bool operator<( const MaterialIdentifier& rhs ) const;
 
64
                };
 
65
 
 
66
                /** Maps framework effects to max materials.*/
 
67
                typedef std::map<MaterialIdentifier, Mtl*> MaterialIdentifierMaxMaterialMap;
 
68
        private:
 
69
 
 
70
                /** Maps all the framework effects already created a max material for, to the max 
 
71
                material.*/
 
72
                MaterialIdentifierMaxMaterialMap mMaterialIdentifierMaxMaterialMap;
 
73
 
 
74
        public:
 
75
 
 
76
        /** Constructor. */
 
77
                MaterialCreator( DocumentImporter* documentImporter );
 
78
 
 
79
        /** Destructor. */
 
80
                virtual ~MaterialCreator();
 
81
 
 
82
                /** Performs the creation of all material.
 
83
                @return True on success, false otherwise.*/
 
84
                bool create();
 
85
 
 
86
                /** Creates all the material referenced in @a materialBinding, if not already created and 
 
87
                assigns them to the node in @a materialBinding.*/
 
88
                bool createAndAssingMaxMaterial( const DocumentImporter::NodeMaterialBindingsPair& materialBinding );
 
89
 
 
90
                /** Creates a standard material from @a effectCommon.*/ 
 
91
                StdMat2* createStandardMaterial( const COLLADAFW::EffectCommon& effectCommon, const String& name, const MaterialCreator::MaterialIdentifier& materialIdentifier, const EffectMaps* extraEffectMaps);
 
92
 
 
93
                /** Creates a material from @a effect.*/
 
94
                Mtl* createMaxMaterial( const COLLADAFW::Effect& effect, const MaterialCreator::MaterialIdentifier& materialIdentifier);
 
95
 
 
96
                /** Returns the material created for @a effect. If for the same effect a max material has already been 
 
97
                created for, the formally created one is returned, otherwise a new one is created.*/
 
98
                Mtl* getMaxMaterial( const COLLADAFW::Effect& effect, const COLLADAFW::MaterialBinding& materialBinding, const COLLADAFW::UniqueId& geometryUniqueId );
 
99
 
 
100
                /** Returns the effect used by @a materialBinding. It resolves first the material and than the effect.
 
101
                If the effect could not be resolved, null is returned.*/
 
102
                const COLLADAFW::Effect* getEffect( const COLLADAFW::MaterialBinding& materialBinding );
 
103
 
 
104
                /** Returns the MaterialIdentifierMaxMaterialMap.*/
 
105
                const MaterialIdentifierMaxMaterialMap& getMaterialIdentifierMaxMaterialMap() const { return mMaterialIdentifierMaxMaterialMap; }
 
106
 
 
107
        private:
 
108
 
 
109
        /** Disable default copy ctor. */
 
110
                MaterialCreator( const MaterialCreator& pre );
 
111
 
 
112
        /** Disable default assignment operator. */
 
113
                const MaterialCreator& operator= ( const MaterialCreator& pre );
 
114
 
 
115
                /** Creates a max texture from the frame work texture @a texture.*/
 
116
                BitmapTex* createTexture( const COLLADAFW::EffectCommon& effectCommon, const COLLADAFW::Texture& texture );
 
117
 
 
118
                BitmapTex* createTexture( const COLLADAFW::EffectCommon& effectCommon, const COLLADAFW::SamplerID& samplerId );
 
119
 
 
120
                /** Assigns @a texture to @a slot of @a material.*/
 
121
                void assignTextureToMaterial(  Mtl* material, int slot, BitmapTex* texture);
 
122
        
 
123
        void createAndAssignTexture( Mtl* material, const COLLADAFW::EffectCommon& effectCommon, const COLLADAFW::ColorOrTexture& (COLLADAFW::EffectCommon::*f)()const, int slot, unsigned char mapChannel);
 
124
 
 
125
                void handleExtraEffectMaps( const EffectMaps* extraEffectMaps, Mtl* material, const COLLADAFW::EffectCommon& effectCommon, const MaterialCreator::MaterialIdentifier& materialIdentifier );
 
126
 
 
127
 
 
128
                /** Sets the vertex color flag for all nodes that use vertex color.*/
 
129
                void setVertexColorFlag();
 
130
 
 
131
 
 
132
        };
 
133
 
 
134
} // namespace COLLADAMAX
 
135
 
 
136
#endif // __COLLADAMAX_MATERIALCREATOR_H__