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>2009-08-11 12:40:08 +0000
committerStijn Buys <ingar@osirion.org>2009-08-11 12:40:08 +0000
commit95b3f5993151db7607f69132adc604e27e0f55ce (patch)
treecfe9204f1b0a6355ac211acda877170aaaf2600e
parent25bcd92706ce2cd6aee24cfb81e9ff2fd7dd4820 (diff)
implements misc_model rotation angle
-rw-r--r--src/model/map.cc35
-rw-r--r--src/render/draw.cc20
2 files changed, 29 insertions, 26 deletions
diff --git a/src/model/map.cc b/src/model/map.cc
index 164be3e..5d699e6 100644
--- a/src/model/map.cc
+++ b/src/model/map.cc
@@ -660,7 +660,9 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t
// default rotation speed 45 degrees per second
class_speed = 45.0f;
}
+ }
+ if (class_type != FragmentGroup::None) {
group->set_transform(true);
}
@@ -669,6 +671,11 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t
group->set_axis(class_axis);
group->set_speed(class_speed);
+ math::Vector3f group_center(map_center);
+ if (group->transform()) {
+ group_center += group->location();
+ }
+
for (Materials::iterator mit = map_materials.begin(); mit != map_materials.end(); mit++) {
// split the Primitives with this material into fragments
Primitives *primitives = (*mit).second;
@@ -682,9 +689,9 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t
Triangle *triangle = (*tris_it);
if (!triangle->detail()) {
size_t count = 0;
- count += fragment->add_vertex(triangle->v0()-map_center, triangle->normal(), false);
- count += fragment->add_vertex(triangle->v1()-map_center, triangle->normal(), false);
- count += fragment->add_vertex(triangle->v2()-map_center, triangle->normal(), false);
+ count += fragment->add_vertex(triangle->v0()-group_center, triangle->normal(), false);
+ count += fragment->add_vertex(triangle->v1()-group_center, triangle->normal(), false);
+ count += fragment->add_vertex(triangle->v2()-group_center, triangle->normal(), false);
if (count == 3)
model->model_tris_count++;
}
@@ -695,9 +702,9 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t
Triangle *triangle = (*tris_it);
if (triangle->detail()) {
size_t count = 0;
- count += fragment->add_vertex(triangle->v0()-map_center, triangle->normal(), true);
- count += fragment->add_vertex(triangle->v1()-map_center, triangle->normal(), true);
- count += fragment->add_vertex(triangle->v2()-map_center, triangle->normal(), true);
+ count += fragment->add_vertex(triangle->v0()-group_center, triangle->normal(), true);
+ count += fragment->add_vertex(triangle->v1()-group_center, triangle->normal(), true);
+ count += fragment->add_vertex(triangle->v2()-group_center, triangle->normal(), true);
if (count == 3) {
model->model_tris_count++;
model->model_tris_detail_count++;
@@ -718,10 +725,10 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t
Quad *quad = (*quad_it);
if (!quad->detail()) {
size_t count = 0;
- count += fragment->add_vertex(quad->v0()-map_center, quad->normal(), false);
- count += fragment->add_vertex(quad->v1()-map_center, quad->normal(), false);
- count += fragment->add_vertex(quad->v2()-map_center, quad->normal(), false);
- count += fragment->add_vertex(quad->v3()-map_center, quad->normal(), false);
+ count += fragment->add_vertex(quad->v0()-group_center, quad->normal(), false);
+ count += fragment->add_vertex(quad->v1()-group_center, quad->normal(), false);
+ count += fragment->add_vertex(quad->v2()-group_center, quad->normal(), false);
+ count += fragment->add_vertex(quad->v3()-group_center, quad->normal(), false);
if (count == 4)
model->model_quad_count++;
}
@@ -732,10 +739,10 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t
Quad *quad = (*quad_it);
if (quad->detail()) {
size_t count = 0;
- count += fragment->add_vertex(quad->v0()-map_center, quad->normal(), false);
- count += fragment->add_vertex(quad->v1()-map_center, quad->normal(), false);
- count += fragment->add_vertex(quad->v2()-map_center, quad->normal(), false);
- count += fragment->add_vertex(quad->v3()-map_center, quad->normal(), false);
+ count += fragment->add_vertex(quad->v0()-group_center, quad->normal(), false);
+ count += fragment->add_vertex(quad->v1()-group_center, quad->normal(), false);
+ count += fragment->add_vertex(quad->v2()-group_center, quad->normal(), false);
+ count += fragment->add_vertex(quad->v3()-group_center, quad->normal(), false);
if (count == 4) {
model->model_quad_count++;
model->model_quad_detail_count++;
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 339f127..e800d62 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -584,23 +584,19 @@ void draw_model_fragments(model::Model *model,
if (group->transform()) {
gl::push();
- //gl::translate(group->location());
- // FIXME this will go wrong if a Rotate group is imported as submodel
+
+ gl::translate(group->location());
+
if (group->type() == model::FragmentGroup::Rotate) {
- gl::translate(group->location());
float rotation_angle = math::degrees360f(core::application()->time() * group->speed());
gl::rotate(-rotation_angle, group->axis().forward());
- gl::translate(group->location()* -1.0f);
- } else {
- float s = group->scale();
- if (s == 0.0f)
- s = 1.0f;
- gl::scale(s, s, s);
- gl::translate(group->location() / s);
+ } else {
+ gl::multmatrix(group->axis());
}
-
-
+ const float s = group->scale();
+ if (s)
+ gl::scale(s, s, s);
}
for (model::FragmentGroup::iterator fit = group->begin(); fit != group->end(); fit++) {