From ebe064bf159a5c6e90f2bbe902efa16c6e654ff8 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 6 May 2011 16:32:55 +0000 Subject: Always use a btCompoundShape for complex collision, added infrastructure for collision mesh animation, minor API documentation updates --- src/model/collisionmesh.h | 84 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 3 deletions(-) (limited to 'src/model/collisionmesh.h') diff --git a/src/model/collisionmesh.h b/src/model/collisionmesh.h index cbd063a..4ab1c19 100644 --- a/src/model/collisionmesh.h +++ b/src/model/collisionmesh.h @@ -48,13 +48,83 @@ public: inline btTriangleMesh *triangles() { return collisionmesh_triangles; } + + /** + * @brief location of the mesh within the parent model + * location() is a point in collision model coordinate space + * that indicates the (0,0,0) location of this mesh. + * The worldspawn mesh should have location (0,0,0) + * */ + inline const math::Vector3f &location() const { + return collisionmesh_location; + } + + /** + * @brief transformation axis + * For normal groups, this is the rotation matrix of the mesh + * For rotating groups axis->forward() is the axis of the rotation. + * For movers, axis->forward() is the axis of movement. + * */ + inline const math::Axis & axis() const { + return collisionmesh_axis; + } + + inline const float speed() const { + return collisionmesh_speed; + } + inline const float distance() const { + return collisionmesh_distance; + } + + inline const float scale() const { + return collisionmesh_scale; + } + + inline const FragmentGroup::Type type() const { + return collisionmesh_type; + } + /* ---- mutators ------------------------------------------- */ /** * @brief change the group type * */ - void set_type(const FragmentGroup::Type type); + inline void set_type(const FragmentGroup::Type type) { + collisionmesh_type = type; + } + + inline void set_location(const math::Vector3f &location) { + collisionmesh_location.assign(location); + } + + inline void set_axis(const math::Axis &axis) { + collisionmesh_axis.assign(axis); + } + + /** + * @brief apply FragmentGroup parameters to the mesh + * This method applies the fragmentgroups type, location, axis, distance, speed and scale + * to the collision mesh + */ + void set_params(const FragmentGroup *group); + + /** + * @brief movement speed + * For rotating meshes this is the number of degrees per second + * For movers, this is the speed in units per second + */ + inline void set_speed(const float speed) { + collisionmesh_speed = speed; + } + + inline void set_distance(const float distance) { + collisionmesh_distance = distance; + } + + inline void set_scale(const float scale) { + collisionmesh_scale = scale; + } /** * @brief add a triangle to the collision mesh @@ -89,8 +159,8 @@ public: static void add(CollisionMesh *collisionmesh); - static bool initialized() { - return collisionmesh_initialized; + inline static bool initialized() { + return collisionmesh_initialized; } private: @@ -102,6 +172,14 @@ private: size_t collisionmesh_size; btTriangleMesh *collisionmesh_triangles; FragmentGroup::Type collisionmesh_type; + + math::Vector3f collisionmesh_location; + math::Axis collisionmesh_axis; + + float collisionmesh_speed; + float collisionmesh_scale; + float collisionmesh_distance; + }; } // namespace model -- cgit v1.2.3