From 83757353860fa447c36d4078602efea36d7da94e Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 23 Feb 2010 20:30:57 +0000 Subject: renamed model::Parts to model::Tags --- src/model/Makefile.am | 8 +- src/model/model.h | 3 +- src/model/parts.cc | 119 ------------ src/model/parts.h | 468 ---------------------------------------------- src/model/tags.cc | 134 ++++++++++++++ src/model/tags.h | 503 ++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 643 insertions(+), 592 deletions(-) delete mode 100644 src/model/parts.cc delete mode 100644 src/model/parts.h create mode 100644 src/model/tags.cc create mode 100644 src/model/tags.h (limited to 'src/model') diff --git a/src/model/Makefile.am b/src/model/Makefile.am index fe398a2..6a44471 100644 --- a/src/model/Makefile.am +++ b/src/model/Makefile.am @@ -1,12 +1,12 @@ METASOURCES = AUTO -libmodel_la_SOURCES = asefile.cc parts.cc fragment.cc mapfile.cc material.cc \ - model.cc face.cc primitives.cc quad.cc triangle.cc vertexarray.cc +libmodel_la_SOURCES = asefile.cc fragment.cc mapfile.cc material.cc \ + model.cc face.cc primitives.cc quad.cc tags.cc triangle.cc vertexarray.cc libmodel_la_LDFLAGS = -avoid-version -no-undefined -lm noinst_LTLIBRARIES = libmodel.la -noinst_HEADERS = asefile.h parts.h fragment.h mapfile.h material.h model.h face.h \ - primitives.h quad.h triangle.h vertexarray.h +noinst_HEADERS = asefile.h fragment.h mapfile.h material.h model.h face.h \ + primitives.h quad.h tags.h triangle.h vertexarray.h INCLUDES = -I$(top_srcdir)/src diff --git a/src/model/model.h b/src/model/model.h index 30714d4..c8f60f1 100644 --- a/src/model/model.h +++ b/src/model/model.h @@ -12,7 +12,8 @@ #include #include "math/mathlib.h" -#include "model/parts.h" + +#include "model/tags.h" #include "model/fragment.h" /// classes representing 3D geometry diff --git a/src/model/parts.cc b/src/model/parts.cc deleted file mode 100644 index e71ad16..0000000 --- a/src/model/parts.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* - model/classes.cc - This file is part of the Osirion project and is distributed under - the terms of the GNU General Public License version 2 -*/ - -#include "model/parts.h" - -namespace model -{ - -/* ---- class Light ------------------------------------------------ */ - -Light::Light() : - Part(), - light_color(1.0f, 1.0f, 1.0f) -{ - light_entity = false; - light_engine = false; - light_strobe = false; - - light_radius = 1.0f; - light_frequency = 1.0f; - light_offset = 0.0f; - light_time = 0.5f; - - light_flare = 0; - - light_texture = 0; -} - -Light::Light(const Light& other) : Part(other), - light_color(other.color()) -{ - light_entity = other.entity(); - light_engine = other.engine(); - light_strobe = other.strobe(); - - light_radius = other.radius(); - light_frequency = other.frequency(); - light_offset = other.offset(); - light_time = other.time(); - - light_flare = other.flare(); - - light_texture = other.texture(); -} -Light::~Light() -{} - -/* ---- class Flare ------------------------------------------------ */ - -Flare::Flare() : Light() -{ - flare_cull = CullBack; -} - -Flare::Flare(const Flare& other) : Light(other) -{ - flare_cull = other.cull(); -} - -Flare::~Flare() -{} - -/* ---- class Particles -------------------------------------------- */ - -Particles::Particles() : Part() -{ - particles_entity = false; - particles_engine = false; - particles_radius = 0.0f; - particles_cull = CullNone; -} - -Particles::Particles(const math::Vector3f& location) : - Part(location) -{ -} - -Particles::~Particles() -{ -} - -/* ---- class Dock ------------------------------------------------- */ - -Dock::Dock() : Part() -{ - dock_radius = 0.01f; -} - -Dock::Dock(const Dock& other) : Part(other) -{ - dock_radius = other.radius(); -} - -Dock::~Dock() -{ -} - -/* ---- class SubModel---------------------------------------------- */ - -SubModel::SubModel() : Part() -{ - submodel_scale = 1.0f; -} - -SubModel::SubModel(const SubModel& other) : Part(other), - submodel_name(other.name()), - submodel_axis(other.axis()) -{ - submodel_scale = other.scale(); -} - -SubModel::~SubModel() -{ -} - -} diff --git a/src/model/parts.h b/src/model/parts.h deleted file mode 100644 index 4df4672..0000000 --- a/src/model/parts.h +++ /dev/null @@ -1,468 +0,0 @@ -/* - model/classes.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_PARTS_H__ -#define __INCLUDED_MODEL_PARTS_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 Part ------------------------------------------------- */ - -/** - * @brief a special part of a model - */ -class Part -{ -public: - /** - * @brief default constructor - */ - inline Part() : part_location() { - } - - /** - * @brief copy constructor - */ - inline Part(const Part& other) : part_location(other.location()) { - } - - /** - * @brief constructor with location - * @param location location of this part within the parent model - */ - inline Part(const math::Vector3f& location) : part_location(location) { - } - - /* ---- inspectors ----------------------------------------- */ - - /** - * @brief location of this part within the parent model - */ - inline const math::Vector3f& location() const { - return part_location; - } - - /* ---- mutators ------------------------------------------- */ - /** - * @brief set the location within the parent model - */ - inline void set_location(const math::Vector3f& location) { - part_location.assign(location); - } - - /** - * @brief set the location within the parent model - */ - inline void set_location(const float x, const float y, const float z) { - part_location.assign(x, y, z); - } - - /* ---- actors --------------------------------------------- */ - - /** - * @brief mutable reference to the location of this part within the parent model - */ - inline math::Vector3f& get_location() { - return part_location; - } - -private: - math::Vector3f part_location; -}; - -/* ---- class Light ------------------------------------------------ */ - -/// an exterior light -class Light : public Part -{ -public: - /** - * @brief default constructor - */ - Light(); - - /** - * @brief copy constructor - */ - Light(const Light& other); - - /** - * @brief destructor - */ - ~Light(); - - /* ---- inspectors ----------------------------------------- */ - - /// light color - inline const math::Color& color() const { - return light_color; - }; - - /// true if this is a strobe light - inline bool strobe() const { - return light_strobe; - } - - /// true if this light has entity color - inline bool entity() const { - return light_entity; - } - - /// true if this light has engine activation - inline bool engine() const { - return light_engine; - } - - /// size of the light, default is 1.0f - inline float radius() const { - return light_radius; - } - - /// strobe time offset, in seconds - inline float offset() const { - return light_offset; - } - - /// strobe frequency in strobes per second, default is 1.0f - inline float frequency() const { - return light_frequency; - } - - /// fraction a strobe light will be on, default is 0.5f - inline float time() const { - return light_time; - } - - /// flare texture number - inline unsigned int flare() const { - return light_flare; - } - - /// render texture id - inline size_t texture() const { - return light_texture; - } - /* ---- mutators ------------------------------------------- */ - - /** - * @brief set strobe color on or off - */ - inline void set_strobe(const bool strobe) { - light_strobe = strobe; - } - - /** - * @brief set entity color on or off - */ - inline void set_entity(const bool entity) { - light_entity = entity; - } - - /** - * @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_radius = 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; - } - - /** - * @brief mutable reference to the color - */ - inline math::Color& get_color() { - return light_color; - } - -private: - bool light_strobe; - bool light_engine; - bool light_entity; - - unsigned int light_flare; - - float light_radius; - float light_frequency; - float light_offset; - float light_time; - - math::Color light_color; - - size_t light_texture; -}; - -/* ---- class Flare ------------------------------------------------ */ - -/// a flare is 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; - } - - /* ---- 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 -------------------------------------------- */ - -/// a particle system -class Particles : public Part -{ -public: - Particles(); - - Particles(const math::Vector3f & location); - - ~Particles(); - - inline const math::Axis &axis() const { - return particles_axis; - } - - inline const std::string& script() const { - return particles_script; - } - - inline bool entity() const { - return particles_entity; - } - - inline bool engine() const { - return particles_engine; - } - - inline float radius() const { - return particles_radius; - } - - inline Cull cull() const { - return particles_cull; - } - - /* ---- mutators ------------------------------------------- */ - - /** - * @brief set entity color on or off - */ - inline void set_entity(const bool entity) { - particles_entity = entity; - } - - /** - * @brief set engine activation on or off - */ - inline void set_engine(const bool engine) { - particles_engine = engine; - } - - inline void set_radius(const float radius) { - particles_radius = radius; - } - - inline void set_cull(const Cull cull) { - particles_cull = cull; - } - - inline void set_script(const std::string& script) { - particles_script.assign(script); - } - - /* ---- actors --------------------------------------------- */ - - /** - * @brief mutable reference to the axis - */ - inline math::Axis& get_axis() { - return particles_axis; - } - -private: - bool particles_entity; - bool particles_engine; - - Cull particles_cull; - - float particles_radius; - - math::Axis particles_axis; - std::string particles_script; -}; - -/* ---- class Dock ------------------------------------------------- */ - -/// a docking location -class Dock : public Part -{ -public: - Dock(); - - /** - * @brief copy constructor - */ - Dock(const Dock& other); - - ~Dock(); - - /// dock radius, default is 0.01f - inline float radius() const { - return dock_radius; - } - - /// set dock radius - inline void set_radius(const float radius) { - dock_radius = radius; - } - -private: - float dock_radius; -}; - -/* ---- class SubModel --------------------------------------------- */ - -/// a submodel -class SubModel : public Part -{ -public: - SubModel(); - - SubModel(const SubModel& other); - - ~SubModel(); - - 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; - } - - - 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; -}; - -} - -#endif // __INCLUDED_MODEL_PARTS_H__ - diff --git a/src/model/tags.cc b/src/model/tags.cc new file mode 100644 index 0000000..baf70a4 --- /dev/null +++ b/src/model/tags.cc @@ -0,0 +1,134 @@ +/* + model/tags.cc + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#include "model/tags.h" + +namespace model +{ + +/* ---- class Light ------------------------------------------------ */ + +Light::Light() : + Tag(), + light_color(1.0f, 1.0f, 1.0f) +{ + light_entity = false; + light_engine = false; + light_strobe = false; + + light_radius = 1.0f; + light_frequency = 1.0f; + light_offset = 0.0f; + light_time = 0.5f; + + light_flare = 0; + + light_texture = 0; +} + +Light::Light(const Light& other) : Tag(other), + light_color(other.color()) +{ + light_entity = other.entity(); + light_engine = other.engine(); + light_strobe = other.strobe(); + + light_radius = other.radius(); + light_frequency = other.frequency(); + light_offset = other.offset(); + light_time = other.time(); + + light_flare = other.flare(); + + light_texture = other.texture(); +} +Light::~Light() +{} + +/* ---- class Flare ------------------------------------------------ */ + +Flare::Flare() : Light() +{ + flare_cull = CullBack; +} + +Flare::Flare(const Flare& other) : Light(other) +{ + flare_cull = other.cull(); +} + +Flare::~Flare() +{} + +/* ---- class Particles -------------------------------------------- */ + +Particles::Particles() : Tag() +{ + particles_entity = false; + particles_engine = false; + particles_radius = 0.0f; + particles_cull = CullNone; +} + +Particles::Particles(const math::Vector3f& location) : + Tag(location) +{ +} + +Particles::~Particles() +{ +} + +/* ---- class Dock ------------------------------------------------- */ + +Dock::Dock() : Tag() +{ + dock_radius = 0.01f; +} + +Dock::Dock(const Dock& other) : Tag(other) +{ + dock_radius = other.radius(); +} + +Dock::~Dock() +{ +} + +/* ---- class Sound ------------------------------------------------- */ + +Sound::Sound() : Tag() +{ +} + +Sound::Sound(const Sound& other) : Tag(other), + sound_name(other.name()) +{ +} + +Sound::~Sound() +{ +} + +/* ---- class SubModel---------------------------------------------- */ + +SubModel::SubModel() : Tag() +{ + submodel_scale = 1.0f; +} + +SubModel::SubModel(const SubModel& other) : Tag(other), + submodel_name(other.name()), + submodel_axis(other.axis()) +{ + submodel_scale = other.scale(); +} + +SubModel::~SubModel() +{ +} + +} diff --git a/src/model/tags.h b/src/model/tags.h new file mode 100644 index 0000000..0c97910 --- /dev/null +++ b/src/model/tags.h @@ -0,0 +1,503 @@ +/* + model/classes.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 + */ + inline Tag() : tag_location() { + } + + /** + * @brief copy constructor + */ + inline Tag(const Tag& other) : tag_location(other.location()) { + } + + /** + * @brief constructor with location + * @param location location of this part within the parent model + */ + inline Tag(const math::Vector3f& location) : tag_location(location) { + } + + /* ---- inspectors ----------------------------------------- */ + + /** + * @brief location of this part within the parent model + */ + inline const math::Vector3f& location() const { + return tag_location; + } + + /* ---- 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); + } + + /* ---- 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; +}; + +/* ---- 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 ----------------------------------------- */ + + /// light color + inline const math::Color& color() const { + return light_color; + }; + + /// true if this is a strobe light + inline bool strobe() const { + return light_strobe; + } + + /// true if this light has entity color + inline bool entity() const { + return light_entity; + } + + /// true if this light has engine activation + inline bool engine() const { + return light_engine; + } + + /// size of the light, default is 1.0f + inline float radius() const { + return light_radius; + } + + /// strobe time offset, in seconds + inline float offset() const { + return light_offset; + } + + /// strobe frequency in strobes per second, default is 1.0f + inline float frequency() const { + return light_frequency; + } + + /// fraction a strobe light will be on, default is 0.5f + inline float time() const { + return light_time; + } + + /// flare texture number + inline unsigned int flare() const { + return light_flare; + } + + /// render texture id + inline size_t texture() const { + return light_texture; + } + /* ---- mutators ------------------------------------------- */ + + /** + * @brief set strobe color on or off + */ + inline void set_strobe(const bool strobe) { + light_strobe = strobe; + } + + /** + * @brief set entity color on or off + */ + inline void set_entity(const bool entity) { + light_entity = entity; + } + + /** + * @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_radius = 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; + } + + /** + * @brief mutable reference to the color + */ + inline math::Color& get_color() { + return light_color; + } + +private: + bool light_strobe; + bool light_engine; + bool light_entity; + + unsigned int light_flare; + + float light_radius; + float light_frequency; + float light_offset; + float light_time; + + math::Color light_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; + } + + /* ---- 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 -------------------------------------------- */ + +/// a particle system +class Particles : public Tag +{ +public: + Particles(); + + Particles(const math::Vector3f & location); + + ~Particles(); + + inline const math::Axis &axis() const { + return particles_axis; + } + + inline const std::string& script() const { + return particles_script; + } + + inline bool entity() const { + return particles_entity; + } + + inline bool engine() const { + return particles_engine; + } + + inline float radius() const { + return particles_radius; + } + + inline Cull cull() const { + return particles_cull; + } + + /* ---- mutators ------------------------------------------- */ + + /** + * @brief set entity color on or off + */ + inline void set_entity(const bool entity) { + particles_entity = entity; + } + + /** + * @brief set engine activation on or off + */ + inline void set_engine(const bool engine) { + particles_engine = engine; + } + + inline void set_radius(const float radius) { + particles_radius = radius; + } + + inline void set_cull(const Cull cull) { + particles_cull = cull; + } + + inline void set_script(const std::string& script) { + particles_script.assign(script); + } + + /* ---- actors --------------------------------------------- */ + + /** + * @brief mutable reference to the axis + */ + inline math::Axis& get_axis() { + return particles_axis; + } + +private: + bool particles_entity; + bool particles_engine; + + Cull particles_cull; + + float particles_radius; + + math::Axis particles_axis; + std::string particles_script; +}; + +/* ---- class Dock ------------------------------------------------- */ + +/// a docking location tag +class Dock : public Tag +{ +public: + Dock(); + + /** + * @brief copy constructor + */ + Dock(const Dock& other); + + ~Dock(); + + /// dock radius, default is 0.01f + inline float radius() const { + return dock_radius; + } + + /// set dock radius + inline void set_radius(const float radius) { + dock_radius = radius; + } + +private: + float dock_radius; +}; + +/* ---- class Sound ------------------------------------------------ */ + +/** + * @brief a sound location tag + */ +class Sound : public Tag +{ +public: + Sound(); + + Sound(const Sound& other); + + ~Sound(); + + /// name of the sound sample + inline const std::string& name() const { + return sound_name; + } + + 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(); + + 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; + } + + + 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; +}; + +} + +#endif // __INCLUDED_MODEL_PARTS_H__ + -- cgit v1.2.3