4 #include <msp/game/component.h>
5 #include <msp/geometry/angle.h>
6 #include <msp/linal/vector.h>
11 Msp::LinAl::Vector<float, 2> velocity;
12 Msp::Geometry::Angle<float> angular_velocity;
13 Msp::LinAl::Vector<float, 2> force;
17 class RigidBody: public Msp::Game::BufferedComponent<RigidBodyData>
20 using Setup = RigidBodySetup;
26 RigidBody(Msp::Game::Handle<Msp::Game::Entity>, const Setup &);
28 float get_mass() const { return setup.mass; }
29 float get_moment_of_inertia() const { return setup.moment_of_inertia; }
30 void set_velocity(const Msp::LinAl::Vector<float, 2> &);
31 void set_angular_velocity(Msp::Geometry::Angle<float>);
32 void add_force(const Msp::LinAl::Vector<float, 2> &);
33 void add_force(const Msp::LinAl::Vector<float, 2> &, const Msp::LinAl::Vector<float, 2> &);
34 void add_torque(float);
36 const Msp::LinAl::Vector<float, 2> &get_velocity() const { return read().velocity; }
37 Msp::Geometry::Angle<float> get_angular_velocity() const { return read().angular_velocity; }
38 const Msp::LinAl::Vector<float, 2> &get_force() const { return read().force; }
39 float get_torque() const { return read().torque; }