FCDocument/FCDEffectStandard.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2006 Feeling Software Inc.
00003     MIT License: http://www.opensource.org/licenses/mit-license.php
00004 */
00005 /*
00006     Based on the FS Import classes:
00007     Copyright (C) 2005-2006 Feeling Software Inc
00008     Copyright (C) 2005-2006 Autodesk Media Entertainment
00009     MIT License: http://www.opensource.org/licenses/mit-license.php
00010 */
00011 
00017 #ifndef _FCD_MATERIAL_STANDARD_H_
00018 #define _FCD_MATERIAL_STANDARD_H_
00019 
00020 #include "FUtils/FUDaeEnum.h"
00021 #include "FCDocument/FCDEffectProfile.h"
00022 
00023 class FCDocument;
00024 class FCDEffect;
00025 class FCDEffectParameter;
00026 class FCDTexture;
00027 class FCDEffectParameterList;
00028 
00030 typedef vector<FCDTexture*> FCDTextureList;
00031 
00042 class FCOLLADA_EXPORT FCDEffectStandard : public FCDEffectProfile
00043 {
00044 public:
00046     enum LightingType
00047     {
00054         CONSTANT, 
00055 
00061         LAMBERT,
00062 
00067         PHONG,
00068 
00073         BLINN,
00074 
00076         UNKNOWN
00077     };
00078 
00079 private:
00080     DeclareObjectType;
00081     LightingType type;
00082     FCDTextureList* textureBuckets;
00083 
00084     // Common material parameter: Emission
00085     FMVector3 emissionColor;
00086     float emissionFactor; // Max-specific
00087     
00088     // Common material parameter: Translucency
00089     FMVector3 translucencyColor;
00090     float translucencyFactor;
00091 
00092     // Lambert material parameters
00093     FMVector3 diffuseColor;
00094     FMVector3 ambientColor;
00095 
00096     // Phong material parameters: Specular
00097     FMVector3 specularColor;
00098     float specularFactor; // Max-specific
00099     float shininess;
00100 
00101     // Phong material parameter: Reflectivity
00102     FMVector3 reflectivityColor; // Maya-specific
00103     float reflectivityFactor; // Maya-specific
00104 
00105     // Geometry modifier
00106     bool isFaceted; // Max-specific
00107     bool isDoubleSided; // Max-specific for now
00108     bool isWireframe; // Max-specific
00109     bool isFaceMap; // Max-specific
00110     bool isEmissionFactor; // Max-specific
00111 
00112 public:
00117     FCDEffectStandard(FCDocument* document, FCDEffect* parent);
00118 
00121     virtual ~FCDEffectStandard();
00122 
00125     inline LightingType GetLightingType() const { return type; }
00126 
00130     inline void SetLightingType(LightingType _type) { type = _type; }
00131 
00136     virtual FUDaeProfileType::Type GetType() const { return FUDaeProfileType::COMMON; }
00137 
00142     const FCDTextureList& GetTextureBucket(uint32 bucket) const;
00143 
00148     size_t GetTextureCount(uint32 bucket) const { FUAssert(bucket < FUDaeTextureChannel::COUNT, return 0); return textureBuckets[bucket].size(); }
00149 
00155     inline FCDTexture* GetTexture(uint32 bucket, size_t index) { FUAssert(index < GetTextureCount(bucket), return NULL); return textureBuckets[bucket].at(index); }
00156     inline const FCDTexture* GetTexture(uint32 bucket, size_t index) const { FUAssert(index < GetTextureCount(bucket), return NULL); return textureBuckets[bucket].at(index); } 
00162     FCDTexture* AddTexture(uint32 bucket);
00163 
00166     void ReleaseTexture(FCDTexture* texture);
00167 
00173     inline const FMVector3& GetTranslucencyColor() const { return translucencyColor; }
00174 
00177     inline void SetTranslucencyColor(const FMVector3& color) { translucencyColor = color; }
00178 
00184     inline const float& GetTranslucencyFactor() const { return translucencyFactor; }
00185 
00188     inline void SetTranslucencyFactor(float factor) { translucencyFactor = factor; }
00189 
00195     float GetOpacity() const;
00196 
00201     inline const FMVector3& GetEmissionColor() const { return emissionColor; }
00202 
00205     inline void SetEmissionColor(const FMVector3& color) { emissionColor = color; }
00206 
00210     inline const float& GetEmissionFactor() const { return emissionFactor; }
00211 
00214     inline void SetEmissionFactor(float factor) { emissionFactor = factor; }
00215 
00220     inline bool IsEmissionFactor() const { return isEmissionFactor; }
00221 
00226     inline void SetIsEmissionFactor(bool useFactor) { isEmissionFactor = useFactor; }
00227 
00231     inline const FMVector3& GetDiffuseColor() const { return diffuseColor; }
00232 
00235     inline void SetDiffuseColor(const FMVector3& color) { diffuseColor = color; }
00236 
00240     inline const FMVector3& GetAmbientColor() const { return ambientColor; }
00241 
00244     inline void SetAmbientColor(const FMVector3& color) { ambientColor = color; }
00245 
00251     inline const FMVector3& GetSpecularColor() const { return specularColor; }
00252 
00255     inline void SetSpecularColor(const FMVector3& color) { specularColor = color; }
00256 
00262     inline const float& GetSpecularFactor() const { return specularFactor; }
00263 
00266     inline void SetSpecularFactor(float factor) { specularFactor = factor; }
00267 
00274     inline const float& GetShininess() const { return shininess; }
00275 
00281     inline void SetShininess(float _shininess) { shininess = _shininess; }
00282 
00288     inline const FMVector3& GetReflectivityColor() const { return reflectivityColor; }
00289 
00292     inline void SetReflectivityColor(const FMVector3& color) { reflectivityColor = color; }
00293     
00299     inline const float& GetReflectivityFactor() const { return reflectivityFactor; }
00300 
00303     inline void SetReflectivityFactor(float factor) { reflectivityFactor = factor; }
00304 
00310     float GetReflectivity() const;
00311 
00317     inline bool GetFacetedFlag() const { return isFaceted; }
00318 
00324     inline void SetFacetedFlag(bool flag) { isFaceted = flag; }
00325 
00330     inline bool GetDoubleSidedFlag() const { return isDoubleSided; }
00331 
00336     inline bool SetDoubleSidedFlag(bool flag) { isDoubleSided = flag; }
00337 
00342     inline bool GetWireframeFlag() const { return isWireframe; }
00343 
00348     inline bool SetWireframeFlag(bool flag) { isWireframe = flag; }
00349 
00353     inline bool GetFaceMapFlag() const { return isFaceMap; }
00354 
00358     inline void SetFaceMapFlag(bool flag) { isFaceMap = flag; }
00359 
00366     virtual FCDEffectParameter* FindParameterBySemantic(const string& semantic);
00367 
00373     virtual void FindParametersBySemantic(const string& semantic, FCDEffectParameterList& parameters);
00374 
00381     virtual void FindParametersByReference(const string& reference, FCDEffectParameterList& parameters);
00382 
00387     virtual FCDEffectProfile* Clone(FCDEffect* newParent);
00388 
00391     virtual void Flatten() {}
00392 
00398     virtual FUStatus LoadFromXML(xmlNode* baseNode);
00399 
00403     virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
00404 
00405 private:
00406     xmlNode* WriteColorTextureParameterToXML(xmlNode* parentNode, const char* parameterNodeName, const FMVector3& value, const FCDTextureList& textureBucket) const;
00407     xmlNode* WriteFloatTextureParameterToXML(xmlNode* parentNode, const char* parameterNodeName, const float& value, const FCDTextureList& textureBucket) const;
00408     xmlNode* WriteTextureParameterToXML(xmlNode* parentNode, const FCDTextureList& textureBucket) const;
00409 
00410     FUStatus ParseColorTextureParameter(xmlNode* parameterNode, FMVector3& value, FCDTextureList& textureBucket);
00411     FUStatus ParseFloatTextureParameter(xmlNode* parameterNode, float& value, FCDTextureList& textureBucket);
00412     FUStatus ParseSimpleTextureParameter(xmlNode* parameterNode, FCDTextureList& textureBucket);
00413 };
00414 
00415 #endif //_FCD_MATERIAL_STANDARD_H_
00416 

Generated on Fri May 12 16:44:38 2006 for FCollada by  doxygen 1.4.6-NO