- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# FCDocument/FCDParameterAnimatable.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 #ifndef _FCD_PARAMETER_ANIMATABLE_H_
    00010 #define _FCD_PARAMETER_ANIMATABLE_H_
    00011
    00017 #ifndef _FU_PARAMETER_H_
    00018 #include <FUtils/FUParameter.h>
    00019 #endif // _FU_PARAMETER_H_
    00020 #ifndef _FM_ANGLEAXIS_H_
    00021 #include <FMath/FMAngleAxis.h>
    00022 #endif // _FM_ANGLEAXIS_H_
    00023 #ifndef _FM_LOOKAT_H_
    00024 #include <FMath/FMLookAt.h>
    00025 #endif // _FM_LOOKAT_H_
    00026 #ifndef _FM_SKEW_H_
    00027 #include <FMath/FMSkew.h>
    00028 #endif // _FM_SKEW_H_
    00029
    00030 class FCDAnimated;
    00031 class FUParameterizable;
    00032
    00037 class FCOLLADA_EXPORT FCDParameterAnimatable
    00038 {
    00039 private:
    00040     FUParameterizable* parent;
    00041     FUObjectRef<FCDAnimated> animated;
    00042
    00043 public:
    00046     FCDParameterAnimatable(FUParameterizable* parent);
    00047
    00049     virtual ~FCDParameterAnimatable();
    00050
    00053     virtual FUParameterizable* GetParent() { return parent; }
    00054
    00058     FCDAnimated* GetAnimated();
    00059     const FCDAnimated* GetAnimated() const;
    00063     bool IsAnimated() const;
    00064
    00069     FCDParameterAnimatable& operator= (FCDParameterAnimatable& parameter);
    00070
    00071 protected:
    00076     virtual FCDAnimated* CreateAnimated();
    00077 };
    00078
    00083 template <class TYPE, int QUALIFIERS>
    00084 class FCOLLADA_EXPORT FCDParameterAnimatableT : public FCDParameterAnimatable
    00085 {
    00086 private:
    00087     TYPE value;
    00088
    00089 public:
    00092     FCDParameterAnimatableT(FUParameterizable* parent);
    00093
    00097     FCDParameterAnimatableT(FUParameterizable* parent, const TYPE& defaultValue);
    00098
    00100     virtual ~FCDParameterAnimatableT();
    00101
    00104     inline operator TYPE&() { return value; }
    00105     inline operator const TYPE&() const { return value; }
    00106     inline TYPE& operator *() { return value; }
    00107     inline const TYPE& operator *() const { return value; }
    00108     inline TYPE* operator->() { return &value; }
    00109     inline const TYPE* operator->() const { return &value; }
    00114     FCDParameterAnimatableT<TYPE, QUALIFIERS>& operator= (const TYPE& copy);
    00115
    00116 protected:
    00120     virtual FCDAnimated* CreateAnimated();
    00121 };
    00122
    00123 typedef FCDParameterAnimatableT<float, 0> FCDParameterAnimatableFloat;
    00124 typedef FCDParameterAnimatableT<FMVector2, 0> FCDParameterAnimatableVector2;
    00125 typedef FCDParameterAnimatableT<FMVector3, 0> FCDParameterAnimatableVector3;
    00126 typedef FCDParameterAnimatableT<FMVector3, 1> FCDParameterAnimatableColor3;
    00127 typedef FCDParameterAnimatableT<FMVector4, 0> FCDParameterAnimatableVector4;
    00128 typedef FCDParameterAnimatableT<FMVector4, 1> FCDParameterAnimatableColor4;
    00129 typedef FCDParameterAnimatableT<FMMatrix44, 0> FCDParameterAnimatableMatrix44;
    00130 typedef FCDParameterAnimatableT<FMAngleAxis, 0> FCDParameterAnimatableAngleAxis;
    00131 typedef FCDParameterAnimatableT<FMLookAt, 0> FCDParameterAnimatableLookAt;
    00132 typedef FCDParameterAnimatableT<FMSkew, 0> FCDParameterAnimatableSkew;
    00138 class FCOLLADA_EXPORT FCDParameterListAnimatable
    00139 {
    00140 private:
    00141     FUParameterizable* parent;
    00142
    00143 protected:
    00147     FUObjectContainer<FCDAnimated> animateds;
    00148
    00149 public:
    00152     FCDParameterListAnimatable(FUParameterizable* parent);
    00153
    00155     virtual ~FCDParameterListAnimatable();
    00156
    00159     virtual FUParameterizable* GetParent() { return parent; }
    00160
    00165     FCDAnimated* GetAnimated(size_t index);
    00166     const FCDAnimated* GetAnimated(size_t index) const;
    00172     bool IsAnimated(size_t index = ~(size_t)0) const;
    00173
    00176     inline FUObjectContainer<FCDAnimated>& GetAnimatedValues() { return animateds; }
    00177     inline const FUObjectContainer<FCDAnimated>& GetAnimatedValues() const { return animateds; }
    00179 protected:
    00185     virtual FCDAnimated* CreateAnimated(size_t index);
    00186
    00192     void OnInsertion(size_t offset, size_t count);
    00193
    00199     void OnRemoval(size_t offset, size_t count);
    00200
    00201 private:
    00202     size_t BinarySearch(size_t arrayElementIndex) const;
    00203 };
    00204
    00209 template <class TYPE, int QUALIFIERS>
    00210 class FCOLLADA_EXPORT FCDParameterListAnimatableT : public FCDParameterListAnimatable
    00211 {
    00212 private:
    00213     fm::vector<TYPE, true> values;
    00214
    00215 public:
    00218     FCDParameterListAnimatableT(FUParameterizable* parent);
    00219
    00221     virtual ~FCDParameterListAnimatableT();
    00222
    00225     inline size_t size() const { return values.size(); }
    00229     inline bool empty() const { return values.size() == 0; }
    00230
    00233     void resize(size_t count);
    00234
    00238     void resize(size_t count, const TYPE& value);
    00239
    00245     inline const TYPE& at(size_t index) const { return values[index]; }
    00246     inline const TYPE& operator[](size_t index) const { return values[index]; }
    00247     template <class INTEGER> inline const TYPE& operator[](INTEGER index) const { return values[index]; }
    00252     void set(size_t index, const TYPE& value);
    00253
    00257     void insert(size_t index, const TYPE& value);
    00258
    00263     void insert(size_t index, size_t count, const TYPE& value);
    00264
    00269     void insert(size_t index, const TYPE* values, size_t count);
    00270
    00273     void erase(size_t index);
    00274
    00277     void erase(const TYPE& value);
    00278
    00282     void erase(size_t start, size_t end);
    00283
    00285     void clear();
    00286
    00291     inline size_t find(const TYPE& value) const { return values.find(value) - values.begin(); }
    00292
    00296     inline bool contains(const TYPE& value) const { return values.contains(value); }
    00297
    00300     void push_back(const TYPE& value);
    00301
    00304     void push_front(const TYPE& value);
    00305
    00307     void pop_back();
    00308
    00310     void pop_front();
    00311
    00314     inline TYPE& front() { return values.front(); }
    00315     inline const TYPE& front() const { return values.front(); }
    00319     inline TYPE& back() { return values.back(); }
    00320     inline const TYPE& back() const { return values.back(); }
    00324     inline TYPE** GetDataPtr() { return values.GetDataPtr(); }
    00325     inline const TYPE** GetDataPtr() const { return values.GetDataPtr(); }
    00329     inline fm::vector<TYPE, true>& GetDataList() { return values; }
    00330     inline const fm::vector<TYPE, true>& GetDataList() const { return values; }
    00334     inline size_t capacity() const { return values.capacity(); }
    00335
    00336 protected:
    00340     virtual FCDAnimated* CreateAnimated(size_t index);
    00341
    00342 private:
    00346     void OnPotentialSizeChange();
    00347 };
    00348
    00349 typedef FCDParameterListAnimatableT<float, 0> FCDParameterListAnimatableFloat;
    00350 typedef FCDParameterListAnimatableT<FMVector2, 0> FCDParameterListAnimatableVector2;
    00351 typedef FCDParameterListAnimatableT<FMVector3, 0> FCDParameterListAnimatableVector3;
    00352 typedef FCDParameterListAnimatableT<FMVector3, 1> FCDParameterListAnimatableColor3;
    00353 typedef FCDParameterListAnimatableT<FMVector4, 0> FCDParameterListAnimatableVector4;
    00354 typedef FCDParameterListAnimatableT<FMVector4, 1> FCDParameterListAnimatableColor4;
    00371 #define DeclareParameterAnimatable(type, qual, parameterName, niceName) \
    00372     class Parameter_##parameterName : public FCDParameterAnimatableT<type, qual> { \
    00373     public: Parameter_##parameterName(FUParameterizable* parent) : FCDParameterAnimatableT<type, qual>(parent) {} \
    00374     Parameter_##parameterName(FUParameterizable* parent, const type& defaultValue) : FCDParameterAnimatableT<type, qual>(parent, defaultValue) {} \
    00375     virtual ~Parameter_##parameterName() {} \
    00376     Parameter_##parameterName& operator= (const type& copy) { FCDParameterAnimatableT<type, qual>::operator=(copy); return *this; } \
    00377     } parameterName;
    00378
    00380 #define DeclareParameterListAnimatable(type, qual, parameterName, niceName) \
    00381     class Parameter_##parameterName : public FCDParameterListAnimatableT<type, qual> { \
    00382     public: Parameter_##parameterName(FUParameterizable* parent) : FCDParameterListAnimatableT<type, qual>(parent) {} \
    00383     virtual ~Parameter_##parameterName() {} \
    00384     } parameterName;
    00385
    00395 #define InitializeParameterAnimatableNoArg(parameterName) parameterName(this)
    00396
    00397 #define InitializeParameterAnimatable(parameterName, ...) parameterName(this, __VA_ARGS__)
    00398
    00399 #if defined(__APPLE__) || defined(LINUX)
    00400 #include <FCDocument/FCDParameterAnimatable.hpp>
    00401 #endif // MAC + LINUX
    00402
    00403 #endif // _FCD_PARAMETER_ANIMATABLE_H
    00404