From 2c98d3eef488233b99a76ca44d69c1c9d53404af Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 7 Dec 2014 16:12:49 +0000 Subject: Cleanup of the slots code, unified model weapon and dock tags into a single slots list, load dock tags into entity slots, represent entity slot locations in entity coordinate space, have r_slots render fixed-size slot indicators regardless of model scale. --- src/model/tags.h | 148 +++++++++++++++++++------------------------------------ 1 file changed, 51 insertions(+), 97 deletions(-) (limited to 'src/model/tags.h') diff --git a/src/model/tags.h b/src/model/tags.h index 5be7576..775dc73 100644 --- a/src/model/tags.h +++ b/src/model/tags.h @@ -546,74 +546,6 @@ private: std::string particles_script; }; -/* ---- class Dock ------------------------------------------------- */ - -/// a docking location tag -class Dock : public Tag -{ -public: - /** - * @brief default constructor - * */ - Dock(); - - /** - * @brief copy constructor - * */ - Dock(const Dock& other); - - /** - * @brief destructor - * */ - ~Dock(); - - /* ---- inspectors ----------------------------------------- */ - - /** - * @brief dock radius, default is 0.01f - * */ - inline float radius() const - { - return dock_radius; - } - - inline const math::Axis &axis() const - { - return dock_axis; - } - - /* ---- mutators ------------------------------------------- */ - - /** - * @brief set dock radius - * */ - inline void set_radius(const float radius) - { - dock_radius = radius; - } - - /** - * @brief set dock axis - * */ - inline void set_axis(const math::Axis& axis) - { - dock_axis.assign(axis); - } - - /* ---- actors --------------------------------------------- */ - - /** - * @brief mutable reference to the axis - * */ - inline math::Axis& get_axis() { - return dock_axis; - } - -private: - float dock_radius; - math::Axis dock_axis; -}; - /* ---- class Sound ------------------------------------------------ */ /** @@ -711,89 +643,111 @@ private: math::Axis submodel_axis; }; -/* ---- class Weapon ----------------------------------------------- */ +/* ---- class Slot ------------------------------------------------- */ /** - * @brief a weapon slot tag + * @brief a slot tag + * A slot tag can be a cannon, turret or a dock. + * Unlike visual effects like lights and flares. slots get copied into entity space. * */ -class Weapon : public Tag +class Slot : public Tag { public: - enum Type {Unmountable = 0, Cannon = 1, Turret = 2 }; + enum Type {None = 0, Cannon = 1, Turret = 2, Dock = 3}; /** * @brief default constructor * */ - Weapon(const Type type = Cannon); + Slot(const Type type = None); /** * @brief copy constructor * */ - Weapon(const Weapon& other); + Slot(const Slot& other); /** * @brief destructor * */ - ~Weapon(); + ~Slot(); /* ---- inspectors ----------------------------------------- */ - inline const math::Axis &axis() const { - return weapon_axis; + /** + * @brief slot type + * */ + inline const Type type() const + { + return slot_type; } /** - * @brief weapon fire cone, in degrees + * @brief slot orientation within the parent model * */ - inline float cone() const - { - return weapon_cone; + inline const math::Axis &axis() const { + return slot_axis; } /** - * @brief weapon slot type + * @brief slot radius, used by Dock slots * */ - inline const Type type() const + inline float radius() const { - return weapon_type; + return slot_radius; } + /** + * @brief slot fire cone, in degrees, used by Turret and Cannon slots. + * */ + inline float cone() const + { + return slot_cone; + } + /* ---- mutators ------------------------------------------- */ /** - * @brief set weapon fire cone, in degrees + * @brief set slot type * */ - inline void set_cone(const float cone) - { - weapon_cone = cone; - } + void set_type(const Type type); /** - * @brief set weapon slot axis + * @brief set slot axis * */ inline void set_axis(const math::Axis& axis) { - weapon_axis.assign(axis); + slot_axis.assign(axis); } /** - * @brief set weapon slot type + * @brief set slot radius * */ -; void set_type(const Type type); + inline void set_radius(const float radius) + { + slot_radius = radius; + } + /** + * @brief set slot fire cone, in degrees + * */ + inline void set_cone(const float cone) + { + slot_cone = cone; + } + /* ---- actors --------------------------------------------- */ /** * @brief mutable reference to the axis * */ inline math::Axis& get_axis() { - return weapon_axis; + return slot_axis; } private: - Type weapon_type; - math::Axis weapon_axis; - float weapon_cone; + Type slot_type; + math::Axis slot_axis; + float slot_radius; + float slot_cone; }; -- cgit v1.2.3