Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/input.cc13
-rw-r--r--src/core/model.cc25
-rw-r--r--src/core/model.h8
-rw-r--r--src/game/game.cc8
-rw-r--r--src/render/draw.cc40
5 files changed, 62 insertions, 32 deletions
diff --git a/src/client/input.cc b/src/client/input.cc
index 87492c4..533ea64 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -66,21 +66,24 @@ void keyreleased(const SDL_keysym &keysym)
case SDLK_SPACE:
camera::next_mode();
+ local_roll = 0;
+ local_pitch = 0;
+ local_turn = 0;
break;
- case SDLK_KP8: // down
+ case SDLK_KP8: // turn down
local_pitch = 0.0f;
break;
- case SDLK_KP2: // up
+ case SDLK_KP2: // turn up
local_pitch = 0.0f;
break;
- case SDLK_KP4: // left
+ case SDLK_KP4: // turn left
local_turn = 0.0f;
break;
- case SDLK_KP6: // right
+ case SDLK_KP6: // turn right
local_turn = 0.0f;
break;
@@ -88,7 +91,7 @@ void keyreleased(const SDL_keysym &keysym)
local_roll = 0.0f;
break;
- case SDLK_KP_MULTIPLY: // roll light
+ case SDLK_KP_MULTIPLY: // roll right
local_roll = 0.0f;
break;
diff --git a/src/core/model.cc b/src/core/model.cc
index e956612..c38749b 100644
--- a/src/core/model.cc
+++ b/src/core/model.cc
@@ -184,6 +184,7 @@ Light::Light(math::Vector3f const & location, math::Color const & color, bool st
light_radius = 1.0f;
light_frequency = 1.0f;
light_offset = 0.0f;
+ light_time = 0.5f;
}
Light::~Light()
@@ -251,6 +252,7 @@ Model::Model(std::string const & name) :
float class_light = 100;
float class_frequency = 1.0f;
float class_offset = 0;
+ float class_time = 0.0f;
bool brush_detail = false;
while (ifs) {
@@ -272,6 +274,7 @@ Model::Model(std::string const & name) :
class_light = 100;
class_offset = 0;
class_frequency = 1.0f;
+ class_time = 0.0f;
brush_detail = false;
}
level ++;
@@ -302,7 +305,10 @@ Model::Model(std::string const & name) :
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;
- light->light_frequency = class_frequency;
+ if (class_frequency > 0 )
+ light->light_frequency = class_frequency;
+ if (class_time > 0 )
+ light->light_time = class_time;
add_light(light);
}
@@ -399,6 +405,15 @@ Model::Model(std::string const & name) :
tmp += c;
std::istringstream is(tmp);
is >> class_offset;
+
+ } else if (firstword == "\"time\"") {
+ std::string tmp;
+ char c;
+ while ((linestream.get(c)) && (c != '"'));
+ while ((linestream.get(c)) && (c != '"'))
+ tmp += c;
+ std::istringstream is(tmp);
+ is >> class_time;
} else if (firstword == "(") {
if ((level == 2) && (class_name == "worldspawn")) {
@@ -408,6 +423,7 @@ Model::Model(std::string const & name) :
Vector3f p3;
std::string tmp;
std::string texture;
+ int n;
linestream >> p1;
linestream >> tmp; // )
@@ -423,9 +439,10 @@ Model::Model(std::string const & name) :
for (int i=0; i < 5; i++)
linestream >> tmp;
- if (linestream >> tmp)
- brush_detail = true;
-
+ if (linestream >> n) {
+ if (n > 0)
+ brush_detail = true;
+ }
//cout << data << std::endl;
//cout << "(" << p1 << ") (" << p2 << ") (" << p3 << ") " << texture << std::endl;
diff --git a/src/core/model.h b/src/core/model.h
index 1c56982..6175ec7 100644
--- a/src/core/model.h
+++ b/src/core/model.h
@@ -119,13 +119,20 @@ public:
inline math::Color const & color() const { return light_color; };
+ /// true if this is a strobe light
inline bool strobe() const { return light_strobe; }
+ /// size if 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; }
math::Vector3f light_location;
math::Color light_color;
@@ -133,6 +140,7 @@ public:
float light_radius;
float light_frequency;
float light_offset;
+ float light_time;
};
diff --git a/src/game/game.cc b/src/game/game.cc
index 07327d9..74aa2d9 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -129,6 +129,8 @@ void Game::init()
core::Entity *entity = 0;
float direction;
+ float pitch;
+ float roll;
while (worldini.getline()) {
if (worldini.got_key()) {
@@ -168,6 +170,12 @@ void Game::init()
else if (worldini.got_key_angle("direction", direction)) {
entity->axis().change_direction(direction);
continue;
+ } else if (worldini.got_key_angle("pitch", pitch)) {
+ entity->axis().change_pitch(pitch);
+ continue;
+ } else if (worldini.got_key_angle("roll", roll)) {
+ entity->axis().change_roll(roll);
+ continue;
} else if (worldini.got_key_angle("radius", entity->entity_radius))
continue;
else if (worldini.got_key_vector3f("location", entity->entity_location))
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 741eb3d..3fe64a5 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -287,9 +287,6 @@ void draw_pass_default()
if (!entity->model()) {
gl::push();
gl::translate(entity->location());
-
- // FIXME
- //gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f );
gl::multmatrix(entity->axis());
if ((entity->flags() & core::Entity::Bright) == core::Entity::Bright)
@@ -392,12 +389,10 @@ void draw_pass_model_lights()
gl::begin(gl::Quads);
-
-
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) && (entity->model()->model_light.size())) {
for (std::list<core::Light *>::iterator lit = entity->model()->model_light.begin(); lit != entity->model()->model_light.end(); lit++) {
// strobe frequency
@@ -405,27 +400,26 @@ void draw_pass_model_lights()
if ((*lit)->strobe())
t = (core::application()->time() + entity->fuzz() + (*lit)->offset()) * (*lit)->frequency();
- if (!(*lit)->strobe() || (( t - floorf(t)) < 0.5f)) {
+ if (!(*lit)->strobe() || (( t - floorf(t)) <= (*lit)->time())) {
math::Vector3f location = entity->location() + (entity->axis() * (*lit)->location());
- float n = dotproduct(camera_axis.forward(), (camera_eye-location));
float light_size = 0.0625 * (*lit)->radius();
- if (n < 0) {
- math::Color color((*lit)->color());
- color.a = fabs(-atanf(n) * 2 / M_PI);
- gl::color(color);
+
+ math::Color color((*lit)->color());
+ color.a = 0.8;
+ gl::color(color);
+
+ glTexCoord2f(0,1);
+ 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);
+ gl::vertex(location + (camera_axis.up() * -1 + camera_axis.left()) * light_size);
+ glTexCoord2f(-1,1);
+ gl::vertex(location + (camera_axis.up() * -1 - camera_axis.left()) * light_size);
+
+ Stats::quads++;
- glTexCoord2f(0,1);
- 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);
- gl::vertex(location + (camera_axis.up() * -1 + camera_axis.left()) * light_size);
- glTexCoord2f(-1,1);
- gl::vertex(location + (camera_axis.up() * -1 - camera_axis.left()) * light_size);
-
- Stats::quads++;
- }
}
}
}