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>2011-03-30 16:39:27 +0000
committerStijn Buys <ingar@osirion.org>2011-03-30 16:39:27 +0000
commit2aea4a37f8007d429132b9b83da3dda7482be67e (patch)
treeaec6ed7261759ec32b478d23fb7c77299f9e2e1b
parent4f5aa3b27c358815f2574ff65871e7ab291be597 (diff)
Corrected func_move submodel instancing.
-rw-r--r--src/model/mapfile.cc14
-rw-r--r--src/render/draw.cc9
2 files changed, 14 insertions, 9 deletions
diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc
index 8f8e87c..20d4c5c 100644
--- a/src/model/mapfile.cc
+++ b/src/model/mapfile.cc
@@ -1172,7 +1172,7 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t
group->set_type(class_type);
// these fragmentgroups are on the same level as worldspawn (no submodels)
- // their axis is always the default
+ // their rotation axis is always identity
switch (class_type) {
case FragmentGroup::None:
@@ -1805,16 +1805,17 @@ Model * MapFile::load(std::string const &name)
for (Model::Groups::iterator git = submodel_model->groups().begin(); git != submodel_model->groups().end(); git++) {
FragmentGroup *groupsrc = (*git);
FragmentGroup *groupdst = new FragmentGroup();
-
- groupdst->set_movement(groupsrc->movement());
+
groupdst->set_type(groupsrc->type());
groupdst->set_scale(groupsrc->scale() * tag_submodel->scale());
groupdst->set_engine(groupsrc->engine());
groupdst->set_speed(groupsrc->speed());
-
+ groupdst->set_movement(groupsrc->movement());
+ groupdst->set_distance(groupsrc->distance());
+
groupdst->set_location(tag_submodel->location() + tag_submodel->axis() * (groupsrc->location() - submodel_model->origin()) * tag_submodel->scale());
groupdst->set_axis(tag_submodel->axis() * groupsrc->axis());
-
+
// copy fragments, this only copies the original fragment's pointer into the vertex array
for (FragmentGroup::Fragments::const_iterator fit = groupsrc->fragments().begin(); fit != groupsrc->fragments().end(); fit++) {
@@ -1933,6 +1934,9 @@ Model * MapFile::load(std::string const &name)
Triangle *triangle = (*it);
collisionmesh->add_triangle(triangle->v0() - map_center, triangle->v1() - map_center, triangle->v2() - map_center);
}
+
+ // TODO merge submodel collision meshes
+ // seperate collision meshes for movers
// register the mesh
CollisionMesh::add(collisionmesh);
diff --git a/src/render/draw.cc b/src/render/draw.cc
index ecabe21..c19dc39 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -671,13 +671,14 @@ void draw_model_fragments(model::Model *model,
gl::scale(s, s, s);
if (group->type() == model::FragmentGroup::Rotate) {
- const float rotation_angle = math::degrees360f((group->engine() ? enginetime : core::game()->time()) * group->speed());
+ const float rotation_angle = math::degrees360f((group->engine() ? enginetime : core::application()->time()) * group->speed());
gl::rotate(-rotation_angle, group->movement());
- } else if (group->type() == model::FragmentGroup::Move ) {
- const float speed = group->distance() / group->speed(); // units per second
+ } else if (group->type() == model::FragmentGroup::Move ) {
+
+ const float freq = group->speed() / group->distance();
math::Vector3f translation(group->movement() * group->distance());
- translation *= sinf((group->engine() ? enginetime : core::application()->time()) * M_PI * speed) * 0.5f + 0.5f;
+ translation *= sinf((group->engine() ? enginetime : core::application()->time()) * M_PI * freq) * 0.5f + 0.5f;
gl::translate(translation);
}