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>2010-11-08 14:34:44 +0000
committerStijn Buys <ingar@osirion.org>2010-11-08 14:34:44 +0000
commitb7dc0938eb7d59f928bbcf2a3a4877a6f60940e5 (patch)
tree5b4b4353f2012fced4180072e0b0def8ba8d22db /src/model/asefile.cc
parentb685a594ae43aa30173912c9fb1177d507ec5a08 (diff)
moved clear() from game::Game~ to core::GameServer~ (solves FIXME),
unified bounding box code into math::BoundingBox3f class
Diffstat (limited to 'src/model/asefile.cc')
-rw-r--r--src/model/asefile.cc34
1 files changed, 11 insertions, 23 deletions
diff --git a/src/model/asefile.cc b/src/model/asefile.cc
index c9dfe1c..64b38d3 100644
--- a/src/model/asefile.cc
+++ b/src/model/asefile.cc
@@ -22,10 +22,7 @@ ASEFile::ASEFile(std::string const &name)
asefile_name.append(".ase");
asefile_ifs.open(asefile_name);
- for (int i = 0; i < 3; i++) {
- ase_minbbox[i] = 0;
- ase_maxbbox[i] = 0;
- }
+ ase_box.assign(MAX_BOUNDS, - MAX_BOUNDS);
// a single fragmentgroup wil contain all the model triangles
ase_fragmentgroup = new FragmentGroup();
@@ -263,15 +260,7 @@ bool ASEFile::read_mesh_vertex_list(std::istream &is)
if (line >> index >> x >> y >> z) {
math::Vector3f *v = new math::Vector3f(x, y, z);
ase_vertexlist[index] = v;
-
- for (size_t i = 0; i < 3; i++) {
- if ((*v)[i] > ase_maxbbox[i]) {
- ase_maxbbox[i] = (*v)[i];
- }
- if ((*v)[i] < ase_minbbox[i]) {
- ase_minbbox[i] = (*v)[i];
- }
- }
+ ase_box.expand(*v * SCALE);
ase_vertexcount++;
}
}
@@ -679,19 +668,18 @@ Model *ASEFile::load(const std::string &name)
// create a new model
Model *model = new Model(name);
- // set bounding box properties
- asefile.ase_minbbox *= SCALE;
- asefile.ase_maxbbox *= SCALE;
-
- math::Vector3f ase_center((asefile.ase_maxbbox + asefile.ase_minbbox) * 0.5f);
+ // center model around (0,0,0) and set the bounding box
+ math::Vector3f ase_center((asefile.box().min() + asefile.box().max()) * 0.5f);
+ model->model_box.assign(
+ asefile.box().min() - ase_center,
+ asefile.box().max() - ase_center
+ );
+ model->set_radius(model->box().max().length());
+ model->set_origin(ase_center);
+
asefile.fragmentgroup()->set_transform(true);
asefile.fragmentgroup()->set_location(ase_center * -1.0f);
- model->model_minbbox.assign(asefile.ase_minbbox - ase_center);
- model->model_maxbbox.assign(asefile.ase_maxbbox - ase_center);
- model->set_radius(asefile.ase_maxbbox.length());
- model->set_origin(ase_center);
-
for (FragmentGroup::Fragments::const_iterator fit = asefile.fragmentgroup()->fragments().begin(); fit != asefile.fragmentgroup()->fragments().end(); fit++) {
const Fragment *fragment = (*fit);
model->model_tris_count += (fragment->structural_size() + fragment->detail_size()) / 3;