Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-12-21 12:12:53 +0000
committerStijn Buys <ingar@osirion.org>2008-12-21 12:12:53 +0000
commitaad0913d91fc3b682deddb5a5f8380d1475174f5 (patch)
tree5b1489a36e7640805058d99db0a0c44447949f4a /src/model/map.cc
parentda4b99de2cf290ccdd22587a8c50aeeadd5ac957 (diff)
improved func_rotate
Diffstat (limited to 'src/model/map.cc')
-rw-r--r--src/model/map.cc54
1 files changed, 39 insertions, 15 deletions
diff --git a/src/model/map.cc b/src/model/map.cc
index 71b0dda..c073a4d 100644
--- a/src/model/map.cc
+++ b/src/model/map.cc
@@ -242,14 +242,6 @@ bool Map::getline()
return true;
}
-void Map::clear_bbox()
-{
- for (int i=0; i < 3; i++) {
- class_minbbox[i] = MAX_BOUNDS;
- class_maxbbox[i] = -MAX_BOUNDS;
- }
-}
-
void Map::make_brushface(Plane *face)
{
using math::Vector3f;
@@ -678,6 +670,17 @@ void Map::close()
mapfile_ifs.close();
}
+void Map::clear_bbox()
+{
+ for (int i=0; i < 3; i++) {
+ class_minbbox[i] = MAX_BOUNDS;
+ class_maxbbox[i] = -MAX_BOUNDS;
+ }
+
+ class_angle = 0;
+ class_speed = 0;
+}
+
void Map::load_worldspawn(Model *model)
{
if (!map_materials.size())
@@ -694,7 +697,7 @@ void Map::load_worldspawn(Model *model)
load_fragmentgroup(model, FragmentGroup::None);
}
-void Map::load_fragmentgroup(Model *model, const FragmentGroup::Type type)
+void Map::load_fragmentgroup(Model *model, const FragmentGroup::Type class_type)
{
if (!VertexArray::instance() || VertexArray::instance()->overflow())
return;
@@ -702,9 +705,18 @@ void Map::load_fragmentgroup(Model *model, const FragmentGroup::Type type)
if (!map_materials.size())
return;
+ if (class_type == FragmentGroup::Rotate) {
+ if (class_speed == 0) {
+ // default rotation speed 45 degrees per second
+ class_speed = 45.0f;
+ }
+ }
+
FragmentGroup *group = new FragmentGroup();
- group->set_type(type);
+ group->set_type(class_type);
group->set_location((class_minbbox + class_maxbbox) / 2.0f - map_center);
+ group->set_angle(class_angle);
+ group->set_speed(class_speed);
for (Materials::iterator mit = map_materials.begin(); mit != map_materials.end(); mit++) {
// split the Primitives with this material into fragments
@@ -819,7 +831,7 @@ Model * Map::load(std::string const &name)
mapfile.load_worldspawn(model);
mapfile.clear_materials();
- } else if (mapfile.classname().compare("worldspawn") == 0) {
+ } else if (mapfile.in_class("worldspawn")) {
// worldspawn attributes
if (mapfile.got_key_int("enginesound", u)) {
@@ -832,14 +844,12 @@ Model * Map::load(std::string const &name)
} else if (mapfile.got_key_color("enginecolor", model->model_enginecolor)) {
continue;
-/*
- } else if (mapfile.got_key("name")) {
- continue;
-*/
+
} else if (mapfile.got_key()) {
con_warn "Unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl;
}
+
} else if (mapfile.got_classname("func_door")) {
mapfile.clear_bbox();
@@ -847,6 +857,8 @@ Model * Map::load(std::string const &name)
mapfile.load_fragmentgroup(model, FragmentGroup::Door);
mapfile.clear_materials();
+ } else if (mapfile.in_class("func_door")) {
+
} else if (mapfile.got_classname("func_group")) {
mapfile.clear_bbox();
@@ -861,6 +873,18 @@ Model * Map::load(std::string const &name)
mapfile.load_fragmentgroup(model, FragmentGroup::Rotate);
mapfile.clear_materials();
+ } else if (mapfile.in_class("func_rotate")) {
+
+ if (mapfile.got_key_float("angle", mapfile.class_angle)) {
+ continue;
+
+ } else if (mapfile.got_key_float("speed", mapfile.class_speed)) {
+ continue;
+
+ } else if (mapfile.got_key()) {
+ con_warn "Unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl;
+ }
+
} else if (mapfile.got_classend()) {
mapfile.clear_materials();