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-20 14:54:17 +0000
committerStijn Buys <ingar@osirion.org>2008-12-20 14:54:17 +0000
commitf36ec64b08c791e7b907ed8efd9a2baa44e7f8fd (patch)
treed86d6d948fa35b58b0955d994291e27910355a40 /src/model/map.cc
parent34747fcb6a29ee573cf432611359ef34fe680dec (diff)
initial support for func_rotate and friends
Diffstat (limited to 'src/model/map.cc')
-rw-r--r--src/model/map.cc65
1 files changed, 46 insertions, 19 deletions
diff --git a/src/model/map.cc b/src/model/map.cc
index f2c519f..71b0dda 100644
--- a/src/model/map.cc
+++ b/src/model/map.cc
@@ -242,6 +242,14 @@ 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;
@@ -445,7 +453,7 @@ void Map::make_brushface(Plane *face)
// default material is none
unsigned int material = 0;
- // default color makrs unknown textures hot pink
+ // default color makes unknown textures hot pink
math::Color color(1.0f, 0.0, 1.0f, 1.0f);
// translate texture names to color and material
@@ -516,9 +524,7 @@ void Map::make_brushface(Plane *face)
// calculate bounding box
for (std::vector<Vector3f *>::iterator it = vl.begin(); it != vl.end(); it++) {
-
*(*it) *= SCALE;
-
for (int i=0; i < 3; i++) {
if (class_maxbbox[i] < (*(*it))[i])
class_maxbbox[i] = (*(*it))[i];
@@ -528,6 +534,7 @@ void Map::make_brushface(Plane *face)
}
}
+ // split polygon into quads
while (vl.size() > 3) {
std::vector<Vector3f *>::iterator v0 = vl.begin();
std::vector<Vector3f *>::reverse_iterator vn = vl.rbegin();
@@ -677,24 +684,28 @@ void Map::load_worldspawn(Model *model)
return;
// FIXME center in maps without brushes
- map_center = (class_minbbox + class_maxbbox) / 2;
+ map_center = (class_minbbox + class_maxbbox) / 2.0f;
model->model_minbbox = class_minbbox - map_center;
model->model_maxbbox = class_maxbbox - map_center;
model->model_radius = model->model_maxbbox.length();
- load_fragmentgroup(model, model->worldspawn());
+ load_fragmentgroup(model, FragmentGroup::None);
}
-void Map::load_fragmentgroup(Model *model, FragmentGroup &group)
+void Map::load_fragmentgroup(Model *model, const FragmentGroup::Type type)
{
if (!VertexArray::instance() || VertexArray::instance()->overflow())
return;
if (!map_materials.size())
return;
-
+
+ FragmentGroup *group = new FragmentGroup();
+ group->set_type(type);
+ group->set_location((class_minbbox + class_maxbbox) / 2.0f - map_center);
+
for (Materials::iterator mit = map_materials.begin(); mit != map_materials.end(); mit++) {
// split the Primitives with this material into fragments
Primitives *primitives = (*mit).second;
@@ -731,8 +742,8 @@ void Map::load_fragmentgroup(Model *model, FragmentGroup &group)
}
}
- // add the fragment to the fragment group
- group.push_back(fragment);
+ // add the fragment to the group
+ group->push_back(fragment);
}
// store quads
@@ -769,12 +780,14 @@ void Map::load_fragmentgroup(Model *model, FragmentGroup &group)
}
}
- // add the fragment to the model
- group.push_back(fragment);
+ // add the fragment to the group
+ group->push_back(fragment);
}
}
-
+
+ // add the group to the model
+ model->add_group(group);
}
Model * Map::load(std::string const &name)
@@ -787,6 +800,7 @@ Model * Map::load(std::string const &name)
}
Model *model = new Model(name);
+ mapfile.clear_bbox();
Dock *dock = 0;
Particles *particles = 0;
@@ -799,13 +813,12 @@ Model * Map::load(std::string const &name)
while (mapfile.getline()) {
if (mapfile.got_classname("worldspawn")) {
- // new wordspawn
-
- } else if (mapfile.got_classend("worldspawn")) {
+ mapfile.clear_bbox();
+ } else if (mapfile.got_classend("worldspawn")) {
mapfile.load_worldspawn(model);
mapfile.clear_materials();
-
+
} else if (mapfile.classname().compare("worldspawn") == 0) {
// worldspawn attributes
@@ -827,14 +840,28 @@ Model * Map::load(std::string const &name)
con_warn "Unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl;
}
+ } else if (mapfile.got_classname("func_door")) {
+ mapfile.clear_bbox();
+
+ } else if (mapfile.got_classend("func_door")) {
+ mapfile.load_fragmentgroup(model, FragmentGroup::Door);
+ mapfile.clear_materials();
+
+ } else if (mapfile.got_classname("func_group")) {
+ mapfile.clear_bbox();
} else if (mapfile.got_classend("func_group")) {
+ mapfile.load_fragmentgroup(model, FragmentGroup::None);
+ mapfile.clear_materials();
- // func_group fragments are loaded into worldspawn
- mapfile.load_fragmentgroup(model, model->worldspawn());
+ } else if (mapfile.got_classname("func_rotate")) {
+ mapfile.clear_bbox();
- } else if (mapfile.got_classend()) {
+ } else if (mapfile.got_classend("func_rotate")) {
+ mapfile.load_fragmentgroup(model, FragmentGroup::Rotate);
+ mapfile.clear_materials();
+ } else if (mapfile.got_classend()) {
mapfile.clear_materials();
} else if (mapfile.got_classname("light")) {