| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- $#include "CollisionShape.h"
- /// Collision shape type.
- enum ShapeType
- {
- SHAPE_BOX = 0,
- SHAPE_SPHERE,
- SHAPE_STATICPLANE,
- SHAPE_CYLINDER,
- SHAPE_CAPSULE,
- SHAPE_CONE,
- SHAPE_TRIANGLEMESH,
- SHAPE_CONVEXHULL,
- SHAPE_TERRAIN
- };
- /// Physics collision shape component.
- class CollisionShape : public Component
- {
- public:
- /// Set as a box.
- void SetBox(const Vector3& size, const Vector3& position = Vector3::ZERO, const Quaternion& rotation = Quaternion::IDENTITY);
- /// Set as a sphere.
- void SetSphere(float diameter, const Vector3& position = Vector3::ZERO, const Quaternion& rotation = Quaternion::IDENTITY);
- /// Set as a static plane.
- void SetStaticPlane(const Vector3& position = Vector3::ZERO, const Quaternion& rotation = Quaternion::IDENTITY);
- /// Set as a cylinder.
- void SetCylinder(float diameter, float height, const Vector3& position = Vector3::ZERO, const Quaternion& rotation = Quaternion::IDENTITY);
- /// Set as a capsule.
- void SetCapsule(float diameter, float height, const Vector3& position = Vector3::ZERO, const Quaternion& rotation = Quaternion::IDENTITY);
- /// Set as a cone.
- void SetCone(float diameter, float height, const Vector3& position = Vector3::ZERO, const Quaternion& rotation = Quaternion::IDENTITY);
- /// Set as a triangle mesh.
- void SetTriangleMesh(Model* model, unsigned lodLevel = 0, const Vector3& scale = Vector3::ONE, const Vector3& position = Vector3::ZERO, const Quaternion& rotation = Quaternion::IDENTITY);
- /// Set as a convex hull from Model.
- void SetConvexHull(Model* model, unsigned lodLevel = 0, const Vector3& scale = Vector3::ONE, const Vector3& position = Vector3::ZERO, const Quaternion& rotation = Quaternion::IDENTITY);
- /// Set as a terrain. Only works if the same scene node contains a Terrain component.
- void SetTerrain();
- /// Set shape type.
- void SetShapeType(ShapeType type);
- /// Set shape size.
- void SetSize(const Vector3& size);
- /// Set offset position.
- void SetPosition(const Vector3& position);
- /// Set offset rotation.
- void SetRotation(const Quaternion& rotation);
- /// Set offset transform.
- void SetTransform(const Vector3& position, const Quaternion& rotation);
- /// Set collision margin.
- void SetMargin(float margin);
- /// Set triangle mesh / convex hull model.
- void SetModel(Model* model);
- /// Set model LOD level.
- void SetLodLevel(unsigned lodLevel);
-
- /// Return physics world.
- PhysicsWorld* GetPhysicsWorld() const;
- /// Return shape type.
- ShapeType GetShapeType() const;
- /// Return shape size.
- const Vector3& GetSize() const;
- /// Return offset position.
- const Vector3& GetPosition() const;
- /// Return offset rotation.
- const Quaternion& GetRotation() const;
- /// Return collision margin.
- float GetMargin() const;
- /// Return triangle mesh / convex hull model.
- Model* GetModel() const;
- /// Return model LOD level.
- unsigned GetLodLevel() const;
- /// Return world-space bounding box.
- BoundingBox GetWorldBoundingBox() const;
-
- /// Update the new collision shape to the RigidBody.
- void NotifyRigidBody(bool updateMass = true);
- /// Set model attribute.
- void SetModelAttr(ResourceRef value);
- /// Return model attribute.
- ResourceRef GetModelAttr() const;
- /// Release the collision shape.
- void ReleaseShape();
- };
|