diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/model/asefile.cc | 2 | ||||
-rw-r--r-- | src/model/mapfile.cc | 32 | ||||
-rw-r--r-- | src/render/draw.cc | 1 |
3 files changed, 24 insertions, 11 deletions
diff --git a/src/model/asefile.cc b/src/model/asefile.cc index 64b38d3..74076c1 100644 --- a/src/model/asefile.cc +++ b/src/model/asefile.cc @@ -675,7 +675,7 @@ Model *ASEFile::load(const std::string &name) asefile.box().max() - ase_center ); model->set_radius(model->box().max().length()); - model->set_origin(ase_center); + model->set_origin(ase_center * -1.0f); asefile.fragmentgroup()->set_transform(true); asefile.fragmentgroup()->set_location(ase_center * -1.0f); diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc index c016659..09bb3af 100644 --- a/src/model/mapfile.cc +++ b/src/model/mapfile.cc @@ -1675,9 +1675,29 @@ Model * MapFile::load(std::string const &name) } if (submodel_model) { - tag_submodel->get_location() += submodel_model->origin() * tag_submodel->scale(); + tag_submodel->get_location() -= submodel_model->origin() * tag_submodel->scale(); - // copy fragmentgroups + // adjust the submodel bounding box to the origin + const math::Vector3f min((submodel_model->model_box.min() - submodel_model->origin()) * tag_submodel->scale()); + const math::Vector3f max((submodel_model->model_box.max() - submodel_model->origin()) * tag_submodel->scale()); + + math::Vector3f cube[8]; + cube[0].assign(min.x(), min.y(), min.z()); + cube[1].assign(min.x(), max.y(), min.z()); + cube[2].assign(max.x(), min.y(), min.z()); + cube[3].assign(max.x(), max.y(), min.z()); + + cube[4].assign(min.x(), min.y(), max.z()); + cube[5].assign(min.x(), max.y(), max.z()); + cube[6].assign(max.x(), min.y(), max.z()); + cube[7].assign(max.x(), max.y(), max.z()); + + for (size_t i = 0; i < 8; i++) { + // rotate the bounding box around the origin + mapfile.map_box.expand(tag_submodel->location() + tag_submodel->axis() * cube[i] + submodel_model->origin() * tag_submodel->scale()); + } + + // copy fragmentgroups for (Model::Groups::iterator git = submodel_model->groups().begin(); git != submodel_model->groups().end(); git++) { FragmentGroup *groupsrc = (*git); FragmentGroup *groupdst = new FragmentGroup(); @@ -1715,12 +1735,6 @@ Model * MapFile::load(std::string const &name) } } - // add the scaled submodel bounding box to the map bounding box - mapfile.map_box.expand( - tag_submodel->location() + submodel_model->model_box.min() * tag_submodel->scale(), - tag_submodel->location() + submodel_model->model_box.max() * tag_submodel->scale() - ); - // copy light tags for (Model::Lights::const_iterator lit = submodel_model->lights().begin(); lit != submodel_model->lights().end(); lit++) { tag_light = new Light(*(*lit)); @@ -1769,7 +1783,7 @@ Model * MapFile::load(std::string const &name) ); model->set_radius(model->box().max().length()); - model->set_origin(map_center); + model->set_origin(map_center * -1.0f); // translate transformed vertex groups for (Model::Groups::iterator git = model->groups().begin(); git != model->groups().end(); git++) { diff --git a/src/render/draw.cc b/src/render/draw.cc index 6f97e99..30271f5 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -609,7 +609,6 @@ void draw_model_fragments(model::Model *model, const float rotation_angle = math::degrees360f((group->engine() ? enginetime : core::application()->time()) * group->speed()); gl::rotate(-rotation_angle, group->axis().forward()); } else { - // FIXME group origin is lost gl::multmatrix(group->axis()); } |