Rotation translation corrected.

This commit is contained in:
jaynus 2015-05-11 14:55:47 -07:00
parent 6cc232ae12
commit 133bd0e817
2 changed files with 10 additions and 13 deletions

View File

@ -42,7 +42,7 @@ void ace::simulation::vertex::animate(const glm::mat4 &matrix, ace::vector3<floa
temp_gl_vector = matrix*temp_gl_vector; temp_gl_vector = matrix*temp_gl_vector;
this->animated_vertex = ace::vector3<float>(temp_gl_vector.x, temp_gl_vector.y, temp_gl_vector.z); this->animated_vertex = ace::vector3<float>(temp_gl_vector.x, temp_gl_vector.y, temp_gl_vector.z);
if (offset) { if (offset) {
this->animated_vertex = this->animated_vertex + rotation_offset; // this->animated_vertex = this->animated_vertex + rotation_offset;
} }
} }
@ -215,7 +215,7 @@ animation_transform ace::simulation::animation::animate(const float phase, const
for (auto lod_id : lods) { for (auto lod_id : lods) {
glm::mat4 base_matrix = base_transforms[lod_id].first; glm::mat4 base_matrix = base_transforms[lod_id].first;
ace::vector3<float> base_rotation_offset = base_transforms[lod_id].second; ace::vector3<float> base_rotation_offset = base_transforms[lod_id].second;
glm::mat4 animation_matrix; glm::mat4 animation_matrix, direction_matrix;
ace::vector3<float> rotation_offset = ace::vector3<float>(0, 0, 0); ace::vector3<float> rotation_offset = ace::vector3<float>(0, 0, 0);
float scale = get_scale(phase); float scale = get_scale(phase);
@ -224,8 +224,13 @@ animation_transform ace::simulation::animation::animate(const float phase, const
//rotation //rotation
case 0: { case 0: {
scale = (scale / (max_value - min_value)) * (angle1 - angle0); scale = (scale / (max_value - min_value)) * (angle1 - angle0);
glm::vec3 rotation_axis = glm::vec3(this->lod_info[lod_id]->axis_direction.x(), this->lod_info[lod_id]->axis_direction.y(), this->lod_info[lod_id]->axis_direction.z()); glm::vec3 rotation_axis = glm::vec3(this->lod_info[lod_id]->axis_position.x(), this->lod_info[lod_id]->axis_position.y(), this->lod_info[lod_id]->axis_position.z());
animation_matrix = glm::rotate(animation_matrix, -scale, rotation_axis); glm::vec3 rotation_direction = glm::vec3(this->lod_info[lod_id]->axis_direction.x(), this->lod_info[lod_id]->axis_direction.y(), this->lod_info[lod_id]->axis_direction.z());
animation_matrix = glm::rotate(glm::mat4(1.0f), scale, rotation_direction);
direction_matrix = glm::translate(glm::mat4(1.0f), rotation_axis);
animation_matrix = animation_matrix * direction_matrix;
rotation_offset = this->lod_info[lod_id]->axis_position; rotation_offset = this->lod_info[lod_id]->axis_position;
break; break;
} }

View File

@ -129,23 +129,15 @@ namespace ace {
ace::vector3<float> hit_from, hit_to; ace::vector3<float> hit_from, hit_to;
hit_from = hit->impactposition; hit_from = hit->impactposition;
hit_to = hit_from + (hit->impactvelocity * 0.005f); hit_to = hit_from + (hit->impactvelocity * 0.01f);
XMVECTORF32 from = { hit_from.x(), hit_from.y(), hit_from.z() }; XMVECTORF32 from = { hit_from.x(), hit_from.y(), hit_from.z() };
XMVECTORF32 to = { hit_to.x(), hit_to.y(), hit_to.z() }; XMVECTORF32 to = { hit_to.x(), hit_to.y(), hit_to.z() };
XMVECTORF32 to_a1 = { hit_to.x() + 0.5, hit_to.y() + 0.5, hit_to.z() };
XMVECTORF32 to_a2 = { hit_to.x() - 0.5, hit_to.y() - 0.5, hit_to.z() };
VertexPositionColor v1(from, color); VertexPositionColor v1(from, color);
VertexPositionColor v2(to, color); VertexPositionColor v2(to, color);
VertexPositionColor a1(to_a2, color);
VertexPositionColor a2(to_a1, color);
batch.DrawLine(v1, v2); batch.DrawLine(v1, v2);
batch.DrawLine(a1, v2);
batch.DrawLine(a2, v2);
} }