diff options
author | Stijn Buys <ingar@osirion.org> | 2011-03-27 15:19:19 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2011-03-27 15:19:19 +0000 |
commit | 6c2075993d68dbacf011756508f957cea1bde845 (patch) | |
tree | c97f2707eb5d36ee33a785139f6ce9e1eb8272a1 /src/model | |
parent | bf84493becfe1a08e9cb906fb85c7268c3a6c910 (diff) |
Corrected rotating fragmentgroups imported from submodels.
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/asefile.cc | 1 | ||||
-rw-r--r-- | src/model/fragment.cc | 1 | ||||
-rw-r--r-- | src/model/fragment.h | 19 | ||||
-rw-r--r-- | src/model/mapfile.cc | 52 |
4 files changed, 41 insertions, 32 deletions
diff --git a/src/model/asefile.cc b/src/model/asefile.cc index 74076c1..ad62029 100644 --- a/src/model/asefile.cc +++ b/src/model/asefile.cc @@ -677,7 +677,6 @@ Model *ASEFile::load(const std::string &name) model->set_radius(model->box().max().length()); model->set_origin(ase_center * -1.0f); - asefile.fragmentgroup()->set_transform(true); asefile.fragmentgroup()->set_location(ase_center * -1.0f); for (FragmentGroup::Fragments::const_iterator fit = asefile.fragmentgroup()->fragments().begin(); fit != asefile.fragmentgroup()->fragments().end(); fit++) { diff --git a/src/model/fragment.cc b/src/model/fragment.cc index 0e0fd00..54ffad9 100644 --- a/src/model/fragment.cc +++ b/src/model/fragment.cc @@ -63,7 +63,6 @@ FragmentGroup::FragmentGroup() { group_type = None; group_scale = 1.0f; - group_transform = false; group_speed = 0.0f; group_engine = false; diff --git a/src/model/fragment.h b/src/model/fragment.h index 58ff4bb..db5f569 100644 --- a/src/model/fragment.h +++ b/src/model/fragment.h @@ -98,6 +98,10 @@ public: return group_location; } + inline const math::Vector3f &movement() const { + return group_movement; + } + inline const math::Axis & axis() const { return group_axis; } @@ -114,10 +118,6 @@ public: return group_scale; } - inline const bool transform() const { - return group_transform; - } - inline const bool engine() const { return group_engine; } @@ -143,6 +143,11 @@ public: inline void set_location(const math::Vector3f &location) { group_location.assign(location); } + + inline void set_movement(const math::Vector3f &movement) { + group_movement.assign(movement); + } + /** * @brief rotation axis @@ -171,10 +176,6 @@ public: group_scale = scale; } - inline void set_transform(const bool transform) { - group_transform = transform; - } - inline void add_fragment(Fragment *fragment) { group_fragments.push_back(fragment); } @@ -191,8 +192,8 @@ private: float group_scale; float group_distance; - bool group_transform; bool group_engine; + math::Vector3f group_movement; }; } diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc index 698a0f6..8f8e87c 100644 --- a/src/model/mapfile.cc +++ b/src/model/mapfile.cc @@ -1160,34 +1160,45 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t { if (!map_materials.size()) return; - - FragmentGroup *group = new FragmentGroup(); - - if (class_type == FragmentGroup::Rotate) { - if (class_speed == 0) { - // default rotation speed 45 degrees per second - class_speed = 45.0f; - } - group->set_speed(class_speed); - group->set_engine(class_engine); - } else if (class_type == FragmentGroup::Move) { - group->set_speed(class_speed); - group->set_distance(class_distance); - group->set_engine(class_engine); - } - // expand bounding box map_box.expand(class_box); // special groups like func_door and func_group are re-centered math::Vector3f translation((class_box.min() + class_box.max()) * 0.5f); - group->set_transform(true); + FragmentGroup *group = new FragmentGroup(); group->set_location(translation); group->set_type(class_type); - group->set_axis(class_axis); - group->set_speed(class_speed); + + // these fragmentgroups are on the same level as worldspawn (no submodels) + // their axis is always the default + + switch (class_type) { + case FragmentGroup::None: + break; + + case FragmentGroup::Rotate: + if (class_speed == 0) { + // default rotation speed 45 degrees per second + class_speed = 45.0f; + } + group->set_speed(class_speed); + group->set_engine(class_engine); + group->set_movement(class_axis.forward()); + break; + + case FragmentGroup::Move: + group->set_speed(class_speed); + group->set_distance(class_distance); + group->set_engine(class_engine); + group->set_movement(class_axis.forward()); + break; + + case FragmentGroup::Door: + group->set_speed(class_speed); + break; + } for (Materials::iterator mit = map_materials.begin(); mit != map_materials.end(); mit++) { // split the Primitives with this material into fragments @@ -1795,7 +1806,7 @@ Model * MapFile::load(std::string const &name) FragmentGroup *groupsrc = (*git); FragmentGroup *groupdst = new FragmentGroup(); - groupdst->set_transform(true); + groupdst->set_movement(groupsrc->movement()); groupdst->set_type(groupsrc->type()); groupdst->set_scale(groupsrc->scale() * tag_submodel->scale()); groupdst->set_engine(groupsrc->engine()); @@ -1881,7 +1892,6 @@ Model * MapFile::load(std::string const &name) // translate transformed vertex groups for (Model::Groups::iterator git = model->groups().begin(); git != model->groups().end(); git++) { FragmentGroup *fragmentgroup = (*git); - fragmentgroup->set_transform(true); fragmentgroup->set_location(fragmentgroup->location() - map_center); } |