diff options
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/classes.cc | 11 | ||||
-rw-r--r-- | src/model/classes.h | 28 | ||||
-rw-r--r-- | src/model/fragment.h | 32 | ||||
-rw-r--r-- | src/model/map.cc | 50 | ||||
-rw-r--r-- | src/model/map.h | 2 |
5 files changed, 94 insertions, 29 deletions
diff --git a/src/model/classes.cc b/src/model/classes.cc index 06ebda3..b601a42 100644 --- a/src/model/classes.cc +++ b/src/model/classes.cc @@ -8,6 +8,16 @@ namespace model { +/* ---- class MapClass --------------------------------------------- */ + +MapClass::MapClass() +{ +} + +MapClass::~MapClass() +{ +} + /* ---- class Light ------------------------------------------------ */ Light::Light() : @@ -31,7 +41,6 @@ Light::~Light() Flare::Flare() : Light() { - flare_angle = 0; flare_engine = false; } diff --git a/src/model/classes.h b/src/model/classes.h index a0e9d1f..f853da8 100644 --- a/src/model/classes.h +++ b/src/model/classes.h @@ -14,6 +14,28 @@ namespace model { +/* ---- class MapClass --------------------------------------------- */ + +class MapClass +{ +public: + MapClass(); + ~MapClass(); + + inline const math::Vector3f &location() const { return mapclass_location; } + + inline const math::Axis &axis() const { return mapclass_axis; } + + + inline void set_location(const math::Vector3f location) { mapclass_location.assign(location); } + + inline void set_axis(const math::Axis axis) { mapclass_axis.assign(axis); } + +private: + math::Vector3f mapclass_location; + math::Axis mapclass_axis; +}; + /* ---- class Light ------------------------------------------------ */ /// an exterior light @@ -107,9 +129,9 @@ public: Flare(); ~Flare(); - inline float angle() const + inline const math::Axis axis() const { - return flare_angle; + return flare_axis; } inline bool engine() const @@ -117,7 +139,7 @@ public: return flare_engine; } - float flare_angle; + math::Axis flare_axis; bool flare_engine; }; diff --git a/src/model/fragment.h b/src/model/fragment.h index 204a3c9..1978baa 100644 --- a/src/model/fragment.h +++ b/src/model/fragment.h @@ -9,8 +9,9 @@ #include <list> -#include "math/vector3f.h" +#include "math/axis.h" #include "math/color.h" +#include "math/vector3f.h" namespace model { @@ -82,31 +83,32 @@ public: ~FragmentGroup(); - inline const math::Vector3f &location() const { return group_location; } - inline const Type type() const { return group_type; } - inline const size_t size() const { return group_fragments.size(); } + inline const math::Vector3f &location() const { return group_location; } - inline const float angle() const { return group_angle; } + inline const math::Axis & axis() const { return group_axis; } inline const float speed() const { return group_speed; } - inline iterator begin() { return group_fragments.begin(); } - - inline iterator end() { return group_fragments.end(); } - - - inline void push_back(Fragment *fragment) { group_fragments.push_back(fragment); } + + inline void set_type(const Type type) { group_type = type; } inline void set_location(const math::Vector3f &location) { group_location.assign(location); } - inline void set_type(const Type type) { group_type = type; } - - inline void set_angle(const float angle) { group_angle = angle; } + inline void set_axis(const math::Axis &axis) { group_axis.assign(axis); } inline void set_speed(const float speed) { group_speed = speed; } + + inline iterator begin() { return group_fragments.begin(); } + + inline iterator end() { return group_fragments.end(); } + + inline const size_t size() const { return group_fragments.size(); } + + inline void push_back(Fragment *fragment) { group_fragments.push_back(fragment); } + void clear(); private: @@ -116,9 +118,9 @@ private: Fragments group_fragments; math::Vector3f group_location; math::Vector3f group_forward; + math::Axis group_axis; Type group_type; - float group_angle; float group_speed; }; diff --git a/src/model/map.cc b/src/model/map.cc index c073a4d..8139dd0 100644 --- a/src/model/map.cc +++ b/src/model/map.cc @@ -677,7 +677,7 @@ void Map::clear_bbox() class_maxbbox[i] = -MAX_BOUNDS; } - class_angle = 0; + class_axis.clear(); class_speed = 0; } @@ -715,7 +715,7 @@ void Map::load_fragmentgroup(Model *model, const FragmentGroup::Type class_type) FragmentGroup *group = new FragmentGroup(); group->set_type(class_type); group->set_location((class_minbbox + class_maxbbox) / 2.0f - map_center); - group->set_angle(class_angle); + group->set_axis(class_axis); group->set_speed(class_speed); for (Materials::iterator mit = map_materials.begin(); mit != map_materials.end(); mit++) { @@ -875,8 +875,22 @@ Model * Map::load(std::string const &name) } else if (mapfile.in_class("func_rotate")) { - if (mapfile.got_key_float("angle", mapfile.class_angle)) { - continue; + if (mapfile.got_key_float("angle", angle)) { + if (angle == ANGLEUP) { + mapfile.class_axis.change_pitch(90.0f); + } else if (angle == ANGLEDOWN) { + mapfile.class_axis.change_pitch(-90.0f); + } else { + mapfile.class_axis.change_direction(angle); + } + } else if (mapfile.got_key_float("direction", angle)) { + mapfile.class_axis.change_direction(angle); + + } else if (mapfile.got_key_float("pitch", angle)) { + mapfile.class_axis.change_pitch(angle); + + } else if (mapfile.got_key_float("roll", angle)) { + mapfile.class_axis.change_roll(angle); } else if (mapfile.got_key_float("speed", mapfile.class_speed)) { continue; @@ -1007,9 +1021,22 @@ Model * Map::load(std::string const &name) } else if (mapfile.got_key_int("flare", flare->light_flare)) { continue; - } else if (mapfile.got_key_float("angle", flare->flare_angle)) { - flare->flare_angle = math::degrees360f(flare->flare_angle); - continue; + } else if (mapfile.got_key_float("angle", angle)) { + if (angle == ANGLEUP) { + flare->flare_axis.change_pitch(90.0f); + } else if (angle == ANGLEDOWN) { + flare->flare_axis.change_pitch(-90.0f); + } else { + flare->flare_axis.change_direction(angle); + } + } else if (mapfile.got_key_float("direction", angle)) { + flare->flare_axis.change_direction(angle); + + } else if (mapfile.got_key_float("pitch", angle)) { + flare->flare_axis.change_pitch(angle); + + } else if (mapfile.got_key_float("roll", angle)) { + flare->flare_axis.change_roll(angle); } else if (mapfile.got_key()) { con_warn "Unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl; @@ -1030,8 +1057,13 @@ Model * Map::load(std::string const &name) } else if (mapfile.got_key_string("script", particles->particles_script)) { continue; } else if (mapfile.got_key_float("angle", angle)) { - particles->particles_axis.change_direction(angle); - + if (angle == ANGLEUP) { + particles->particles_axis.change_pitch(90.0f); + } else if (angle == ANGLEDOWN) { + particles->particles_axis.change_pitch(-90.0f); + } else { + particles->particles_axis.change_direction(angle); + } } else if (mapfile.got_key_float("direction", angle)) { particles->particles_axis.change_direction(angle); diff --git a/src/model/map.h b/src/model/map.h index f9b036f..86bada6 100644 --- a/src/model/map.h +++ b/src/model/map.h @@ -165,7 +165,7 @@ private: math::Vector3f class_maxbbox; math::Vector3f class_minbbox; - float class_angle; + math::Axis class_axis; float class_speed; math::Vector3f map_center; |