Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-05-04 11:39:24 +0000
committerStijn Buys <ingar@osirion.org>2008-05-04 11:39:24 +0000
commit33e45d8052b385aa8b1fce68122c8d11f50e7e42 (patch)
treea1a92304f5be2bb322d4d491e737972eb9dd9dfc /src/model
parent6155d32aa9e5fc2e5548fcc863a64d442cf5770a (diff)
better target_engine rendering
Diffstat (limited to 'src/model')
-rw-r--r--src/model/Makefile.am4
-rw-r--r--src/model/engine.cc24
-rw-r--r--src/model/engine.h32
-rw-r--r--src/model/model.cc40
-rw-r--r--src/model/model.h17
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