diff options
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/Makefile.am | 4 | ||||
-rw-r--r-- | src/model/engine.cc | 24 | ||||
-rw-r--r-- | src/model/engine.h | 32 | ||||
-rw-r--r-- | src/model/model.cc | 40 | ||||
-rw-r--r-- | src/model/model.h | 17 |
5 files changed, 83 insertions, 34 deletions
diff --git a/src/model/Makefile.am b/src/model/Makefile.am index 1490bfc..5df1fd7 100644 --- a/src/model/Makefile.am +++ b/src/model/Makefile.am @@ -1,9 +1,9 @@ METASOURCES = AUTO -libmodel_la_SOURCES = light.cc model.cc vertexarray.cc +libmodel_la_SOURCES = engine.cc light.cc model.cc vertexarray.cc libmodel_la_LDFLAGS = -avoid-version -no-undefined -lm noinst_LTLIBRARIES = libmodel.la -noinst_HEADERS = light.h model.h vertexarray.h +noinst_HEADERS = engine.h light.h model.h vertexarray.h INCLUDES = -I$(top_srcdir)/src diff --git a/src/model/engine.cc b/src/model/engine.cc new file mode 100644 index 0000000..17201d0 --- /dev/null +++ b/src/model/engine.cc @@ -0,0 +1,24 @@ +/* + model/engine.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/engine.h" + +namespace model { + + +/* ---------- core::Engine ------------------------------------------ */ + +Engine::Engine(math::Vector3f const & location) : + engine_location(location) +{ + engine_radius = 1.0f; +} + +Engine::~Engine() +{} + +} diff --git a/src/model/engine.h b/src/model/engine.h new file mode 100644 index 0000000..fc868c9 --- /dev/null +++ b/src/model/engine.h @@ -0,0 +1,32 @@ +/* + model/engine.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_ENGINE_H__ +#define __INCLUDED_MODEL_ENGINE_H__ + +#include "math/vector3f.h" + +namespace model { + +/// a spacecraft engine +class Engine +{ +public: + Engine(math::Vector3f const & location); + ~Engine(); + + inline math::Vector3f const & location() const { return engine_location; } + + inline float radius() const { return engine_radius; } + + math::Vector3f engine_location; + float engine_radius; +}; + +} + +#endif // __INCLUDED_MODEL_ENGINE_H__ + diff --git a/src/model/model.cc b/src/model/model.cc index b3c8b03..8c853f8 100644 --- a/src/model/model.cc +++ b/src/model/model.cc @@ -41,16 +41,6 @@ Triangle::~Triangle() { } - -/* ---------- core::Engine ------------------------------------------ */ - -Engine::Engine(math::Vector3f const & location) : - engine_location(location) -{} - -Engine::~Engine() -{} - /* ---------- core::Model ------------------------------------------ */ std::map<std::string, Model*> Model::registry; @@ -101,7 +91,8 @@ Model::Model(std::string const & name) : float class_angle = 0; math::Color class_color; unsigned int class_spawnflags = 0; - float class_light = 100; + float class_light = 0.0f; + float class_radius = 0.0f; float class_frequency = 1.0f; float class_offset = 0; float class_time = 0.0f; @@ -124,7 +115,8 @@ Model::Model(std::string const & name) : class_origin = math::Vector3f(0,0,0); class_color = math::Color(1, 1, 1); class_spawnflags = 0; - class_light = 100; + class_light = 0.0f; + class_radius = 0.0f; class_offset = 0; class_frequency = 1.0f; class_time = 0.0f; @@ -153,12 +145,19 @@ Model::Model(std::string const & name) : brush_detail = false; } else if ((level == 1) && (class_name == "target_engine")) { - //con_debug << " engine at " << class_origin << "\n"; - add_engine(new Engine(class_origin * model_scale)); + model::Engine *engine = new Engine(class_origin * model_scale); + if (class_radius) + engine->engine_radius = class_radius / 100.0f; + add_engine(engine); + } else if ((level == 1) && (class_name == "light")) { Light *light = new Light(class_origin * model_scale, class_color, (class_spawnflags & 1) == 1); - light->light_radius = class_light / 100.0f; - light->light_offset = class_offset; + if (class_light) + light->light_radius = class_light / 100.0f; + else if (class_radius) + light->light_radius = class_radius / 100.0f; + if (class_offset > 0) + light->light_offset = class_offset; if (class_frequency > 0 ) light->light_frequency = class_frequency; if (class_time > 0 ) @@ -244,6 +243,15 @@ Model::Model(std::string const & name) : std::istringstream is(tmp); is >> class_light; + } else if (firstword == "\"radius\"") { + std::string tmp; + char c; + while ((linestream.get(c)) && (c != '"')); + while ((linestream.get(c)) && (c != '"')) + tmp += c; + std::istringstream is(tmp); + is >> class_radius; + } else if (firstword == "\"frequency\"") { std::string tmp; char c; diff --git a/src/model/model.h b/src/model/model.h index 95f84cc..f94c170 100644 --- a/src/model/model.h +++ b/src/model/model.h @@ -13,6 +13,7 @@ #include "math/mathlib.h" #include "math/plane3f.h" +#include "model/engine.h" #include "model/light.h" #include "model/vertexarray.h" @@ -48,22 +49,6 @@ private: bool triangle_detail; }; -/// a spacecraft engine -class Engine -{ -public: - Engine(math::Vector3f const & location); - ~Engine(); - - inline math::Vector3f const & location() const - { - return engine_location; - } - - math::Vector3f engine_location; -}; - - /// a 3D model contains a list of faces class Model |