X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=examples%2Fbassteroids%2Fsource%2Frigidbody.h;h=cd5063d953c8422481965b2c7ea354c09296400e;hb=239cd38de0ddbb5931151523530a5e7272e16f7f;hp=6225500237c79f69eb0367994ca4f363cd585c48;hpb=1819b186d60376a546722d99edd686e876b81d9f;p=libs%2Fgame.git diff --git a/examples/bassteroids/source/rigidbody.h b/examples/bassteroids/source/rigidbody.h index 6225500..cd5063d 100644 --- a/examples/bassteroids/source/rigidbody.h +++ b/examples/bassteroids/source/rigidbody.h @@ -4,22 +4,23 @@ #include #include #include +#include "setups.h" -struct RigidBodySetup +struct RigidBodyData { - float mass = 1.0f; - float moment_of_inertia = 0.5f; + Msp::LinAl::Vector velocity; + Msp::Geometry::Angle angular_velocity; + Msp::LinAl::Vector force; + float torque = 0.0f; }; -class RigidBody: public Msp::Game::Component +class RigidBody: public Msp::Game::BufferedComponent { public: using Setup = RigidBodySetup; private: const Setup &setup; - Msp::LinAl::Vector velocity; - Msp::Geometry::Angle angular_velocity; public: RigidBody(Msp::Game::Handle, const Setup &); @@ -28,8 +29,14 @@ public: float get_moment_of_inertia() const { return setup.moment_of_inertia; } void set_velocity(const Msp::LinAl::Vector &); void set_angular_velocity(Msp::Geometry::Angle); - const Msp::LinAl::Vector &get_velocity() const { return velocity; } - Msp::Geometry::Angle get_angular_velocity() const { return angular_velocity; } + void add_force(const Msp::LinAl::Vector &); + void add_force(const Msp::LinAl::Vector &, const Msp::LinAl::Vector &); + void add_torque(float); + void clear_forces(); + const Msp::LinAl::Vector &get_velocity() const { return read().velocity; } + Msp::Geometry::Angle get_angular_velocity() const { return read().angular_velocity; } + const Msp::LinAl::Vector &get_force() const { return read().force; } + float get_torque() const { return read().torque; } }; #endif