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

- File List
- File Members

# FCDocument/FCDTransform.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
    00021 #ifndef _FCD_TRANSFORM_H_
    00022 #define _FCD_TRANSFORM_H_
    00023
    00024 class FCDocument;
    00025 class FCDAnimated;
    00026 class FCDSceneNode;
    00027 class FCDTransform;
    00028
    00029 #ifndef __FCD_OBJECT_H_
    00030 #include "FCDocument/FCDObject.h"
    00031 #endif // __FCD_OBJECT_H_
    00032 #ifndef _FM_QUATERNION_H_
    00033 #include "FMath/FMQuaternion.h"
    00034 #endif // _FM_QUATERNION_H_
    00035 #ifndef _FCD_PARAMETER_ANIMATABLE_H_
    00036 #include "FCDocument/FCDParameterAnimatable.h"
    00037 #endif // _FCD_PARAMETER_ANIMATABLE_H_
    00038
    00048 class FCOLLADA_EXPORT FCDTransform : public FCDObject
    00049 {
    00050 public:
    00052     enum Type
    00053     {
    00054         TRANSLATION,
    00055         ROTATION,
    00056         SCALE,
    00057         MATRIX,
    00058         LOOKAT,
    00059         SKEW,
    00060         TYPE_COUNT
    00061     };
    00062
    00063 private:
    00064     DeclareObjectType(FCDObject);
    00065     FCDSceneNode* parent;
    00066     DeclareParameter(fm::string, FUParameterQualifiers::SIMPLE, sid, FC("Sub-id"));
    00067
    00068 public:
    00075     FCDTransform(FCDocument* document, FCDSceneNode* parent);
    00076
    00078     virtual ~FCDTransform();
    00079
    00083     FCDSceneNode* GetParent() { return parent; }
    00084     const FCDSceneNode* GetParent() const { return parent; }
    00087     DEPRECATED(3.05, SetValueChange)
    00088     void SetTransformsDirtyFlag();
    00089
    00093     virtual FCDTransform* Clone(FCDTransform* clone = NULL) const = 0;
    00094
    00098     virtual Type GetType() const = 0;
    00099
    00103     virtual FMMatrix44 ToMatrix() const = 0;
    00104
    00109     inline FUParameterString& GetSubId() { return sid; }
    00110     inline const FUParameterString& GetSubId() const { return sid; }
    00116     void SetSubId(const fm::string& subId);
    00117
    00120     virtual bool IsAnimated() const = 0;
    00121
    00125     inline FCDAnimated* GetAnimated() { return const_cast<FCDAnimated*>(const_cast<const FCDTransform*>(this)->GetAnimated()); }
    00126     virtual const FCDAnimated* GetAnimated() const = 0;
    00134     virtual bool IsInverse(const FCDTransform* transform) const;
    00135
    00137     virtual void SetValueChange();
    00138 };
    00139
    00146 class FCOLLADA_EXPORT FCDTTranslation : public FCDTransform
    00147 {
    00148 private:
    00149     DeclareObjectType(FCDTransform);
    00150     DeclareParameterAnimatable(FMVector3, FUParameterQualifiers::VECTOR, translation, FC("Translation"));
    00151
    00152 public:
    00160     FCDTTranslation(FCDocument* document, FCDSceneNode* parent);
    00161
    00163     virtual ~FCDTTranslation();
    00164
    00167     virtual Type GetType() const { return TRANSLATION; }
    00168
    00172     inline FCDParameterAnimatableVector3& GetTranslation() { return translation; }
    00173     inline const FCDParameterAnimatableVector3& GetTranslation() const { return translation; }
    00177     inline void SetTranslation(const FMVector3& _translation) { translation = _translation; SetValueChange(); }
    00178
    00183     inline void SetTranslation(float x, float y, float z) { translation = FMVector3(x, y, z); SetValueChange(); }
    00184
    00187     virtual FMMatrix44 ToMatrix() const;
    00188
    00191     virtual bool IsAnimated() const;
    00192
    00196     inline FCDAnimated* GetAnimated() { return Parent::GetAnimated(); }
    00197     virtual const FCDAnimated* GetAnimated() const;
    00204     virtual bool IsInverse(const FCDTransform* transform) const;
    00205
    00209     virtual FCDTransform* Clone(FCDTransform* clone = NULL) const;
    00210 };
    00211
    00217 class FCOLLADA_EXPORT FCDTScale : public FCDTransform
    00218 {
    00219 private:
    00220     DeclareObjectType(FCDTransform);
    00221     DeclareParameterAnimatable(FMVector3, FUParameterQualifiers::VECTOR, scale, FC("Scale"));
    00222
    00223 public:
    00231     FCDTScale(FCDocument* document, FCDSceneNode* parent);
    00232
    00234     virtual ~FCDTScale();
    00235
    00238     virtual Type GetType() const { return SCALE; }
    00239
    00243     inline FCDParameterAnimatableVector3& GetScale() { return scale; }
    00244     inline const FCDParameterAnimatableVector3& GetScale() const { return scale; }
    00248     inline void SetScale(const FMVector3& _scale) { scale = _scale; SetValueChange(); }
    00249
    00254     inline void SetScale(float x, float y, float z) { scale = FMVector3(x, y, z); SetValueChange(); }
    00255
    00258     virtual FMMatrix44 ToMatrix() const;
    00259
    00262     virtual bool IsAnimated() const;
    00263
    00267     inline FCDAnimated* GetAnimated() { return Parent::GetAnimated(); }
    00268     virtual const FCDAnimated* GetAnimated() const;
    00273     virtual FCDTransform* Clone(FCDTransform* clone = NULL) const;
    00274 };
    00275
    00283 class FCOLLADA_EXPORT FCDTRotation : public FCDTransform
    00284 {
    00285 private:
    00286     DeclareObjectType(FCDTransform);
    00287     DeclareParameterAnimatable(FMAngleAxis, FUParameterQualifiers::SIMPLE, angleAxis, FC("Angle-axis"));
    00288
    00289 public:
    00297     FCDTRotation(FCDocument* document, FCDSceneNode* parent);
    00298
    00300     virtual ~FCDTRotation();
    00301
    00304     virtual Type GetType() const { return ROTATION; }
    00305
    00308     inline FCDParameterAnimatableAngleAxis& GetAngleAxis() { return angleAxis; }
    00309     inline const FCDParameterAnimatableAngleAxis& GetAngleAxis() const { return angleAxis; }
    00313     inline void SetAngleAxis(const FMAngleAxis& aa) { angleAxis = aa; SetValueChange(); }
    00314
    00318     inline FMVector3& GetAxis() { return angleAxis->axis; }
    00319     inline const FMVector3& GetAxis() const { return angleAxis->axis; }
    00323     inline void SetAxis(const FMVector3& axis) { angleAxis->axis = axis; SetValueChange(); }
    00324
    00329     inline void SetAxis(float x, float y, float z) { angleAxis->axis = FMVector3(x, y, z); SetValueChange(); }
    00330
    00334     inline float& GetAngle() { return angleAxis->angle; }
    00335     inline const float& GetAngle() const { return angleAxis->angle; }
    00339     inline void SetAngle(float a) { angleAxis->angle = a; SetValueChange(); }
    00340
    00344     inline void SetRotation(const FMVector3& axis, float angle) { angleAxis = FMAngleAxis(axis, angle); SetValueChange(); }
    00345
    00348     inline FMQuaternion GetOrientation() { return FMQuaternion(angleAxis->axis, FMath::DegToRad(angleAxis->angle)); }
    00349
    00352     inline void SetOrientation(const FMQuaternion& q) { q.ToAngleAxis(angleAxis->axis, angleAxis->angle); angleAxis->angle = FMath::RadToDeg(angleAxis->angle); SetValueChange(); }
    00353
    00356     virtual FMMatrix44 ToMatrix() const;
    00357
    00360     virtual bool IsAnimated() const;
    00361
    00366     inline FCDAnimated* GetAnimated() { return Parent::GetAnimated(); }
    00367     virtual const FCDAnimated* GetAnimated() const;
    00374     virtual bool IsInverse(const FCDTransform* transform) const;
    00375
    00379     virtual FCDTransform* Clone(FCDTransform* clone = NULL) const;
    00380 };
    00381
    00388 class FCOLLADA_EXPORT FCDTMatrix : public FCDTransform
    00389 {
    00390 private:
    00391     DeclareObjectType(FCDTransform);
    00392     DeclareParameterAnimatable(FMMatrix44, FUParameterQualifiers::SIMPLE, transform, FC("Transform"));
    00393
    00394 public:
    00400     FCDTMatrix(FCDocument* document, FCDSceneNode* parent);
    00401
    00403     virtual ~FCDTMatrix();
    00404
    00407     virtual Type GetType() const { return MATRIX; }
    00408
    00412     inline FCDParameterAnimatableMatrix44& GetTransform() { return transform; }
    00413     inline const FCDParameterAnimatableMatrix44& GetTransform() const { return transform; }
    00417     inline void SetTransform(const FMMatrix44& mx) { transform = mx; SetValueChange(); }
    00418
    00422     virtual FMMatrix44 ToMatrix() const { return transform; }
    00423
    00426     virtual bool IsAnimated() const;
    00427
    00432     inline FCDAnimated* GetAnimated() { return Parent::GetAnimated(); }
    00433     virtual const FCDAnimated* GetAnimated() const;
    00438     virtual FCDTransform* Clone(FCDTransform* clone = NULL) const;
    00439 };
    00440
    00448 class FCOLLADA_EXPORT FCDTLookAt : public FCDTransform
    00449 {
    00450 private:
    00451     DeclareObjectType(FCDTransform);
    00452     DeclareParameterAnimatable(FMLookAt, FUParameterQualifiers::SIMPLE, lookAt, FC("LookAt"));
    00453
    00454 public:
    00460     FCDTLookAt(FCDocument* document, FCDSceneNode* parent);
    00461
    00463     virtual ~FCDTLookAt();
    00464
    00467     virtual Type GetType() const { return LOOKAT; }
    00468
    00471     inline FCDParameterAnimatableLookAt& GetLookAt() { return lookAt; }
    00472     inline const FCDParameterAnimatableLookAt& GetLookAt() const { return lookAt; }
    00476     inline void SetLookAt(const FMLookAt& _lookAt) { lookAt = _lookAt; SetValueChange(); }
    00477
    00480     FMVector3& GetPosition() { return lookAt->position; }
    00481     const FMVector3& GetPosition() const { return lookAt->position; }
    00485     inline void SetPosition(const FMVector3& pos) { lookAt->position = pos; SetValueChange(); }
    00486
    00491     inline void SetPosition(float x, float y, float z) { lookAt->position = FMVector3(x, y, z); SetValueChange(); }
    00492
    00495     FMVector3& GetTarget() { return lookAt->target; }
    00496     const FMVector3& GetTarget() const { return lookAt->target; }
    00500     inline void SetTarget(const FMVector3& target) { lookAt->target = target; SetValueChange(); }
    00501
    00506     inline void SetTarget(float x, float y, float z) { lookAt->target = FMVector3(x, y, z); SetValueChange(); }
    00507
    00510     FMVector3& GetUp() { return lookAt->up; }
    00511     const FMVector3& GetUp() const { return lookAt->up; }
    00515     inline void SetUp(const FMVector3& up) { lookAt->up = up; SetValueChange(); }
    00516
    00521     inline void SetUp(float x, float y, float z) { lookAt->up = FMVector3(x, y, z); SetValueChange(); }
    00522
    00525     virtual FMMatrix44 ToMatrix() const;
    00526
    00530     virtual bool IsAnimated() const;
    00531
    00536     inline FCDAnimated* GetAnimated() { return Parent::GetAnimated(); }
    00537     virtual const FCDAnimated* GetAnimated() const;
    00542     virtual FCDTransform* Clone(FCDTransform* clone = NULL) const;
    00543 };
    00544
    00552 class FCOLLADA_EXPORT FCDTSkew : public FCDTransform
    00553 {
    00554 private:
    00555     DeclareObjectType(FCDTransform);
    00556     DeclareParameterAnimatable(FMSkew, FUParameterQualifiers::SIMPLE, skew, FC("Skew"));
    00557
    00558 public:
    00564     FCDTSkew(FCDocument* document, FCDSceneNode* parent);
    00565
    00567     virtual ~FCDTSkew();
    00568
    00571     virtual Type GetType() const { return SKEW; }
    00572
    00575     inline FCDParameterAnimatableSkew& GetSkew() { return skew; }
    00576     inline const FCDParameterAnimatableSkew& GetSkew() const { return skew; }
    00577
    00580     inline void SetSkew(const FMSkew& _skew) { skew = _skew; SetValueChange(); }
    00581
    00584     const FMVector3& GetRotateAxis() const { return skew->rotateAxis; }
    00585     FMVector3& GetRotateAxis() { return skew->rotateAxis; }
    00589     inline void SetRotateAxis(const FMVector3& axis) { skew->rotateAxis = axis; SetValueChange(); }
    00590
    00593     inline const FMVector3& GetAroundAxis() const { return skew->aroundAxis; }
    00594     inline FMVector3& GetAroundAxis() { return skew->aroundAxis; }
    00598     inline void SetAroundAxis(const FMVector3& axis) { skew->aroundAxis = axis; SetValueChange(); }
    00599
    00602     inline const float& GetAngle() const { return skew->angle; }
    00603     inline float& GetAngle() { return skew->angle; }
    00607     inline void SetAngle(float angle) { skew->angle = angle; SetValueChange(); }
    00608
    00611     virtual FMMatrix44 ToMatrix() const;
    00612
    00615     virtual bool IsAnimated() const;
    00616
    00619     inline FCDAnimated* GetAnimated() { return Parent::GetAnimated(); }
    00620     virtual const FCDAnimated* GetAnimated() const;
    00625     virtual FCDTransform* Clone(FCDTransform* clone = NULL) const;
    00626 };
    00627
    00633 class FCOLLADA_EXPORT FCDTFactory
    00634 {
    00635 private:
    00636     FCDTFactory() {} // Static class: do not instantiate.
    00637
    00638 public:
    00645     static FCDTransform* CreateTransform(FCDocument* document, FCDSceneNode* parent, FCDTransform::Type type);
    00646 };
    00647
    00648 #endif // _FR_TRANSFORM_H_