Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/model/Makefile.am8
-rw-r--r--src/model/classes.cc67
-rw-r--r--src/model/classes.h184
-rw-r--r--src/model/dock.cc20
-rw-r--r--src/model/dock.h43
-rw-r--r--src/model/engine.cc31
-rw-r--r--src/model/engine.h42
-rw-r--r--src/model/flare.cc21
-rw-r--r--src/model/flare.h38
-rw-r--r--src/model/light.cc29
-rw-r--r--src/model/light.h101
-rw-r--r--src/model/map.cc88
-rw-r--r--src/model/model.cc12
-rw-r--r--src/model/model.h23
14 files changed, 327 insertions, 380 deletions
diff --git a/src/model/Makefile.am b/src/model/Makefile.am
index f029390..93023ff 100644
--- a/src/model/Makefile.am
+++ b/src/model/Makefile.am
@@ -1,11 +1,11 @@
METASOURCES = AUTO
-libmodel_la_SOURCES = dock.cc engine.cc flare.cc fragment.cc light.cc map.cc \
- model.cc plane.cc primitives.cc quad.cc triangle.cc vertexarray.cc
+libmodel_la_SOURCES = classes.cc fragment.cc map.cc model.cc plane.cc \
+ primitives.cc quad.cc triangle.cc vertexarray.cc
libmodel_la_LDFLAGS = -avoid-version -no-undefined -lm
noinst_LTLIBRARIES = libmodel.la
-noinst_HEADERS = dock.h engine.h flare.h fragment.h light.h map.h material.h \
- model.h plane.h primitives.h quad.h triangle.h vertexarray.h
+noinst_HEADERS = classes.h fragment.h map.h material.h model.h plane.h \
+ primitives.h quad.h triangle.h vertexarray.h
INCLUDES = -I$(top_srcdir)/src
diff --git a/src/model/classes.cc b/src/model/classes.cc
new file mode 100644
index 0000000..4042c38
--- /dev/null
+++ b/src/model/classes.cc
@@ -0,0 +1,67 @@
+/*
+ model/classes.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/classes.h"
+
+namespace model {
+
+/* ---- class Light ------------------------------------------------ */
+
+Light::Light() :
+ light_location(),
+ light_color(1.0f, 1.0f, 1.0f)
+{
+ light_entity = false;
+ light_strobe = false;
+ light_radius = 1.0f;
+ light_frequency = 1.0f;
+ light_offset = 0.0f;
+ light_time = 0.5f;
+ light_flare = 0;
+ render_texture = 0;
+}
+
+Light::~Light()
+{}
+
+/* ---- class Flare ------------------------------------------------ */
+
+Flare::Flare() : Light()
+{
+ flare_angle = 0;
+ flare_engine = false;
+}
+
+Flare::~Flare()
+{}
+
+/* ---- class Particles -------------------------------------------- */
+
+Particles::Particles() :
+ particles_location()
+{
+}
+
+Particles::Particles(math::Vector3f const & location) :
+ particles_location(location)
+{
+}
+
+Particles::~Particles()
+{}
+
+/* ---- class Dock ------------------------------------------------- */
+
+Dock::Dock()
+{
+ dock_radius = 0.01f;
+}
+
+Dock::~Dock()
+{
+}
+
+}
diff --git a/src/model/classes.h b/src/model/classes.h
new file mode 100644
index 0000000..f51a391
--- /dev/null
+++ b/src/model/classes.h
@@ -0,0 +1,184 @@
+/*
+ model/classes.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_CLASSES_H__
+#define __INCLUDED_MODEL_CLASSES_H__
+
+#include "math/axis.h"
+#include "math/color.h"
+#include "math/vector3f.h"
+
+namespace model
+{
+
+/* ---- class Light ------------------------------------------------ */
+
+/// an exterior light
+class Light
+{
+public:
+ Light();
+
+ Light(const math::Vector3f & location, const math::Color & color, bool strobe=false);
+
+ ~Light();
+
+ inline const math::Vector3f & location() const
+ {
+ return light_location;
+ }
+
+ inline const math::Color & color() const
+ {
+ return light_color;
+ };
+
+ /// true if this is a strobe light
+ inline bool strobe() const
+ {
+ return light_strobe;
+ }
+
+ /// true if this light has entity color
+ inline bool entity() const
+ {
+ return light_entity;
+ }
+
+ /// size of the light, default is 1.0f
+ inline float radius() const
+ {
+ return light_radius;
+ }
+
+ /// strobe time offset, in seconds
+ inline float offset() const
+ {
+ return light_offset;
+ }
+
+ /// frequency in strobes per second
+ inline float frequency() const
+ {
+ return light_frequency;
+ }
+
+ /// fraction a strobe light will be on, default is 0.5f
+ inline float time() const
+ {
+ return light_time;
+ }
+
+ /// flare texture number
+ inline unsigned int flare() const
+ {
+ return light_flare;
+ }
+
+ /// render texture number
+ inline size_t texture() const
+ {
+ return render_texture;
+ }
+
+ math::Vector3f light_location;
+ math::Color light_color;
+ bool light_strobe;
+ bool light_entity;
+ float light_radius;
+ float light_frequency;
+ float light_offset;
+ float light_time;
+
+ unsigned int light_flare;
+
+ size_t render_texture;
+};
+
+/* ---- class Flare ------------------------------------------------ */
+
+/// a flare is a directional light
+class Flare : public Light
+{
+public:
+ Flare();
+ ~Flare();
+
+ inline float angle() const
+ {
+ return flare_angle;
+ }
+
+ inline bool engine() const
+ {
+ return flare_engine;
+ }
+
+ float flare_angle;
+ bool flare_engine;
+};
+
+/* ---- class Particles -------------------------------------------- */
+
+/// a particle system
+class Particles
+{
+public:
+ Particles();
+
+ Particles(const math::Vector3f & location);
+ ~Particles();
+
+ inline const math::Vector3f & location() const
+ {
+ return particles_location;
+ }
+
+ inline const math::Axis &axis() const
+ {
+ return particles_axis;
+ }
+
+ inline const std::string & script() const
+ {
+ return particles_script;
+ }
+
+ std::string particles_script;
+ math::Vector3f particles_location;
+ math::Axis particles_axis;
+};
+
+/* ---- class Dock ------------------------------------------------- */
+
+/// a docking location
+class Dock
+{
+public:
+ Dock();
+ ~Dock();
+
+ /// location of the dock
+ inline const math::Vector3f & location() const
+ {
+ return dock_location;
+ }
+
+ /// trigger distance default is 0.01f
+ inline float radius() const
+ {
+ return dock_radius;
+ }
+
+
+ math::Vector3f dock_location;
+ float dock_radius;
+};
+
+}
+
+#endif // __INCLUDED_MODEL_CLASSES_H__
+
diff --git a/src/model/dock.cc b/src/model/dock.cc
deleted file mode 100644
index bdc63e3..0000000
--- a/src/model/dock.cc
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- model/dock.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/dock.h"
-
-namespace model {
-
-Dock::Dock()
-{
- dock_radius = 0.01f;
-}
-
-Dock::~Dock()
-{
-}
-
-}
diff --git a/src/model/dock.h b/src/model/dock.h
deleted file mode 100644
index 89a4026..0000000
--- a/src/model/dock.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- model/dock.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_DOCK_H__
-#define __INCLUDED_MODEL_DOCK_H__
-
-#include "math/vector3f.h"
-#include "math/color.h"
-
-namespace model
-{
-
-/// a docking location
-class Dock
-{
-public:
- Dock();
- ~Dock();
-
- /// location of the dock
- inline math::Vector3f const & location() const
- {
- return dock_location;
- }
-
- /// trigger distance default is 0.01f
- inline float radius() const
- {
- return dock_radius;
- }
-
-
- math::Vector3f dock_location;
- float dock_radius;
-};
-
-}
-
-#endif // __INCLUDED_MODEL_DOCK_H__
-
diff --git a/src/model/engine.cc b/src/model/engine.cc
deleted file mode 100644
index 959f2ce..0000000
--- a/src/model/engine.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- 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
-{
-
-
-/* ---- class Engine ----------------------------------------------- */
-
-Engine::Engine() :
- engine_location()
-{
- engine_radius = 1.0f;
-}
-
-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
deleted file mode 100644
index 68f16e5..0000000
--- a/src/model/engine.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- 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"
-#include "math/color.h"
-
-namespace model
-{
-
-/// a spacecraft engine
-class Engine
-{
-public:
- Engine();
-
- 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/flare.cc b/src/model/flare.cc
deleted file mode 100644
index 5491dd2..0000000
--- a/src/model/flare.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- 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_engine = false;
-}
-
-Flare::~Flare()
-{}
-
-}
diff --git a/src/model/flare.h b/src/model/flare.h
deleted file mode 100644
index 6affe55..0000000
--- a/src/model/flare.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- 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;
- }
-
- inline bool engine() const
- {
- return flare_engine;
- }
-
- float flare_angle;
- bool flare_engine;
-};
-
-}
-
-#endif // __INCLUDED_MODEL_FLARE_H__
diff --git a/src/model/light.cc b/src/model/light.cc
deleted file mode 100644
index 01ddf96..0000000
--- a/src/model/light.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- model/light.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/light.h"
-
-namespace model
-{
-
-Light::Light() :
- light_location(),
- light_color(1.0f, 1.0f, 1.0f)
-{
- light_entity = false;
- light_strobe = false;
- 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/light.h b/src/model/light.h
deleted file mode 100644
index f91cabe..0000000
--- a/src/model/light.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- model/light.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_LIGHT_H__
-#define __INCLUDED_MODEL_LIGHT_H__
-
-#include "math/vector3f.h"
-#include "math/color.h"
-
-namespace model
-{
-
-/// an exterior light
-class Light
-{
-public:
- Light();
-
- 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;
- };
-
- /// true if this is a strobe light
- inline bool strobe() const
- {
- return light_strobe;
- }
-
- /// true if this light has entity color
- inline bool entity() const
- {
- return light_entity;
- }
-
- /// size of the light, default is 1.0f
- inline float radius() const
- {
- return light_radius;
- }
-
- /// strobe time offset, in seconds
- inline float offset() const
- {
- return light_offset;
- }
-
- /// frequency in strobes per second
- inline float frequency() const
- {
- return light_frequency;
- }
-
- /// fraction a strobe light will be on, default is 0.5f
- inline float time() const
- {
- return light_time;
- }
-
- /// flare texture number
- inline unsigned int flare() const
- {
- return light_flare;
- }
-
- /// render texture number
- inline size_t texture() const
- {
- return render_texture;
- }
-
- math::Vector3f light_location;
- math::Color light_color;
- bool light_strobe;
- bool light_entity;
- float light_radius;
- float light_frequency;
- float light_offset;
- float light_time;
-
- unsigned int light_flare;
-
- size_t render_texture;
-};
-
-}
-
-#endif // __INCLUDED_MODEL_LIGHT_H__
-
diff --git a/src/model/map.cc b/src/model/map.cc
index 1767743..29332ee 100644
--- a/src/model/map.cc
+++ b/src/model/map.cc
@@ -6,9 +6,6 @@
#include "filesystem/filesystem.h"
#include "math/mathlib.h"
-#include "model/dock.h"
-#include "model/engine.h"
-#include "model/light.h"
#include "model/map.h"
#include "model/material.h"
#include "model/model.h"
@@ -30,9 +27,6 @@ inline bool spawnflag_isset(unsigned int spawnflags, unsigned int flag)
// max geometry bounds
const float MAX_BOUNDS = 16384;
-// scaling factor when loading .map geometry
-const float SCALE = 1.0f / 1024.0f;
-
const float MIN_DELTA = 10e-10;
Map::Map() : map_center(0,0,0)
@@ -795,11 +789,12 @@ Model * Map::load(std::string const &name)
Model *model = new Model(name);
Dock *dock = 0;
- Engine *engine = 0;
+ Particles *particles = 0;
Flare *flare = 0;
Light *light = 0;
unsigned int u;
+ float angle;
while (mapfile.getline()) {
@@ -858,10 +853,10 @@ Model * Map::load(std::string const &name)
light->light_entity = spawnflag_isset(u, 2);
} else if (mapfile.got_key_float("light", light->light_radius)) {
- light->light_radius /= 100.0f;
+ light->light_radius *= LIGHTSCALE;
} else if (mapfile.got_key_float("radius", light->light_radius)) {
- light->light_radius /= 100.0f;
+ light->light_radius *= LIGHTSCALE;
} else if (mapfile.got_key_float("frequency", light->light_frequency)) {
continue;
@@ -880,13 +875,13 @@ Model * Map::load(std::string const &name)
}
- } else if (mapfile.got_classname("trigger_dock")) {
+ } else if (mapfile.got_classname("location_dock")) {
// new docking location
dock = new Dock();
model->add_dock(dock);
- } else if (mapfile.classname().compare("trigger_dock") == 0) {
+ } else if (mapfile.classname().compare("location_dock") == 0) {
// dock attributes
if (mapfile.got_key_vector3f("origin", dock->dock_location)) {
@@ -894,7 +889,7 @@ Model * Map::load(std::string const &name)
continue;
} else if (mapfile.got_key_float("radius", dock->dock_radius)) {
- dock->dock_radius /= 100.0f;
+ dock->dock_radius *= SCALE;
continue;
} else if (mapfile.got_key("angle")) {
@@ -905,13 +900,28 @@ Model * Map::load(std::string const &name)
}
- } else if (mapfile.got_classname("target_flare")) {
+ } else if (mapfile.got_classname("location_cannon")) {
+ // new cannon
+
+ } else if (mapfile.classname().compare("location_cannon") == 0) {
+
+ } else if (mapfile.got_classname("location_turret")) {
+ // new turret
+
+ } else if (mapfile.classname().compare("location_turret") == 0) {
+
+ } else if (mapfile.got_classname("location_cockpit")) {
+ // cockpit location
+
+ } else if (mapfile.classname().compare("location_cockpit") == 0) {
+
+ } else if (mapfile.got_classname("fx_flare")) {
// new flare
flare = new Flare();
model->add_flare(flare);
-
- } else if (mapfile.classname().compare("target_flare") == 0) {
+
+ } else if (mapfile.classname().compare("fx_flare") == 0) {
// flare attributes
if (mapfile.got_key_vector3f("origin", flare->light_location)) {
@@ -927,7 +937,7 @@ Model * Map::load(std::string const &name)
flare->flare_engine = spawnflag_isset(u, 4);
} else if (mapfile.got_key_float("radius", flare->light_radius)) {
- flare->light_radius /= 100.0f;
+ flare->light_radius *= LIGHTSCALE;
} else if (mapfile.got_key_float("frequency", flare->light_frequency)) {
continue;
@@ -949,35 +959,45 @@ Model * Map::load(std::string const &name)
con_warn "unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl;
}
- } else if (mapfile.got_classname("target_engine")) {
- // new engine
- engine = new Engine();
- model->add_engine(engine);
-
- } else if (mapfile.classname().compare("target_engine") == 0) {
- // engine attributes
+ } else if (mapfile.got_classname("fx_particles")) {
+
+ // new particle system
+ particles = new Particles();
+ model->add_particles(particles);
- if (mapfile.got_key_vector3f("origin", engine->engine_location)) {
- engine->engine_location *= SCALE;
+ } else if (mapfile.classname().compare("fx_particles") == 0) {
+
+ // particle system attributes
+ if (mapfile.got_key_vector3f("origin", particles->particles_location)) {
+ particles->particles_location *= SCALE;
continue;
-
- } else if (mapfile.got_key_float("radius", engine->engine_radius)) {
- engine->engine_radius /= 100.0f;
+ } 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);
- } else if (mapfile.got_key("angle")) {
- continue;
+ } else if (mapfile.got_key_float("direction", angle)) {
+ particles->particles_axis.change_direction(angle);
+
+ } else if (mapfile.got_key_float("pitch", angle)) {
+ particles->particles_axis.change_pitch(angle);
+
+ } else if (mapfile.got_key_float("roll", angle)) {
+ particles->particles_axis.change_roll(angle);
} else if (mapfile.got_key()) {
- con_warn "unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl;
+ con_warn << "Unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl;
}
+ } else if (mapfile.got_classname()) {
+
+ con_warn << "Unkown class '" << mapfile.classname() << "'" << std::endl;
}
}
mapfile.close();
- // reposition docks, lights, flares and engines according to the model center
+ // reposition docks, lights, flares and particles according to the model center
for (Model::Lights::iterator lit = model->lights().begin(); lit != model->lights().end(); lit++) {
(*lit)->light_location -= mapfile.map_center;
}
@@ -986,8 +1006,8 @@ Model * Map::load(std::string const &name)
(*flit)->light_location -= mapfile.map_center;
}
- for (Model::Engines::iterator eit = model->engines().begin(); eit != model->engines().end(); eit++) {
- (*eit)->engine_location -= mapfile.map_center;
+ for (Model::ParticleSystems::iterator pit = model->particles().begin(); pit != model->particles().end(); pit++) {
+ (*pit)->particles_location -= mapfile.map_center;
}
for (Model::Docks::iterator dit = model->docks().begin(); dit != model->docks().end(); dit++) {
diff --git a/src/model/model.cc b/src/model/model.cc
index 3329afe..8fadb33 100644
--- a/src/model/model.cc
+++ b/src/model/model.cc
@@ -40,11 +40,11 @@ Model::~Model()
delete (*dit);
}
- // delete all engines
- for (Engines::iterator eit = model_engines.begin(); eit != model_engines.end(); eit++) {
- delete(*eit);
+ // delete all particle systems
+ for (Model::ParticleSystems::iterator pit = model_particles.begin(); pit != model_particles.end(); pit++) {
+ delete (*pit);
}
- model_engines.clear();
+ model_particles.clear();
// delete all lights
for (Lights::iterator lit = model_lights.begin(); lit != model_lights.end(); lit++) {
@@ -59,9 +59,9 @@ Model::~Model()
model_flares.clear();
}
-void Model::add_engine(Engine *engine)
+void Model::add_particles(Particles *particles)
{
- model_engines.push_back(engine);
+ model_particles.push_back(particles);
}
void Model::add_light(Light *light)
diff --git a/src/model/model.h b/src/model/model.h
index cb10386..5b52fde 100644
--- a/src/model/model.h
+++ b/src/model/model.h
@@ -12,16 +12,17 @@
#include <map>
#include "math/mathlib.h"
-#include "model/dock.h"
-#include "model/engine.h"
+#include "model/classes.h"
#include "model/fragment.h"
-#include "model/light.h"
-#include "model/flare.h"
/// classes representing 3D geometry
namespace model
{
+/// scaling factor when loading .map geometry
+const float SCALE = 1.0f / 1024.0f;
+const float LIGHTSCALE = 1.0f / 100.0f;
+
/// a 3D model contains a list of faces
class Model
{
@@ -41,8 +42,8 @@ public:
/// type definition for a lost of dockable locations
typedef std::list<Dock *> Docks;
- /// type definition for a list of model engines
- typedef std::list<Engine *> Engines;
+ /// type definition for a list of model particles
+ typedef std::list<Particles *> ParticleSystems;
/// create a model with a name
Model(std::string const & name);
@@ -87,9 +88,9 @@ public:
}
/// list of engines
- inline Engines & engines()
+ inline ParticleSystems & particles()
{
- return model_engines;
+ return model_particles;
}
/// maximum values of the bounding box
@@ -122,8 +123,8 @@ public:
/// add a light to the model
void add_light(Light *light);
- /// add an engine to the model
- void add_engine(Engine *engine);
+ /// add a particle system to the model
+ void add_particles(Particles *particles);
/// add a flare to the model
void add_flare(Flare *flare);
@@ -181,9 +182,9 @@ private:
FragmentGroup model_worldspawn;
Docks model_docks;
- Engines model_engines;
Flares model_flares;
Lights model_lights;
+ ParticleSystems model_particles;
};
}