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;
16 Msp::LinAl::Vector<float, 2> velocity;
17 Msp::Geometry::Angle<float> angular_velocity;
18 Msp::LinAl::Vector<float, 2> force;
22 class RigidBody: public Msp::Game::BufferedComponent<RigidBodyData>
25 using Setup = RigidBodySetup;
31 RigidBody(Msp::Game::Handle<Msp::Game::Entity>, const Setup &);
33 float get_mass() const { return setup.mass; }
34 float get_moment_of_inertia() const { return setup.moment_of_inertia; }
35 void set_velocity(const Msp::LinAl::Vector<float, 2> &);
36 void set_angular_velocity(Msp::Geometry::Angle<float>);
37 void add_force(const Msp::LinAl::Vector<float, 2> &);
38 void add_force(const Msp::LinAl::Vector<float, 2> &, const Msp::LinAl::Vector<float, 2> &);
39 void add_torque(float);
41 const Msp::LinAl::Vector<float, 2> &get_velocity() const { return read().velocity; }
42 Msp::Geometry::Angle<float> get_angular_velocity() const { return read().angular_velocity; }
43 const Msp::LinAl::Vector<float, 2> &get_force() const { return read().force; }
44 float get_torque() const { return read().torque; }