4 #include <msp/game/component.h>
5 #include <msp/geometry/angle.h>
6 #include <msp/linal/vector.h>
11 float moment_of_inertia = 0.5f;
14 class RigidBody: public Msp::Game::Component
17 using Setup = RigidBodySetup;
21 Msp::LinAl::Vector<float, 2> velocity;
22 Msp::Geometry::Angle<float> angular_velocity;
23 Msp::LinAl::Vector<float, 2> force;
27 RigidBody(Msp::Game::Handle<Msp::Game::Entity>, const Setup &);
29 float get_mass() const { return setup.mass; }
30 float get_moment_of_inertia() const { return setup.moment_of_inertia; }
31 void set_velocity(const Msp::LinAl::Vector<float, 2> &);
32 void set_angular_velocity(Msp::Geometry::Angle<float>);
33 void add_force(const Msp::LinAl::Vector<float, 2> &);
34 void add_force(const Msp::LinAl::Vector<float, 2> &, const Msp::LinAl::Vector<float, 2> &);
35 void add_torque(float);
37 const Msp::LinAl::Vector<float, 2> &get_velocity() const { return velocity; }
38 Msp::Geometry::Angle<float> get_angular_velocity() const { return angular_velocity; }
39 const Msp::LinAl::Vector<float, 2> &get_force() const { return force; }
40 float get_torque() const { return torque; }