void BoxGeometryComponent::draw(Matrix4 transformation) { Point4 rotated_move = rotate(myRotation) * Point4(myMove.x, myMove.y, myMove.z); //Matrix4 total_transform = transformation * translate(Vector4(rotated_move.x, rotated_move.y, rotated_move.z)) * rotate(myRotation) * scale(myScale); Matrix4 total_transform = transformation * translate(myTranslation) * rotate(myRotation) * scale(myScale); Matrix4 transform_noscale = transformation * translate(myTranslation) * rotate(myRotation); std::for_each(myTriangles.begin(), myTriangles.end(), std::bind2nd(std::ptr_fun(TransformAndDraw), total_transform)); // Draw all subcomponents. std::for_each(myComponents.begin(), myComponents.end(), [&transform_noscale](std::shared_ptr<BoxGeometryComponent> x){ x->draw(transform_noscale); }); }
BoxGeometryComponent& BoxGeometryComponent::move() { static const Vector4 move_amount(0.0f, 0.0f, 5.0f); myTranslation += rotate(myRotation) * move_amount; return(*this); }