Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
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
parent6155d32aa9e5fc2e5548fcc863a64d442cf5770a (diff)
better target_engine rendering
Diffstat (limited to 'src')
-rw-r--r--src/core/gameserver.cc16
-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
-rw-r--r--src/render/draw.cc61
-rw-r--r--src/render/textures.cc9
-rw-r--r--src/render/textures.h3
9 files changed, 155 insertions, 51 deletions
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index bedab1d..ae2b3a9 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -256,14 +256,16 @@ void GameServer::frame(float seconds)
if (localplayer()->dirty())
localplayer()->update_info();
- float f = 0;
server_frametime += seconds;
- if (core::Cvar::sv_framerate->value()) {
- f = 1.0f / core::Cvar::sv_framerate->value();
- if (server_frametime < f) {
- return;
+
+ if ((Cvar::sv_dedicated->value() || Cvar::sv_private->value())) {
+ if (core::Cvar::sv_framerate->value()) {
+ float f = 1.0f / core::Cvar::sv_framerate->value();
+ if (server_frametime < f) {
+ return;
+ }
}
- }
+ }
// run a time frame on each entity
std::map<unsigned int, Entity *>::iterator it;
@@ -358,7 +360,7 @@ void GameServer::frame(float seconds)
}
}
- server_frametime -= f;
+ server_frametime = 0;
}
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
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 5627ac6..7342b69 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -385,7 +385,7 @@ void draw_pass_model_fx() {
gl::translate(entity->location());
gl::multmatrix(entity->axis());
- draw_model_engines((core::EntityControlable *)entity);
+// draw_model_engines((core::EntityControlable *)entity);
draw_model_shield((core::EntityControlable *)entity);
gl::pop();
}
@@ -397,8 +397,11 @@ void draw_pass_model_fx() {
/* draw model lights */
void draw_pass_model_lights()
{
- //glPointSize(10);
+ float t;
+
size_t flare_texture = Textures::bind("bitmaps/fx/flare00");
+ size_t engine_texture = Textures::find("bitmaps/fx/flare01");
+
gl::enable(GL_TEXTURE_2D);
gl::begin(gl::Quads);
@@ -406,11 +409,13 @@ void draw_pass_model_lights()
for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
core::Entity *entity = (*it).second;
- if (test_drawfx_distance(entity) && (entity->model()->model_light.size())) {
-
+ if (test_drawfx_distance(entity)) {
+
+ // draw model lights
for (std::list<model::Light *>::iterator lit = entity->model()->model_light.begin(); lit != entity->model()->model_light.end(); lit++) {
+
// strobe frequency
- float t = 1.0f;
+ t = 1.0f;
if ((*lit)->strobe())
t = (core::application()->time() + entity->fuzz() + (*lit)->offset()) * (*lit)->frequency();
@@ -432,22 +437,58 @@ void draw_pass_model_lights()
gl::vertex(location + (camera_axis.up() - camera_axis.left()) * light_size);
glTexCoord2f(0,0);
gl::vertex(location + (camera_axis.up() + camera_axis.left()) * light_size);
- glTexCoord2f(-1,0);
+ glTexCoord2f(1,0);
gl::vertex(location + (camera_axis.up() * -1 + camera_axis.left()) * light_size);
- glTexCoord2f(-1,1);
+ glTexCoord2f(1,1);
gl::vertex(location + (camera_axis.up() * -1 - camera_axis.left()) * light_size);
Stats::quads++;
}
- }
+ }
+
+ // draw model engines for Controlable entities
+ if (entity->type() == core::Entity::Controlable && entity->model()->model_engine.size()) {
+
+ if (flare_texture != engine_texture) {
+ gl::end();
+ flare_texture = Textures::bind(engine_texture);
+ gl::begin(gl::Quads);
+ }
+
+ float u = static_cast<core::EntityControlable *>(entity)->thrust();
+
+ t = entity->fuzz() + core::application()->time() * 4;
+
+ t = t - floorf(t);
+ if (t > 0.5)
+ t = 1-t;
+ t = 0.75f + t/2;
+
+ for(std::list<model::Engine*>::iterator eit = entity->model()->model_engine.begin(); eit != entity->model()->model_engine.end(); eit++) {
+ math::Vector3f location = entity->location() + (entity->axis() * (*eit)->location());
+ float engine_size = 0.0625 * (*eit)->radius() * t;
+
+ math::Color color(1.0f, 0.0f, 0.0f, 0.9f * u);
+
+ gl::color(color);
+ glTexCoord2f(0,1);
+ gl::vertex(location + (camera_axis.up() - camera_axis.left()) * engine_size);
+ glTexCoord2f(0,0);
+ gl::vertex(location + (camera_axis.up() + camera_axis.left()) * engine_size);
+ glTexCoord2f(1,0);
+ gl::vertex(location + (camera_axis.up() * -1 + camera_axis.left()) * engine_size);
+ glTexCoord2f(1,1);
+ gl::vertex(location + (camera_axis.up() * -1 - camera_axis.left()) * engine_size);
+
+ Stats::quads++;
+ }
+ }
}
}
gl::end();
gl::disable(GL_TEXTURE_2D);
- //glPointSize(1);
-
}
void draw_pass_model_radius()
diff --git a/src/render/textures.cc b/src/render/textures.cc
index 6880d87..eef5f1d 100644
--- a/src/render/textures.cc
+++ b/src/render/textures.cc
@@ -110,6 +110,15 @@ size_t Textures::load(std::string name)
return id;
}
+size_t Textures::find(std::string name)
+{
+ size_t id = 0;
+ iterator it = registry.find(name);
+ if (it != registry.end())
+ id = (*it).second;
+ return id;
+}
+
size_t Textures::bind(std::string name)
{
size_t id = 0;
diff --git a/src/render/textures.h b/src/render/textures.h
index ad38451..f8e35b3 100644
--- a/src/render/textures.h
+++ b/src/render/textures.h
@@ -39,6 +39,9 @@ public:
/// bind a texture for OpenGL usage
static size_t bind(size_t texture);
+ /// find the texture index for a given name
+ static size_t find(std::string name);
+
private:
static void clear();