/* model/tags.h This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2 */ #ifndef __INCLUDED_MODEL_TAGS_H__ #define __INCLUDED_MODEL_TAGS_H__ #include "math/axis.h" #include "math/color.h" #include "math/vector3f.h" namespace model { /* ---- globals ---------------------------------------------------- */ // FIXME this should end up in material.h /** * @brief * culling parameter values * Culling is a paremeter used by flares and particles to indicate * with side of the polygons should be culled during rendering * */ enum Cull { CullNone = 0, CullBack = 1, CullFront = 2 }; /* ---- class Tag -------------------------------------------------- */ /** * @brief a location tag * A location tag provides an anchor point for model extenions * like lights, flares and sounds. * */ class Tag { public: /** * @brief default constructor * */ Tag(); /** * @brief copy constructor * */ Tag(const Tag& other); /** * @brief default destructor * */ ~Tag(); /* ---- inspectors ----------------------------------------- */ /** * @brief location of this part within the parent model * */ inline const math::Vector3f& location() const { return tag_location; } /** * @brief tag info text * */ inline const std::string & info() const { return tag_info; } /* ---- mutators ------------------------------------------- */ /** * @brief set the location within the parent model * */ inline void set_location(const math::Vector3f& location) { tag_location.assign(location); } /** * @brief set the location within the parent model * */ inline void set_location(const float x, const float y, const float z) { tag_location.assign(x, y, z); } /** * @brief set the info text * */ inline void set_info(const std::string &text) { tag_info.assign(text); } /* ---- actors --------------------------------------------- */ /** * @brief mutable reference to the location of this part within the parent model * */ inline math::Vector3f& get_location() { return tag_location; } private: math::Vector3f tag_location; std::string tag_info; }; /* ---- class Light ------------------------------------------------ */ /** * @brief an exterior light * a tag used to attach exterior lights */ class Light : public Tag { public: /** * @brief default constructor * */ Light(); /** * @brief copy constructor * */ Light(const Light& other); /** * @brief destructor * */ ~Light(); /* ---- inspectors ----------------------------------------- */ /** * @brief light color * */ inline const math::Color& color() const { return light_color; } /** * @brief true if the color was set * */ inline bool has_color() const { return light_has_color; } /** * @brief true if this is a strobe light * */ inline bool strobe() const { return light_strobe; } /** * @brief true if this light has entity primary color * */ inline bool entity() const { return light_entity; } /** * @brief true if this light has entity secondary color * */ inline bool entity_second() const { return light_entity_second; } /** * @brief true if this light has engine activation * The light's intensity will vary depedning on entity thrust, * */ inline bool engine() const { return light_engine; } /** * @brief size of the light, default is 1.0f * */ inline float radius() const { return light_radius; } /** * @brief strobe time offset, in seconds * */ inline float offset() const { return light_offset; } /** * @brief strobe frequency in strobes per second, default is 1.0f * */ inline float frequency() const { return light_frequency; } /** * @brief fraction a strobe light will be on, default is 0.5f * */ inline float time() const { return light_time; } /** * @brief flare texture number * */ inline unsigned int flare() const { return light_flare; } /** * @brief render texture id * */ inline size_t texture() const { return light_texture; } /* ---- mutators ------------------------------------------- */ /** * @brief set the light color * light color overrides engine color if the engine flag is set * @see engine() */ inline void set_color(const math::Color& color) { light_color.assign(color); light_has_color = true; } /** * @brief set strobe on or off */ inline void set_strobe(const bool strobe) { light_strobe = strobe; } /** * @brief set entity prinary color on or off * */ inline void set_entity(const bool entity) { light_entity = entity; } /** * @brief set entity secondary color on or off * */ inline void set_entity_second(const bool entity_second) { light_entity_second = entity_second; } /** * @brief set engine activation on or off * */ inline void set_engine(const bool engine) { light_engine = engine; } /** * @brief set the light radius * */ inline void set_radius(const float radius) { light_radius = radius; } /** * @brief set the light strobe frequency, in strobes per second * */ inline void set_frequency(const float frequency) { light_frequency = frequency; } /** * @brief set the light on time, from 0.0 (always off) to 1.0 (always on) * */ inline void set_time(const float time) { light_time = time; } /** * @brief set the light strobe time offset, in seconds * */ inline void set_offset(const float offset) { light_offset = offset; } /** * @brief set the flare texture number * */ inline void set_flare(unsigned int flare) { light_flare = flare; } /** * @brief set the render texture id * */ inline void set_texture(size_t texture) { light_texture = texture; } private: bool light_strobe; bool light_engine; bool light_entity; bool light_entity_second; unsigned int light_flare; float light_radius; float light_frequency; float light_offset; float light_time; math::Color light_color; bool light_has_color; size_t light_texture; }; /* ---- class Flare ------------------------------------------------ */ /** * @brief a directional light */ class Flare : public Light { public: Flare(); /** * @brief copy constructor */ Flare(const Flare& other); ~Flare(); /* ---- inspectors ----------------------------------------- */ inline const math::Axis &axis() const { return flare_axis; } inline Cull cull() const { return flare_cull; } /* ---- mutators ------------------------------------------- */ inline void set_cull(const Cull cull) { flare_cull = cull; } inline void set_axis(const math::Axis& axis) { flare_axis.assign(axis); } /* ---- actors --------------------------------------------- */ /** * @brief mutable reference to the axis * */ inline math::Axis& get_axis() { return flare_axis; } private: Cull flare_cull; math::Axis flare_axis; }; /* ---- class Particles -------------------------------------------- */ /** * @brief a particle system * */ class Particles : public Tag { public: /** * @brief default constructor * */ Particles(); /** * @brief copy constructor * */ Particles(const Particles & other); /** * @brief destructor * */ ~Particles(); /* ---- inspectors ----------------------------------------- */ inline const math::Axis &axis() const { return particles_axis; } /** * @brief name of the script to load * */ inline const std::string& script() const { return particles_script; } /** * @brief if true, the particle system has entity primary color * */ inline bool entity() const { return particles_entity; } /** * @brief if true, the particle system has entity secondary color * */ inline bool entity_second() const { return particles_entity_second; } inline bool engine() const { return particles_engine; } inline const math::Color & color() const { return particles_color; } /** * @brief true if the color was set * */ inline bool has_color() const { return particles_has_color; } inline float scale() const { return particles_scale; } inline Cull cull() const { return particles_cull; } /* ---- mutators ------------------------------------------- */ /** * @brief set entity primary color on or off */ inline void set_entity(const bool entity) { particles_entity = entity; } /** * @brief set entity secondary color on or off */ inline void set_entity_second(const bool entity_second) { particles_entity_second = entity_second; } /** * @brief set engine activation on or off */ inline void set_engine(const bool engine) { particles_engine = engine; } inline void set_cull(const Cull cull) { particles_cull = cull; } inline void set_script(const std::string& script) { particles_script.assign(script); } inline void set_scale(const float scale) { particles_scale = scale; } inline void set_color(const math::Color &color) { particles_color.assign(color); particles_has_color = true; } inline void set_axis(const math::Axis& axis) { particles_axis.assign(axis); } /* ---- actors --------------------------------------------- */ /** * @brief mutable reference to the axis */ inline math::Axis& get_axis() { return particles_axis; } private: bool particles_entity; bool particles_entity_second; bool particles_engine; bool particles_has_color; Cull particles_cull; float particles_scale; math::Color particles_color; math::Axis particles_axis; std::string particles_script; }; /* ---- class Sound ------------------------------------------------ */ /** * @brief a sound location tag */ class Sound : public Tag { public: Sound(); Sound(const Sound& other); ~Sound(); /* ---- inspectors ----------------------------------------- */ /** * @brief name of the sound sample * */ inline const std::string& name() const { return sound_name; } /* ---- mutators ------------------------------------------- */ /** * @brief set the name name of the sound sample * */ inline void set_name(const std::string& name) { sound_name.assign(name); } private: std::string sound_name; }; /* ---- class SubModel --------------------------------------------- */ /** * @brief a submodel tag */ class SubModel : public Tag { public: SubModel(); SubModel(const SubModel& other); ~SubModel(); /* ---- inspectors ----------------------------------------- */ inline const std::string& name() const { return submodel_name; } inline const math::Axis& axis() const { return submodel_axis; } inline float scale() const { return submodel_scale; } /* ---- mutators ------------------------------------------- */ inline void set_scale(const float scale) { submodel_scale = scale; } inline void set_name(const std::string& name) { submodel_name.assign(name); } inline void set_axis(const math::Axis& axis) { submodel_axis.assign(axis); } /* ---- actors --------------------------------------------- */ /** * @brief mutable reference to the axis */ inline math::Axis& get_axis() { return submodel_axis; } private: float submodel_scale; std::string submodel_name; math::Axis submodel_axis; }; /* ---- class Slot ------------------------------------------------- */ /** * @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 Slot : public Tag { public: enum Type {None = 0, Cannon = 1, Turret = 2, Dock = 3}; /** * @brief default constructor * */ Slot(const Type type = None); /** * @brief copy constructor * */ Slot(const Slot& other); /** * @brief destructor * */ ~Slot(); /* ---- inspectors ----------------------------------------- */ /** * @brief slot type * */ inline const Type type() const { return slot_type; } /** * @brief slot orientation within the parent model * */ inline const math::Axis &axis() const { return slot_axis; } /** * @brief slot radius, used by Dock slots * */ inline float radius() const { 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 slot type * */ void set_type(const Type type); /** * @brief set slot axis * */ inline void set_axis(const math::Axis& axis) { slot_axis.assign(axis); } /** * @brief set slot radius * */ 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 slot_axis; } private: Type slot_type; math::Axis slot_axis; float slot_radius; float slot_cone; }; } #endif // __INCLUDED_MODEL_TAGS_H__