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

- File List
- File Members

# FCDocument/FCDPhysicsShape.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
    00014 #ifndef _FCD_PHYSICS_SHAPE_H_
    00015 #define _FCD_PHYSICS_SHAPE_H_
    00016
    00017 #ifndef __FCD_OBJECT_H_
    00018 #include "FCDocument/FCDObject.h"
    00019 #endif // __FCD_OBJECT_H_
    00020 #ifndef _FCD_PHYSICS_ANALYTICAL_GEOM_H_
    00021 #include "FCDocument/FCDPhysicsAnalyticalGeometry.h"
    00022 #endif // _FCD_PHYSICS_ANALYTICAL_GEOM_H_
    00023 #ifndef _FCD_TRANSFORM_H_
    00024 #include "FCDocument/FCDTransform.h"
    00025 #endif // _FCD_TRANSFORM_H_
    00026 #ifndef _FU_DAE_ENUM_H_
    00027 #include "FUtils/FUDaeEnum.h"
    00028 #endif // _FU_DAE_ENUM_H_
    00029
    00030 class FCDEntityInstance;
    00031 class FCDGeometry;
    00032 class FCDGeometryInstance;
    00033 class FCDPhysicsAnalyticalGeometry;
    00034 class FCDPhysicsMaterial;
    00035
    00036 typedef FUObjectContainer<FCDTransform> FCDTransformContainer;
    00047 class FCOLLADA_EXPORT FCDPhysicsShape : public FCDObject
    00048 {
    00049 private:
    00050     DeclareObjectType(FCDObject);
    00051
    00052     bool hollow;
    00053     FUTrackedPtr<FCDPhysicsMaterial> physicsMaterial;
    00054     bool ownsPhysicsMaterial;
    00055
    00056     //one of these two will define the rigid body
    00057     FUTrackedPtr<FCDGeometryInstance> geometry;
    00058     FUObjectRef<FCDPhysicsAnalyticalGeometry> analGeom;
    00059
    00060     float* mass;
    00061     float* density;
    00062     FCDTransformContainer transforms;
    00063     FCDEntityInstance* instanceMaterialRef;
    00064
    00065     bool isDensityMoreAccurate;
    00066
    00067 public:
    00071     FCDPhysicsShape(FCDocument* document);
    00072
    00074     virtual ~FCDPhysicsShape();
    00075
    00078     float GetMass() const;
    00079     const float* GetMassPointer() const { return mass; }
    00083     void SetMass(float mass);
    00084
    00088     bool IsDensityMoreAccurate() const { return isDensityMoreAccurate; }
    00089
    00093     void SetDensityMoreAccurate(bool value){ isDensityMoreAccurate = value; }
    00094
    00097     float GetDensity() const;
    00098     const float* GetDensityPointer() const { return density; }
    00102     void SetDensity(float density);
    00103
    00106     bool IsHollow() const {return hollow;}
    00107
    00110     void SetHollow(bool _hollow) {hollow = _hollow;}
    00111
    00115     bool IsAnalyticalGeometry() const { return analGeom != NULL; }
    00116
    00120     FCDPhysicsAnalyticalGeometry* GetAnalyticalGeometry() { return analGeom; }
    00121     const FCDPhysicsAnalyticalGeometry* GetAnalyticalGeometry() const { return analGeom; }
    00126     void SetAnalyticalGeometry(FCDPhysicsAnalyticalGeometry* aGeom){ analGeom = aGeom; }
    00127
    00131     bool IsGeometryInstance() const { return geometry != NULL; }
    00132
    00136     FCDGeometryInstance* GetGeometryInstance() { return geometry; }
    00137     const FCDGeometryInstance* GetGeometryInstance() const { return geometry; }
    00142     void SetGeometryInstance(FCDGeometryInstance* instance){ geometry = instance; }
    00143
    00150     FCDGeometryInstance* CreateGeometryInstance(FCDGeometry* geom, bool createConvexMesh=false);
    00151
    00157     FCDPhysicsAnalyticalGeometry* CreateAnalyticalGeometry(FCDPhysicsAnalyticalGeometry::GeomType type);
    00158
    00161     FCDTransformContainer& GetTransforms() {return transforms;}
    00162     const FCDTransformContainer& GetTransforms() const {return transforms;}
    00169     FCDTransform* AddTransform(FCDTransform::Type type, size_t index = (size_t)-1);
    00170
    00173     FCDPhysicsMaterial* GetPhysicsMaterial() {return physicsMaterial;}
    00174     const FCDPhysicsMaterial* GetPhysicsMaterial() const {return physicsMaterial;}
    00178     void SetPhysicsMaterial(FCDPhysicsMaterial* physicsMaterial);
    00179
    00183     FCDPhysicsMaterial* AddOwnPhysicsMaterial();
    00184
    00190     FCDPhysicsShape* Clone(FCDPhysicsShape* clone = NULL) const;
    00191
    00197     float CalculateVolume() const;
    00198
    00202     void SetInstanceMaterial(FCDEntityInstance* instance){ instanceMaterialRef = instance; }
    00203
    00207     FCDEntityInstance* GetInstanceMaterial(){ return instanceMaterialRef; }
    00208
    00212     bool OwnsPhysicsMaterial() { return ownsPhysicsMaterial; }
    00213
    00214
    00215 };
    00216
    00217 #endif // _FCD_PHYSICS_SHAPE_H_