diff options
author | Stijn Buys <ingar@osirion.org> | 2008-05-25 16:44:37 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-05-25 16:44:37 +0000 |
commit | f7283b2b9a9bf305ac110ef00cd5c21d5304bfbb (patch) | |
tree | 8b595b0971a63678414daead588c6b27a209d819 /src/model | |
parent | 18180a06fa99bd97587b7c6e5bc60395b1d01262 (diff) |
target_flare
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/Makefile.am | 8 | ||||
-rw-r--r-- | src/model/flare.cc | 19 | ||||
-rw-r--r-- | src/model/flare.h | 27 | ||||
-rw-r--r-- | src/model/light.cc | 14 | ||||
-rw-r--r-- | src/model/map.cc | 46 | ||||
-rw-r--r-- | src/model/model.cc | 13 | ||||
-rw-r--r-- | src/model/model.h | 7 |
7 files changed, 115 insertions, 19 deletions
diff --git a/src/model/Makefile.am b/src/model/Makefile.am index 25985bb..ba8c38b 100644 --- a/src/model/Makefile.am +++ b/src/model/Makefile.am @@ -1,11 +1,11 @@ METASOURCES = AUTO -libmodel_la_SOURCES = engine.cc light.cc map.cc mapfile.cc model.cc plane.cc \ - tirangle.cc vertexarray.cc +libmodel_la_SOURCES = engine.cc flare.cc light.cc map.cc mapfile.cc model.cc \ + plane.cc tirangle.cc vertexarray.cc libmodel_la_LDFLAGS = -avoid-version -no-undefined -lm noinst_LTLIBRARIES = libmodel.la -noinst_HEADERS = engine.h light.h map.h mapfile.h model.h plane.h triangle.h \ - vertexarray.h +noinst_HEADERS = engine.h flare.h light.h map.h mapfile.h model.h plane.h \ + triangle.h vertexarray.h INCLUDES = -I$(top_srcdir)/src diff --git a/src/model/flare.cc b/src/model/flare.cc new file mode 100644 index 0000000..fcd36f1 --- /dev/null +++ b/src/model/flare.cc @@ -0,0 +1,19 @@ +/* + model/flare.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/flare.h" + +namespace model { + +Flare::Flare() : Light() { + flare_angle = 0; +} + +Flare::~Flare() +{ +} + +} diff --git a/src/model/flare.h b/src/model/flare.h new file mode 100644 index 0000000..3cd192c --- /dev/null +++ b/src/model/flare.h @@ -0,0 +1,27 @@ +/* + model/flare.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_FLARE_H__ +#define __INCLUDED_MODEL_FLARE_H__ + +#include "model/light.h" + +namespace model { + +/// a flare is a directional light +class Flare : public Light { +public: + Flare(); + ~Flare(); + + inline float angle() const { return flare_angle; } + + float flare_angle; +}; + +} + +#endif // __INCLUDED_MODEL_FLARE_H__ diff --git a/src/model/light.cc b/src/model/light.cc index f391a44..426e7fd 100644 --- a/src/model/light.cc +++ b/src/model/light.cc @@ -22,20 +22,6 @@ Light::Light() : render_texture = 0; } -/* -Light::Light(math::Vector3f const & location, math::Color const & color, bool strobe) : - light_location(location), - light_color(color) -{ - light_strobe = strobe; - light_radius = 1.0f; - light_frequency = 1.0f; - light_offset = 0.0f; - light_time = 0.5f; - light_flare = 0; - render_texture = 0; -} -*/ Light::~Light() {} diff --git a/src/model/map.cc b/src/model/map.cc index 4b78f762..6769ba8 100644 --- a/src/model/map.cc +++ b/src/model/map.cc @@ -30,6 +30,7 @@ Model * Map::load(std::string const &name) Model *model = new Model(name); Light *light = 0; + Flare *flare = 0; Engine *engine = 0; unsigned int u; @@ -73,7 +74,48 @@ Model * Map::load(std::string const &name) continue; } + + } else if (mapfile.got_classname("target_flare")) { + + // new flare + flare = new Flare(); + model->add_flare(flare); + + } else if (mapfile.classname().compare("target_flare") == 0 ) { + + // flare attributes + if (mapfile.got_key_vector3f("origin", flare->light_location)) { + flare->light_location *= SCALE; + continue; + + } else if (mapfile.got_key_color("_color", flare->light_color)) { + continue; + + } else if (mapfile.got_key_int("spawnflags", u)) { + flare->light_strobe = spawnflag_isset(u, 1); + flare->light_entity = spawnflag_isset(u, 2); + + } else if (mapfile.got_key_float("radius", flare->light_radius)) { + flare->light_radius /= 100.0f; + + } else if (mapfile.got_key_float("frequency", flare->light_frequency)) { + continue; + } else if (mapfile.got_key_float("offset", flare->light_offset)) { + continue; + + } else if (mapfile.got_key_float("time", flare->light_time)) { + continue; + + } 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_classname("target_engine")) { // new engine engine = new Engine(); @@ -195,6 +237,10 @@ Model * Map::load(std::string const &name) (*lit)->light_location -= center; } + for (std::list<Flare *>::iterator flit = model->model_flare.begin(); flit != model->model_flare.end(); flit++) { + (*flit)->light_location -= center; + } + } con_print << " maps/" << model->name() << ".map " << mapfile.brushes << " brushes " << model->tris() diff --git a/src/model/model.cc b/src/model/model.cc index cf03986..6508fdf 100644 --- a/src/model/model.cc +++ b/src/model/model.cc @@ -44,6 +44,12 @@ Model::~Model() delete (*lit); } model_light.clear(); + + // delete all flares + for (std::list<Flare *>::iterator flit = model_flare.begin(); flit != model_flare.end(); flit++) { + delete (*flit); + } + model_flare.clear(); } size_t Model::tris() const @@ -68,6 +74,10 @@ void Model::add_light(Light *light) model_light.push_back(light); } +void Model::add_flare(Flare *flare) +{ + model_flare.push_back(flare); +} Model *Model::find(std::string const & name) { @@ -110,7 +120,8 @@ void Model::list() << (*mit).second->tris() << " triangles (" << (*mit).second->details() << " detail) " << (*mit).second->model_engine.size() << " engines " - << (*mit).second->model_light.size() << " lights\n"; + << (*mit).second->model_light.size() << " lights " + << (*mit).second->model_flare.size() << " flares "; } con_print << registry.size() << " registered models" << std::endl; if (VertexArray::instance()) diff --git a/src/model/model.h b/src/model/model.h index ce288df..cb1352f 100644 --- a/src/model/model.h +++ b/src/model/model.h @@ -14,6 +14,7 @@ #include "math/mathlib.h" #include "model/engine.h" #include "model/light.h" +#include "model/flare.h" /// classes representing 3D geometry namespace model @@ -89,6 +90,12 @@ public: /// add a light to the model void add_light(Light *light); + + /// list of flares + std::list<Flare *> model_flare; + + /// add a flare to the model + void add_flare(Flare *flare); std::string model_name; float model_radius; |