diff options
author | Stijn Buys <ingar@osirion.org> | 2008-03-23 22:24:13 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-03-23 22:24:13 +0000 |
commit | 5a099735d5457298b87a33884356ff29417143e6 (patch) | |
tree | 05f6fa86051b0b7be450383d5cdea19340365cc6 /src | |
parent | 8529af97f7b9a5d69297726a62bdf3835f3c4d6d (diff) |
strobe lights
Diffstat (limited to 'src')
-rw-r--r-- | src/core/model.cc | 27 | ||||
-rw-r--r-- | src/core/model.h | 5 | ||||
-rw-r--r-- | src/render/draw.cc | 8 |
3 files changed, 33 insertions, 7 deletions
diff --git a/src/core/model.cc b/src/core/model.cc index 686cbfd..7c83edd 100644 --- a/src/core/model.cc +++ b/src/core/model.cc @@ -82,10 +82,12 @@ void VertexArray::add_evertex(math::Vector3f const &v, math::Vector3f const &n) /* ---------- core::Light ------------------------------------------ */ -Light::Light(math::Vector3f const & location, math::Color const & color) : +Light::Light(math::Vector3f const & location, math::Color const & color, bool strobe) : light_location(location), light_color(color) -{} +{ + light_strobe = strobe; +} Light::~Light() {} @@ -144,6 +146,7 @@ Model::Model(std::string const & name) : math::Vector3f class_origin; float class_angle; math::Color class_color; + unsigned int class_spawnflags; model_first_evertex = VertexArray::evertex_index/3; model_first_vertex = VertexArray::vertex_index/3; @@ -163,6 +166,7 @@ Model::Model(std::string const & name) : class_name.clear(); class_origin = math::Vector3f(0,0,0); class_color = math::Color(1, 1, 1); + class_spawnflags = 0; } level ++; //cout << " LEVEL +" << level << std::endl; @@ -188,13 +192,15 @@ Model::Model(std::string const & name) : //con_debug << " engine at " << class_origin << "\n"; add_engine(new Engine(class_origin * model_scale)); } else if ((level == 1) && (class_name == "light")) { - add_light(new Light(class_origin * model_scale, class_color)); + add_light(new Light(class_origin * model_scale, class_color, (class_spawnflags & 1) == 1)); } if (level == 1) { class_angle = 0; class_name.clear(); class_origin = Vector3f(0,0,0); + class_color = math::Color(1, 1, 1); + class_spawnflags = 0; } level--; @@ -246,6 +252,16 @@ Model::Model(std::string const & name) : is >> class_angle; //con_debug << " angle '" << class_angle << "'" << std::endl; + } else if (firstword == "\"spawnflags\"") { + std::string tmp; + char c; + while ((linestream.get(c)) && (c != '"')); + while ((linestream.get(c)) && (c != '"')) + tmp += c; + std::istringstream is(tmp); + is >> class_spawnflags; + //con_debug << " spawnflags '" << class_spawnflags << "'" << std::endl; + } else if (firstword == "(") { if ((level == 2) && (class_name == "worldspawn")) { //cout << " BRUSH PLANE" << std::endl; @@ -318,6 +334,11 @@ void Model::make_face(math::Plane3f *face, std::vector<math::Plane3f *> & planes return; } + // FIXME clip should be parsed as collision blocks + if (face->texture() == "common/clip") { + return; + } + // using suggestions from // http://www.flipcode.com/archives/Level_Editing.shtml diff --git a/src/core/model.h b/src/core/model.h index 5a3cd72..bdfeb86 100644 --- a/src/core/model.h +++ b/src/core/model.h @@ -71,16 +71,19 @@ private: class Light { public: - Light(math::Vector3f const & location, math::Color const & color); + Light(math::Vector3f const & location, math::Color const & color, bool strobe=false); ~Light(); inline math::Vector3f const & location() const { return light_location; } inline math::Color const & color() const { return light_color; }; + + inline bool strobe() const { return light_strobe; } private: math::Vector3f light_location; math::Color light_color; + bool light_strobe; }; diff --git a/src/render/draw.cc b/src/render/draw.cc index 8a03e40..e904888 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -171,9 +171,11 @@ void draw_model_lights(core::Entity *entity) gl::begin(gl::Points); for (std::list<core::Light *>::iterator lit = model->model_light.begin(); lit != model->model_light.end(); lit++) { - math::Vector3f location = (*lit)->location(); - gl::color((*lit)->color()); - gl::vertex(location); + if (!(*lit)->strobe() || (( core::application()->time() - floorf(core::application()->time()) ) < 0.5f)) { + math::Vector3f location = (*lit)->location(); + gl::color((*lit)->color()); + gl::vertex(location); + } } gl::end(); |