FCDocument/FCDEffectParameter.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 
00015 #ifndef _FCD_EFFECT_PARAMETER_H_
00016 #define _FCD_EFFECT_PARAMETER_H_
00017 
00018 #ifndef __FCD_OBJECT_H_
00019 #include "FCDocument/FCDObject.h"
00020 #endif // __FCD_OBJECT_H_
00021 #ifndef _FCD_PARAMETER_ANIMATABLE_H_
00022 #include "FCDocument/FCDParameterAnimatable.h"
00023 #endif // _FCD_PARAMETER_ANIMATABLE_H_
00024 
00025 class FCDocument;
00026 class FCDEffectParameterAnnotation;
00027 
00043 class FCOLLADA_EXPORT FCDEffectParameter : public FCDObject
00044 {
00045 public:
00047     enum Type
00048     {
00049         SAMPLER, 
00050         INTEGER, 
00051         BOOLEAN, 
00052         FLOAT, 
00053         FLOAT2, 
00054         FLOAT3, 
00055         VECTOR, 
00056         MATRIX, 
00057         STRING, 
00058         SURFACE 
00059     };
00060 
00062     enum ParamType
00063     {
00064         GENERATOR, 
00066         MODIFIER, 
00068         ANIMATOR, 
00070         REFERENCER, 
00072         CONSTANT 
00074     };
00075 
00076 private:
00077     DeclareObjectType(FCDObject);
00078 
00079     DeclareParameter(uint32, FUParameterQualifiers::SIMPLE, paramType, FC("Parameter Type")); // ParamType 
00080     DeclareParameter(fm::string, FUParameterQualifiers::SIMPLE, reference, FC("Identifier"));
00081     DeclareParameter(fm::string, FUParameterQualifiers::SIMPLE, semantic, FC("Semantic")); // this is a COLLADA Semantic, not a Cg semantic
00082     DeclareParameterContainer(FCDEffectParameterAnnotation, annotations, FC("Annotations"));
00083     
00084 public:
00088     FCDEffectParameter(FCDocument* document);
00089 
00091     virtual ~FCDEffectParameter();
00092 
00095     virtual Type GetType() const = 0;
00096 
00101     inline ParamType GetParamType() const { return (ParamType) *paramType; }
00102 
00106     inline const fm::string& GetReference() const { return reference; }
00107 
00111     void SetReference(const char* _reference);
00112 
00115     inline const fm::string& GetSemantic() const { return semantic; }
00116 
00119     void SetSemantic(const char* _semantic) { semantic = _semantic; SetDirtyFlag(); } 
00120 
00125     inline bool IsGenerator() const { return paramType == GENERATOR; }
00126 
00128     inline void SetGenerator() { paramType = GENERATOR; SetDirtyFlag(); }
00129 
00134     inline bool IsModifier() const { return paramType == MODIFIER; }
00135 
00137     inline void SetModifier() { paramType = MODIFIER; SetDirtyFlag(); }
00138 
00143     inline bool IsAnimator() const { return paramType == ANIMATOR; }
00144 
00146     inline void SetAnimator() { paramType = ANIMATOR; SetDirtyFlag(); }
00147 
00152     inline bool IsReferencer() const { return paramType == REFERENCER; }
00153 
00155     inline void SetReferencer() { paramType = REFERENCER; SetDirtyFlag(); }
00156 
00161     inline bool IsConstant() const { return paramType == CONSTANT; }
00162 
00164     inline void SetConstant() { paramType = CONSTANT; SetDirtyFlag(); }
00165 
00168     inline const FCDEffectParameterAnnotation** GetAnnotations() const { return annotations.begin(); } 
00172     inline size_t GetAnnotationCount() const { return annotations.size(); }
00173 
00178     inline FCDEffectParameterAnnotation* GetAnnotation(size_t index) { FUAssert(index < GetAnnotationCount(), return NULL); return annotations.at(index); }
00179     inline const FCDEffectParameterAnnotation* GetAnnotation(size_t index) const { FUAssert(index < GetAnnotationCount(), return NULL); return annotations.at(index); } 
00183     FCDEffectParameterAnnotation* AddAnnotation();
00184 
00189     void AddAnnotation(const fchar* name, FCDEffectParameter::Type type, const fchar* value);
00190     inline void AddAnnotation(const fstring& name, FCDEffectParameter::Type type, const fchar* value) { AddAnnotation(name.c_str(), type, value); } 
00191     inline void AddAnnotation(const fchar* name, FCDEffectParameter::Type type, const fstring& value) { AddAnnotation(name, type, value.c_str()); } 
00192     inline void AddAnnotation(const fstring& name, FCDEffectParameter::Type type, const fstring& value) { AddAnnotation(name.c_str(), type, value.c_str()); } 
00193     template <class T> inline void AddAnnotation(const fchar* name, FCDEffectParameter::Type type, const T& value) { FUStringBuilder builder; builder.set(value); AddAnnotation(name, type, builder.ToCharPtr()); } 
00194     template <class T> inline void AddAnnotation(const fstring& name, FCDEffectParameter::Type type, const T& value) { FUStringBuilder builder; builder.set(value); AddAnnotation(name.c_str(), type, builder.ToCharPtr()); } 
00198     DEPRECATED(3.05A, annotation->Release) inline void ReleaseAnnotation(FCDEffectParameterAnnotation* annotation) { ((FCDObject*) annotation)->Release(); }
00199 
00203     virtual bool IsValueEqual(FCDEffectParameter *parameter) = 0;
00204 
00210     virtual FCDEffectParameter* Clone(FCDEffectParameter* clone = NULL) const;
00211 
00215     virtual void Overwrite(FCDEffectParameter* target);
00216 };
00217 
00222 template <class PrimitiveType>
00223 class FCOLLADA_EXPORT FCDEffectParameterT : public FCDEffectParameter
00224 {
00225 private:
00226     DeclareObjectType(FCDEffectParameter);
00227     DeclareParameter(PrimitiveType, FUParameterQualifiers::SIMPLE, value, FC("Value"));
00228 
00229 public:
00233     FCDEffectParameterT(FCDocument* document);
00234 
00236     virtual ~FCDEffectParameterT();
00237 
00240     virtual Type GetType() const;
00241 
00244     inline const PrimitiveType& GetValue() const { return *value; }
00245 
00248     inline void SetValue(const PrimitiveType& _value) { value = _value; SetDirtyFlag(); }
00249 
00253     virtual bool IsValueEqual(FCDEffectParameter *parameter);
00254 
00260     virtual FCDEffectParameter* Clone(FCDEffectParameter* clone = NULL) const;
00261 
00265     virtual void Overwrite(FCDEffectParameter* target);
00266 };
00267 
00268 typedef FCDEffectParameterT<int32> FCDEffectParameterInt; 
00269 typedef FCDEffectParameterT<bool> FCDEffectParameterBool; 
00270 typedef FCDEffectParameterT<fm::string> FCDEffectParameterString; 
00276 template <class PrimitiveType, int Qualifiers>
00277 class FCOLLADA_EXPORT FCDEffectParameterAnimatableT : public FCDEffectParameter
00278 {
00279 public:
00281     enum FloatType
00282     {
00283         FLOAT, 
00284         HALF 
00285     };
00286 
00287 private:
00288     DeclareObjectType(FCDEffectParameter);
00289     FloatType floatType;
00290     DeclareParameterAnimatable(PrimitiveType, Qualifiers, value, FC("Value"));
00291 
00292 public:
00296     FCDEffectParameterAnimatableT(FCDocument* document);
00297 
00299     virtual ~FCDEffectParameterAnimatableT();
00300 
00303     virtual Type GetType() const;
00304 
00307     inline FloatType GetFloatType() const { return floatType; }
00308 
00311     inline void SetFloatType(FloatType type) { floatType = type; SetDirtyFlag(); }
00312 
00315     inline FCDParameterAnimatableT<PrimitiveType, Qualifiers>& GetValue() { return value; }
00316     inline const FCDParameterAnimatableT<PrimitiveType, Qualifiers>& GetValue() const { return value; } 
00320     inline void SetValue(const PrimitiveType& _value) { value = _value; SetDirtyFlag(); }
00321 
00325     virtual bool IsValueEqual(FCDEffectParameter *parameter);
00326 
00332     virtual FCDEffectParameter* Clone(FCDEffectParameter* clone = NULL) const;
00333 
00337     virtual void Overwrite(FCDEffectParameter* target);
00338 };
00339 
00340 typedef FCDEffectParameterAnimatableT<float, FUParameterQualifiers::SIMPLE> FCDEffectParameterFloat; 
00341 typedef FCDEffectParameterAnimatableT<FMVector2, FUParameterQualifiers::SIMPLE> FCDEffectParameterFloat2; 
00342 typedef FCDEffectParameterAnimatableT<FMVector3, FUParameterQualifiers::VECTOR> FCDEffectParameterFloat3; 
00343 typedef FCDEffectParameterAnimatableT<FMVector3, FUParameterQualifiers::COLOR> FCDEffectParameterColor3; 
00344 typedef FCDEffectParameterAnimatableT<FMVector4, FUParameterQualifiers::VECTOR> FCDEffectParameterVector; 
00345 typedef FCDEffectParameterAnimatableT<FMVector4, FUParameterQualifiers::COLOR> FCDEffectParameterColor4; 
00346 typedef FCDEffectParameterAnimatableT<FMMatrix44, FUParameterQualifiers::SIMPLE> FCDEffectParameterMatrix; 
00355 class FCOLLADA_EXPORT FCDEffectParameterAnnotation : public FUParameterizable
00356 {
00357 private:
00358     DeclareObjectType(FUParameterizable);
00359 
00360 public:
00363     FCDEffectParameterAnnotation();
00365     virtual ~FCDEffectParameterAnnotation();
00366 
00367     DeclareParameter(fstring, FUParameterQualifiers::SIMPLE, name, FC("Name")); 
00368     DeclareParameter(uint32, FUParameterQualifiers::SIMPLE, type, FC("Value Type")); 
00369     DeclareParameter(fstring, FUParameterQualifiers::SIMPLE, value, FC("Value")); 
00370 };
00371 
00372 #if defined(__APPLE__) || defined(LINUX)
00373 #include <FCDocument/FCDEffectParameter.hpp>
00374 #endif
00375 
00376 #endif // _FCD_EFFECT_PARAMETER_H_
00377 

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