FCDocument/FCDEffectParameter.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 
00012 #ifndef _FCD_EFFECT_PARAMETER_H_
00013 #define _FCD_EFFECT_PARAMETER_H_
00014 
00015 #include "FCDocument/FCDObject.h"
00016 
00017 class FCDEffectPass;
00018 class FCDocument;
00019 class FCDEffectParameterSurface;
00020 
00036 class FCOLLADA_EXPORT FCDEffectParameter : public FCDObject
00037 {
00038 public:
00040     enum Type
00041     {
00042         SAMPLER, 
00043         INTEGER, 
00044         BOOLEAN, 
00045         FLOAT, 
00046         FLOAT2, 
00047         FLOAT3, 
00048         VECTOR, 
00049         MATRIX, 
00050         STRING, 
00051         SURFACE 
00052     };
00053 
00054 private:
00055     DeclareObjectType;
00056     bool isGenerator; // whether this effect parameter structure generates a new value or modifies an existing value (is <newparam>?)
00057     string reference;
00058     string semantic; // this is a Collada Semantic, not a Cg semantic
00059     
00060     // [glaforte] These two members should be somewhere else
00061     string bindSymbol; // this can be used in Cg to bind to the correct variable
00062     bool isFragment; // parameter bound to the fragment program or the vertex one
00063 
00064 public:
00068     FCDEffectParameter(FCDocument* document);
00069 
00074     virtual ~FCDEffectParameter();
00075 
00078     virtual Type GetType() const = 0;
00079 
00083     const string& GetReference() const { return reference; } 
00084 
00087     const string& GetSemantic() const { return semantic; }
00088 
00091     void SetSemantic(const string& _semantic) { semantic = _semantic; } 
00092 
00097     bool IsGenerator() const { return isGenerator; }
00098 
00103     bool IsModifier() const { return !isGenerator; }
00104 
00109     const string& GetBindSymbol() const { return bindSymbol; }
00110 
00114     void SetBindSymbol(const string& _bindSymbol) { bindSymbol = _bindSymbol; }
00115 
00120     bool IsFragment() const { return isFragment; }
00121 
00126     void SetFragment(bool _isFragment) { isFragment = _isFragment;}
00127 
00130     virtual FCDEffectParameter* Clone() = 0;
00131 
00135     virtual void Overwrite(FCDEffectParameter* target);
00136 
00141     virtual FUStatus LoadFromXML(xmlNode* parameterNode);
00142 
00146     virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
00147 
00148 protected:
00153     void Clone(FCDEffectParameter* clone);
00154 };
00155 
00164 class FCOLLADA_EXPORT FCDEffectParameterSampler : public FCDEffectParameter
00165 {
00166 public:
00168     enum SamplerType
00169     {
00170         SAMPLER1D, 
00171         SAMPLER2D, 
00172         SAMPLER3D, 
00173         SAMPLERCUBE 
00174     };
00175 
00176 private:
00177     SamplerType samplerType;
00178     string surfaceSid;
00179 
00180 public:
00184     FCDEffectParameterSampler(FCDocument* document);
00185 
00190     virtual ~FCDEffectParameterSampler();
00191 
00194     virtual Type GetType() const { return SAMPLER; }
00195 
00200     const char* GetSurfaceSid() const { return surfaceSid.c_str(); }
00201 
00204     void SetSurfaceSid(const char* sid) { surfaceSid = sid; }
00205 
00208     SamplerType GetSamplerType() const { return samplerType; }
00209 
00212     void SetSamplerType(SamplerType type) { samplerType = type; }
00213 
00216     virtual FCDEffectParameter* Clone();
00217 
00221     virtual void Overwrite(FCDEffectParameter* target);
00222 
00227     virtual FUStatus LoadFromXML(xmlNode* parameterNode);
00228 
00232     virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
00233 };
00234 
00239 class FCOLLADA_EXPORT FCDEffectParameterInt : public FCDEffectParameter
00240 {
00241 private:
00242     int value;
00243 
00244 public:
00248     FCDEffectParameterInt(FCDocument* document);
00249 
00254     virtual ~FCDEffectParameterInt();
00255 
00258     virtual Type GetType() const { return INTEGER; }
00259 
00262     int GetValue() const { return value; }
00263 
00266     void SetValue(int _value) { value = _value; }
00267 
00270     virtual FCDEffectParameter* Clone();
00271 
00275     virtual void Overwrite(FCDEffectParameter* target);
00276 
00281     virtual FUStatus LoadFromXML(xmlNode* parameterNode);
00282 
00286     virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
00287 };
00288 
00293 class FCOLLADA_EXPORT FCDEffectParameterBool : public FCDEffectParameter
00294 {
00295 private:
00296     bool value;
00297 
00298 public:
00302     FCDEffectParameterBool(FCDocument* document);
00303 
00308     virtual ~FCDEffectParameterBool();
00309 
00312     virtual Type GetType() const { return BOOLEAN; }
00313 
00316     bool GetValue() const { return value; }
00317 
00320     void SetValue(bool _value) { value = _value; }
00321 
00324     virtual FCDEffectParameter* Clone();
00325 
00329     virtual void Overwrite(FCDEffectParameter* target);
00330 
00335     virtual FUStatus LoadFromXML(xmlNode* parameterNode);
00336 
00340     virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
00341 };
00342 
00347 class FCOLLADA_EXPORT FCDEffectParameterString : public FCDEffectParameter
00348 {
00349 private:
00350     string value;
00351 
00352 public:
00356     FCDEffectParameterString(FCDocument* document);
00357 
00362     virtual ~FCDEffectParameterString();
00363 
00366     virtual Type GetType() const { return STRING; }
00367 
00370     const string& GetValue() const { return value; }
00371 
00374     void SetValue(const string& _value) { value = _value; }
00375 
00378     virtual FCDEffectParameter* Clone();
00379 
00383     virtual void Overwrite(FCDEffectParameter* target);
00384 
00389     virtual FUStatus LoadFromXML(xmlNode* parameterNode);
00390 
00394     virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
00395 };
00396 
00402 class FCOLLADA_EXPORT FCDEffectParameterFloat : public FCDEffectParameter
00403 {
00404 public:
00406     enum FloatType
00407     {
00408         FLOAT, 
00409         HALF 
00410     };
00411 
00412 private:
00413     FloatType floatType;
00414     float value;
00415     float min;
00416     float max;
00417 
00418 public:
00422     FCDEffectParameterFloat(FCDocument* document);
00423 
00428     virtual ~FCDEffectParameterFloat();
00429 
00432     virtual FCDEffectParameter::Type GetType() const { return FCDEffectParameter::FLOAT; }
00433 
00436     FloatType GetFloatType() const { return floatType; }
00437 
00440     void SetFloatType(FloatType type) { floatType = type; }
00441 
00444     float& GetValue() { return value; }
00445     const float& GetValue() const { return value; } 
00449     void SetValue(float _value) { value = _value; }
00450 
00454     float GetMin() const { return min; }
00455 
00459     void SetMin(float _min) { min = _min; }
00460 
00464     float GetMax() const { return max; }
00465 
00469     void SetMax(float _max) { max = _max; }
00470 
00473     virtual FCDEffectParameter* Clone();
00474 
00478     virtual void Overwrite(FCDEffectParameter* target);
00479 
00484     virtual FUStatus LoadFromXML(xmlNode* parameterNode);
00485 
00489     virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
00490 };
00491 
00497 class FCOLLADA_EXPORT FCDEffectParameterFloat2 : public FCDEffectParameter
00498 {
00499 public:
00501     enum FloatType
00502     {
00503         FLOAT, 
00504         HALF 
00505     };
00506 
00507 private:
00508     FloatType floatType;
00509     float value_x;
00510     float value_y;
00511 
00512 public:
00516     FCDEffectParameterFloat2(FCDocument* document);
00517 
00522     virtual ~FCDEffectParameterFloat2();
00523 
00526     virtual Type GetType() const { return FLOAT2; }
00527 
00530     FloatType GetFloatType() const { return floatType; }
00531 
00534     void SetFloatType(FloatType type) { floatType = type; }
00535 
00538     float& GetValueX() { return value_x; }
00539     const float& GetValueX() const { return value_x; } 
00543     void SetValueX(float value) { value_x = value; }
00544 
00547     float& GetValueY() { return value_y; }
00548     const float& GetValueY() const { return value_y; } 
00552     void SetValueY(float value) { value_y = value; }
00553 
00556     virtual FCDEffectParameter* Clone();
00557 
00561     virtual void Overwrite(FCDEffectParameter* target);
00562 
00567     virtual FUStatus LoadFromXML(xmlNode* parameterNode);
00568 
00572     virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
00573 };
00574 
00580 class FCOLLADA_EXPORT FCDEffectParameterFloat3 : public FCDEffectParameter
00581 {
00582 public:
00584     enum FloatType
00585     {
00586         FLOAT, 
00587         HALF 
00588     };
00589 
00590 private:
00591     FloatType floatType;
00592     FMVector3 value;
00593 
00594 public:
00598     FCDEffectParameterFloat3(FCDocument* document);
00599 
00604     virtual ~FCDEffectParameterFloat3();
00605 
00608     virtual Type GetType() const { return FLOAT3; }
00609 
00612     FloatType GetFloatType() const { return floatType; }
00613 
00616     void SetFloatType(FloatType type) { floatType = type; }
00617 
00620     float& GetValueX() { return value.x; }
00621     const float& GetValueX() const { return value.x; } 
00625     void SetValueX(float _value) { value.x = _value; }
00626 
00629     float& GetValueY() { return value.y; }
00630     const float& GetValueY() const { return value.y; } 
00634     void SetValueY(float _value) { value.y = _value; }
00635 
00638     float& GetValueZ() { return value.z; }
00639     const float& GetValueZ() const { return value.z; } 
00643     void SetValueZ(float _value) { value.z = _value; }
00644 
00647     virtual FCDEffectParameter* Clone();
00648 
00652     virtual void Overwrite(FCDEffectParameter* target);
00653 
00658     virtual FUStatus LoadFromXML(xmlNode* parameterNode);
00659 
00663     virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
00664 };
00665 
00671 class FCOLLADA_EXPORT FCDEffectParameterVector : public FCDEffectParameter
00672 {
00673 public:
00675     enum FloatType
00676     {
00677         FLOAT, 
00678         HALF 
00679     };
00680 
00681 private:
00682     FloatType floatType;
00683     float vector[4];
00684 
00685 public:
00689     FCDEffectParameterVector(FCDocument* document);
00690 
00695     virtual ~FCDEffectParameterVector();
00696 
00699     virtual Type GetType() const { return VECTOR; }
00700 
00703     FloatType GetFloatType() const { return floatType; }
00704 
00707     void SetFloatType(FloatType type) { floatType = type; }
00708 
00711     float* GetVector() { return vector; }
00712     const float* GetVector() const { return vector; } 
00716     float& GetValueX() { return vector[0]; }
00717     const float& GetValueX() const { return vector[0]; } 
00721     void SetValueX(float _value) { vector[0] = _value; }
00722 
00725     float& GetValueY() { return vector[1]; }
00726     const float& GetValueY() const { return vector[1]; } 
00730     void SetValueY(float _value) { vector[1] = _value; }
00731 
00734     float& GetValueZ() { return vector[2]; }
00735     const float& GetValueZ() const { return vector[2]; } 
00739     void SetValueZ(float _value) { vector[2] = _value; }
00740 
00743     float& GetValueW() { return vector[3]; }
00744     const float& GetValueW() const { return vector[3]; } 
00748     void SetValueW(float _value) { vector[3] = _value; }
00749 
00752     virtual FCDEffectParameter* Clone();
00753 
00757     virtual void Overwrite(FCDEffectParameter* target);
00758 
00763     virtual FUStatus LoadFromXML(xmlNode* parameterNode);
00764 
00768     virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
00769 };
00770 
00776 class FCOLLADA_EXPORT FCDEffectParameterMatrix : public FCDEffectParameter
00777 {
00778 public:
00780     enum FloatType
00781     {
00782         FLOAT, 
00783         HALF 
00784     };
00785 
00786 private:
00787     FloatType floatType;
00788     FMMatrix44 matrix;
00789 
00790 public:
00794     FCDEffectParameterMatrix(FCDocument* document);
00795 
00800     virtual ~FCDEffectParameterMatrix();
00801 
00804     virtual Type GetType() const { return MATRIX; }
00805 
00808     FloatType GetFloatType() const { return floatType; }
00809 
00812     void SetFloatType(FloatType type) { floatType = type; }
00813 
00816     FMMatrix44& GetMatrix() { return matrix; }
00817     const FMMatrix44& GetMatrix() const { return matrix; } 
00821     void SetMatrix(const FMMatrix44& mx) { matrix = mx; }
00822 
00825     virtual FCDEffectParameter* Clone();
00826 
00830     virtual void Overwrite(FCDEffectParameter* target);
00831 
00836     virtual FUStatus LoadFromXML(xmlNode* parameterNode);
00837 
00841     virtual xmlNode* WriteToXML(xmlNode* parentNode) const;
00842 };
00843 
00844 #endif // _FCD_EFFECT_PARAMETER_H_
00845 

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