FCDocument/FCDEffectStandard.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2007 Feeling Software Inc.
00003     Portions of the code are:
00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
00005     
00006     MIT License: http://www.opensource.org/licenses/mit-license.php
00007 */
00008 /*
00009     Based on the FS Import classes:
00010     Copyright (C) 2005-2006 Feeling Software Inc
00011     Copyright (C) 2005-2006 Autodesk Media Entertainment
00012     MIT License: http://www.opensource.org/licenses/mit-license.php
00013 */
00014 
00020 #ifndef _FCD_MATERIAL_STANDARD_H_
00021 #define _FCD_MATERIAL_STANDARD_H_
00022 
00023 #ifndef _FU_DAE_ENUM_H_
00024 #include "FUtils/FUDaeEnum.h"
00025 #endif // _FU_DAE_ENUM_H_
00026 #ifndef _FCD_EFFECT_PROFILE_H_
00027 #include "FCDocument/FCDEffectProfile.h"
00028 #endif // _FCD_EFFECT_PROFILE_H_
00029 #ifndef _FCD_EFFECT_PARAMETER_H_
00030 #include "FCDocument/FCDEffectParameter.h"
00031 #endif // _FCD_EFFECT_PARAMETER_H_
00032 
00033 class FCDocument;
00034 class FCDEffect;
00035 class FCDTexture;
00036 class FCDEffectParameter;
00037 
00038 #ifndef LINUX
00039 template <class T, int Q> class FCOLLADA_EXPORT FCDEffectParameterAnimatableT; 
00040 #else
00041 template <class T, int Q> class FCDEffectParameterAnimatableT; 
00042 #endif // LINUX
00043 typedef FCDEffectParameterAnimatableT<FMVector4, 1> FCDEffectParameterColor4; 
00044 typedef FCDEffectParameterAnimatableT<float, 0> FCDEffectParameterFloat; 
00056 class FCOLLADA_EXPORT FCDEffectStandard : public FCDEffectProfile
00057 {
00058 public:
00060     enum LightingType
00061     {
00068         CONSTANT, 
00069 
00075         LAMBERT,
00076 
00081         PHONG,
00082 
00087         BLINN,
00088 
00090         UNKNOWN
00091     };
00092 
00094     enum TransparencyMode
00095     {
00098         A_ONE,
00099 
00102         RGB_ZERO
00103     };
00104 
00105 private:
00106     DeclareObjectType(FCDEffectProfile);
00107 
00108     DeclareParameter(uint32, FUParameterQualifiers::SIMPLE, type, FC("Lighting Type")); // LightingType;
00109 
00110     // Emission Channel
00111     DeclareParameterContainer(FCDTexture, emissionTextures, FC("Emission Textures"));
00112     DeclareParameterRef(FCDEffectParameterColor4, emissionColor, FC("Emission Color"));
00113     DeclareParameterRef(FCDEffectParameterFloat, emissionFactor, FC("Emission Factor"));
00114     DeclareParameter(bool, FUParameterQualifiers::SIMPLE, isEmissionFactor, FC("Is Emission Factor"));
00115 
00116     // Reflectivity Channel
00117     DeclareParameterContainer(FCDTexture, reflectivityTextures, FC("Reflectivity Textures"));
00118     DeclareParameterRef(FCDEffectParameterColor4, reflectivityColor, FC("Reflectivity Color"));
00119     DeclareParameterRef(FCDEffectParameterFloat, reflectivityFactor, FC("Reflectivity Factor"));
00120     DeclareParameter(bool, FUParameterQualifiers::SIMPLE, isReflective, FC("Is Reflective"));
00121 
00122     // Refractivity Channel
00123     DeclareParameterContainer(FCDTexture, refractionTextures, FC("Refraction Textures"));
00124     DeclareParameterRef(FCDEffectParameterFloat, indexOfRefraction, FC("Index of Refraction"));
00125     DeclareParameter(bool, FUParameterQualifiers::SIMPLE, isRefractive, FC("Is Refractive"));
00126 
00127     // Transparency Channel
00128     DeclareParameterContainer(FCDTexture, translucencyTextures, FC("Translucency Textures"));
00129     DeclareParameterRef(FCDEffectParameterColor4, translucencyColor, FC("Translucency Color"));
00130     DeclareParameterRef(FCDEffectParameterFloat, translucencyFactor, FC("Translucency Factor"));
00131     DeclareParameter(uint32, FUParameterQualifiers::SIMPLE, transparencyMode, FC("Translucency Mode")); // TransparencyMode
00132 
00133     // Diffuse Channel
00134     DeclareParameterContainer(FCDTexture, diffuseTextures, FC("Diffuse Textures"));
00135     DeclareParameterRef(FCDEffectParameterColor4, diffuseColor, FC("Diffuse Color"));
00136 
00137     // Ambient Channel
00138     DeclareParameterContainer(FCDTexture, ambientTextures, FC("Ambient Textures"));
00139     DeclareParameterRef(FCDEffectParameterColor4, ambientColor, FC("Ambient Color"));
00140 
00141     // Specular Channel
00142     DeclareParameterContainer(FCDTexture, specularTextures, FC("Specular Color Textures"));
00143     DeclareParameterRef(FCDEffectParameterColor4, specularColor, FC("Specular Color"));
00144     DeclareParameterContainer(FCDTexture, specularFactorTextures, FC("Specular Factor Textures"));
00145     DeclareParameterRef(FCDEffectParameterFloat, specularFactor, FC("Specular Factor"));
00146 
00147     // Specular Exponent Channel
00148     DeclareParameterContainer(FCDTexture, shininessTextures, FC("Shininess Textures"));
00149     DeclareParameterRef(FCDEffectParameterFloat, shininess, FC("Shininess Factor"));
00150 
00151     // Extra Channels
00152     DeclareParameterContainer(FCDTexture, bumpTextures, FC("Bump Maps"));
00153     DeclareParameterContainer(FCDTexture, displacementTextures, FC("Displacement Maps")); // Max-only
00154     DeclareParameterContainer(FCDTexture, filterTextures, FC("Filter Maps")); // Max-only
00155 
00156 public:
00162     FCDEffectStandard(FCDocument* document, FCDEffect* parent);
00163 
00165     virtual ~FCDEffectStandard();
00166 
00169     inline LightingType GetLightingType() const { return (LightingType) *type; }
00170 
00174     inline void SetLightingType(LightingType _type) { type = _type; SetDirtyFlag(); }
00175 
00180     virtual FUDaeProfileType::Type GetType() const { return FUDaeProfileType::COMMON; }
00181 
00186     inline FCDTexture** GetTextureBucket(uint32 bucket) { return const_cast<FCDTexture**>(const_cast<const FCDEffectStandard*>(this)->GetTextureBucket(bucket)); }
00187     const FCDTexture** GetTextureBucket(uint32 bucket) const; 
00193     size_t GetTextureCount(uint32 bucket) const;
00194 
00200     inline FCDTexture* GetTexture(uint32 bucket, size_t index) { FUAssert(index < GetTextureCount(bucket), return NULL); return GetTextureBucket(bucket)[index]; }
00201     inline const FCDTexture* GetTexture(uint32 bucket, size_t index) const { FUAssert(index < GetTextureCount(bucket), return NULL); return GetTextureBucket(bucket)[index]; } 
00207     FCDTexture* AddTexture(uint32 bucket);
00208 
00211     DEPRECATED(3.05A, texture->Release()) void ReleaseTexture(FCDTexture* texture) { ((FUObject*) texture)->Release(); }
00212 
00218     FCDEffectParameter* GetParam(const fm::string& semantic, bool* isFloat);
00219 
00220 //
00221 //  Translucency Color (vector)
00222 //
00223 
00231     inline FMVector4& GetTranslucencyColor() { return translucencyColor->GetValue(); }
00232     inline const FMVector4& GetTranslucencyColor() const { return translucencyColor->GetValue(); } 
00239     inline FCDEffectParameterColor4* GetTranslucencyColorParam() { return translucencyColor; }
00240     inline const FCDEffectParameterColor4* GetTranslucencyColorParam() const { return translucencyColor; } 
00244     inline void SetTranslucencyColor(const FMVector4& color) { translucencyColor->SetValue(color); SetDirtyFlag(); }
00245 
00246 //
00247 // Translucency Factor (float)
00248 //
00249 
00255     inline float& GetTranslucencyFactor() { return translucencyFactor->GetValue(); }
00256     inline const float& GetTranslucencyFactor() const { return translucencyFactor->GetValue(); } 
00263     inline FCDEffectParameterFloat* GetTranslucencyFactorParam() { return translucencyFactor; }
00264     inline const FCDEffectParameterFloat* GetTranslucencyFactorParam() const { return translucencyFactor; } 
00268     inline void SetTranslucencyFactor(float factor) { translucencyFactor->SetValue(factor); SetDirtyFlag(); }
00269 
00270 //
00271 // Transparency Mode (bool)
00272 //
00273 
00276     inline TransparencyMode GetTransparencyMode() const { return (TransparencyMode) *transparencyMode; }
00277 
00280     inline void SetTransparencyMode(TransparencyMode mode) { transparencyMode = mode; SetDirtyFlag(); }
00281 
00287     float GetOpacity() const;
00288 
00289 // 
00290 // Emission Color (vector)
00291 //
00292 
00297     inline FMVector4& GetEmissionColor() { return emissionColor->GetValue(); }
00298     inline const FMVector4& GetEmissionColor() const { return emissionColor->GetValue(); } 
00305     inline FCDEffectParameterColor4* GetEmissionColorParam() { return emissionColor; }
00306     inline const FCDEffectParameterColor4* GetEmissionColorParam() const { return emissionColor; } 
00310     inline void SetEmissionColor(const FMVector4& color) { emissionColor->SetValue(color); SetDirtyFlag(); }
00311 
00312 //
00313 // Emission Factor (float)
00314 //
00315 
00319     inline float& GetEmissionFactor() { return emissionFactor->GetValue(); }
00320     inline const float& GetEmissionFactor() const { return emissionFactor->GetValue(); } 
00327     inline FCDEffectParameterFloat* GetEmissionFactorParam() { return emissionFactor; }
00328     inline const FCDEffectParameterFloat* GetEmissionFactorParam() const { return emissionFactor; } 
00332     inline void SetEmissionFactor(float factor) { emissionFactor->SetValue(factor); SetDirtyFlag(); }
00333 
00334 //
00335 // IsEmission Factor (bool)
00336 //
00337 
00342     inline bool IsEmissionFactor() const { return isEmissionFactor; }
00343 
00348     inline void SetIsEmissionFactor(bool useFactor) { isEmissionFactor = useFactor; SetDirtyFlag(); }
00349 
00350 //
00351 // Diffuse Color (vector)
00352 // 
00353 
00357     inline FMVector4& GetDiffuseColor() { return diffuseColor->GetValue(); }
00358     inline const FMVector4& GetDiffuseColor() const { return diffuseColor->GetValue(); } 
00365     inline FCDEffectParameterColor4* GetDiffuseColorParam() { return diffuseColor; }
00366     inline const FCDEffectParameterColor4* GetDiffuseColorParam() const { return diffuseColor; } 
00370     inline void SetDiffuseColor(const FMVector4& color) { diffuseColor->SetValue(color); SetDirtyFlag(); }
00371 
00372 //
00373 // Ambient Color (vector)
00374 //
00375 
00379     inline FMVector4& GetAmbientColor() { return ambientColor->GetValue(); }
00380     inline const FMVector4& GetAmbientColor() const { return ambientColor->GetValue(); } 
00387     inline FCDEffectParameterColor4* GetAmbientColorParam() { return ambientColor; }
00388     inline const FCDEffectParameterColor4* GetAmbientColorParam() const { return ambientColor; } 
00392     inline void SetAmbientColor(const FMVector4& color) { ambientColor->SetValue(color); SetDirtyFlag(); }
00393 
00394 //
00395 // Specular Color (vector)
00396 //
00397 
00403     inline FMVector4& GetSpecularColor() { return specularColor->GetValue(); }
00404     inline const FMVector4& GetSpecularColor() const { return specularColor->GetValue(); } 
00411     inline FCDEffectParameterColor4* GetSpecularColorParam() { return specularColor; }
00412     inline const FCDEffectParameterColor4* GetSpecularColorParam() const { return specularColor; } 
00416     inline void SetSpecularColor(const FMVector4& color) { specularColor->SetValue(color); SetDirtyFlag(); }
00417 
00418 //
00419 // Specular Factor (float)
00420 //
00421 
00427     inline float& GetSpecularFactor() { return specularFactor->GetValue(); }
00428     inline const float& GetSpecularFactor() const { return specularFactor->GetValue(); } 
00435     inline FCDEffectParameterFloat* GetSpecularFactorParam() { return specularFactor; }
00436     inline const FCDEffectParameterFloat* GetSpecularFactorParam() const { return specularFactor; } 
00440     inline void SetSpecularFactor(float factor) { specularFactor->SetValue(factor); SetDirtyFlag(); }
00441 
00442 //
00443 // Shininess (float)
00444 //
00445 
00452     inline float& GetShininess() { return shininess->GetValue(); }
00453     inline const float& GetShininess() const { return shininess->GetValue(); } 
00460     inline FCDEffectParameterFloat* GetShininessParam() { return shininess; }
00461     inline const FCDEffectParameterFloat* GetShininessParam() const { return shininess; } 
00468     inline void SetShininess(float _shininess) { shininess->SetValue(_shininess); SetDirtyFlag(); }
00469 
00470 //
00471 // IsReflective (bool)
00472 //
00473 
00476     inline bool IsReflective() const { return isReflective; }
00477 
00480     inline void SetReflective(bool r) { isReflective = r; }
00481 
00482 //
00483 // Reflectivity Color (vector)
00484 //
00485 
00491     inline FMVector4& GetReflectivityColor() { return reflectivityColor->GetValue(); }
00492     inline const FMVector4& GetReflectivityColor() const { return reflectivityColor->GetValue(); } 
00499     inline FCDEffectParameterColor4* GetReflectivityColorParam() { return reflectivityColor; }
00500     inline const FCDEffectParameterColor4* GetReflectivityColorParam() const { return reflectivityColor; } 
00504     inline void SetReflectivityColor(const FMVector4& color) { reflectivityColor->SetValue(color); isReflective = true; SetDirtyFlag(); }
00505 
00506 // 
00507 // Reflectivity Factor (float)
00508 //
00509 
00515     inline float& GetReflectivityFactor() { return reflectivityFactor->GetValue(); }
00516     inline const float& GetReflectivityFactor() const { return reflectivityFactor->GetValue(); } 
00523     inline FCDEffectParameterFloat* GetReflectivityFactorParam() { return reflectivityFactor; }
00524     inline const FCDEffectParameterFloat* GetReflectivityFactorParam() const { return reflectivityFactor; } 
00528     inline void SetReflectivityFactor(float factor) { reflectivityFactor->SetValue(factor); isReflective = true; SetDirtyFlag(); }
00529 
00535     float GetReflectivity() const;
00536 
00537 //
00538 // IsRefractive (bool)
00539 //
00540 
00543     inline bool IsRefractive() const { return isRefractive; }
00544 
00547     inline void SetRefractive(bool r) { isRefractive = r; }
00548 
00549 //
00550 // IndexOfRefraction (float)
00551 //
00552 
00556     inline float& GetIndexOfRefraction() { return indexOfRefraction->GetValue(); }
00557     inline const float& GetIndexOfRefraction() const { return indexOfRefraction->GetValue(); } 
00564     inline FCDEffectParameterFloat* GetIndexOfRefractionParam() { return indexOfRefraction; }
00565     inline const FCDEffectParameterFloat* GetIndexOfRefractionParam() const { return indexOfRefraction; } 
00569     inline void SetIndexOfRefraction(float index) { indexOfRefraction->SetValue(index); isRefractive = true; SetDirtyFlag(); }
00570 
00571 //
00572 //  Miscellaneous
00573 //
00574 
00580     virtual FCDEffectProfile* Clone(FCDEffectProfile* clone = NULL) const;
00581 
00584     DEPRECATED(3.05A, not recommended) void Flatten() {}
00585 
00590     void AddExtraAttribute(const char *profile, const char *key, const fchar *value);
00591 
00595     const fchar* GetExtraAttribute(const char *profile, const char *key) const;
00596 
00597 public:
00598     static const fm::string EmissionColorSemantic;
00599     static const fm::string EmissionFactorSemantic;
00600     static const fm::string ReflectivityColorSemantic;
00601     static const fm::string ReflectivityFactorSemantic;
00602     static const fm::string IndexOfRefractionSemantic;
00603     static const fm::string TranslucencyColorSemantic;
00604     static const fm::string TranslucencyFactorSemantic;
00605     static const fm::string DiffuseColorSemantic;
00606     static const fm::string AmbientColorSemantic;
00607     static const fm::string SpecularColorSemantic;
00608     static const fm::string SpecularFactorSemantic;
00609     static const fm::string ShininessSemantic;
00610 
00611 };
00612 
00613 #endif //_FCD_MATERIAL_STANDARD_H_
00614 

Generated on Thu Feb 14 16:58:34 2008 for FCollada by  doxygen 1.4.6-NO