Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/model')
-rw-r--r--src/model/collisionmesh.cc20
-rw-r--r--src/model/collisionmesh.h14
-rw-r--r--src/model/mapfile.cc32
3 files changed, 55 insertions, 11 deletions
diff --git a/src/model/collisionmesh.cc b/src/model/collisionmesh.cc
index 808da63..0bb6580 100644
--- a/src/model/collisionmesh.cc
+++ b/src/model/collisionmesh.cc
@@ -32,7 +32,12 @@ CollisionMesh::CollisionMesh(const CollisionMesh &other)
collisionmesh_scale = other.scale();
collisionmesh_speed = other.speed();
collisionmesh_distance = other.distance();
+
+ collisionmesh_location.assign(other.location());
+ collisionmesh_axis.assign(other.axis());
+ collisionmesh_movement.assign(other.movement());
}
+
CollisionMesh::~CollisionMesh()
{
if (collisionmesh_owns_triangles)
@@ -41,14 +46,15 @@ CollisionMesh::~CollisionMesh()
collisionmesh_triangles = 0;
}
-void CollisionMesh::set_params(const FragmentGroup *group)
+void CollisionMesh::set_params(const FragmentGroup & group)
{
- collisionmesh_type = group->type();
- collisionmesh_location.assign(group->location());
- collisionmesh_axis.assign(group->axis());
- collisionmesh_scale = group->scale();
- collisionmesh_speed = group->speed();
- collisionmesh_distance = group->distance();
+ collisionmesh_type = group.type();
+ collisionmesh_location.assign(group.location());
+ collisionmesh_axis.assign(group.axis());
+ collisionmesh_movement.assign(group.movement());
+ collisionmesh_scale = group.scale();
+ collisionmesh_speed = group.speed();
+ collisionmesh_distance = group.distance();
}
diff --git a/src/model/collisionmesh.h b/src/model/collisionmesh.h
index e80774d..c1f9846 100644
--- a/src/model/collisionmesh.h
+++ b/src/model/collisionmesh.h
@@ -72,6 +72,10 @@ public:
return collisionmesh_axis;
}
+ inline const math::Vector3f &movement() const {
+ return collisionmesh_movement;
+ }
+
inline const float speed() const {
return collisionmesh_speed;
}
@@ -105,12 +109,16 @@ public:
collisionmesh_axis.assign(axis);
}
+ inline void set_movement(const math::Vector3f &movement) {
+ collisionmesh_movement.assign(movement);
+ }
+
/**
* @brief apply FragmentGroup parameters to the mesh
- * This method applies the fragmentgroups type, location, axis, distance, speed and scale
+ * This method applies the fragmentgroups type, location, axis, movement, distance, speed and scale
* to the collision mesh
*/
- void set_params(const FragmentGroup *group);
+ void set_params(const FragmentGroup &group);
/**
* @brief movement speed
@@ -147,6 +155,8 @@ private:
math::Vector3f collisionmesh_location;
math::Axis collisionmesh_axis;
+ math::Vector3f collisionmesh_movement;
+
float collisionmesh_speed;
float collisionmesh_scale;
float collisionmesh_distance;
diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc
index 0abbdbd..270d63f 100644
--- a/src/model/mapfile.cc
+++ b/src/model/mapfile.cc
@@ -1317,8 +1317,36 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t
}
// apply vertexgroup params to the collision mesh
- collisionmesh->set_params(group);
-
+ collisionmesh->set_location(translation);
+ collisionmesh->set_type(class_type);
+
+ // these fragmentgroups are on the same level as worldspawn (no submodels)
+ // their rotation axis is always identity
+
+ switch (class_type) {
+ case FragmentGroup::None:
+ break;
+
+ case FragmentGroup::Rotate:
+ if (class_speed == 0) {
+ // default rotation speed 45 degrees per second
+ class_speed = 45.0f;
+ }
+ collisionmesh->set_speed(class_speed);
+ collisionmesh->set_movement(class_axis.forward());
+ break;
+
+ case FragmentGroup::Move:
+ group->set_speed(class_speed);
+ group->set_distance(class_distance);
+ group->set_movement(class_axis.forward());
+ break;
+
+ case FragmentGroup::Door:
+ group->set_speed(class_speed);
+ break;
+ }
+
// add the collision mesh to the collision model
model->collisionmodel()->add_mesh(collisionmesh);
}