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-10-24 22:22:34 +0000
committerStijn Buys <ingar@osirion.org>2010-10-24 22:22:34 +0000
commitfa852cfee26d3bdff0e18589ffb00851b0c25775 (patch)
tree45c2308424e77508fc79708932b5f163ec2992d9 /src/model/asefile.cc
parenta704318f507f486ac04834747eb209d0a9410702 (diff)
corrects model bounding box issues
Diffstat (limited to 'src/model/asefile.cc')
-rw-r--r--src/model/asefile.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/model/asefile.cc b/src/model/asefile.cc
index 0275603..afe74ea 100644
--- a/src/model/asefile.cc
+++ b/src/model/asefile.cc
@@ -680,17 +680,23 @@ Model *ASEFile::load(const std::string &name)
Model *model = new Model(name);
// set bounding box properties
- math::Vector3f origin(0.0f, 0.0f, 0.0f);
- model->set_origin(origin);
- model->model_minbbox.assign (asefile.ase_minbbox * SCALE);
- model->model_maxbbox.assign (asefile.ase_maxbbox * SCALE);
- model->set_radius(math::max(model->model_minbbox.length(), model->model_maxbbox.length()));
+ asefile.ase_minbbox *= SCALE;
+ asefile.ase_maxbbox *= SCALE;
- for (FragmentGroup::Fragments::const_iterator fit = asefile.fragmentgroup()->fragments().begin(); fit != asefile.fragmentgroup()->fragments().end(); fit++) {
-
+ math::Vector3f ase_center((asefile.ase_maxbbox + asefile.ase_minbbox) * 0.5f);
+ 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();
}
+
model->add_group(asefile.fragmentgroup());
con_debug << " " << asefile.name() << " " << asefile.vertexcount() << " vertices " << asefile.facecount() << " faces " << std::endl;