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-07-30 19:50:51 +0000
committerStijn Buys <ingar@osirion.org>2008-07-30 19:50:51 +0000
commitcf0f21b73e53b4371c42c95e1132b1d3ce69ade5 (patch)
treef5efa4f20c581ab6a2672666d4b2df4ee9ce2b44 /src
parent04050c1685855a0640c7c0d5147299fadbd2ebe8 (diff)
minimize opengl transformation matrix by doing eye-location in software
Diffstat (limited to 'src')
-rw-r--r--src/client/targets.cc2
-rw-r--r--src/render/camera.cc3
-rw-r--r--src/render/draw.cc18
-rw-r--r--src/render/dust.cc27
4 files changed, 30 insertions, 20 deletions
diff --git a/src/client/targets.cc b/src/client/targets.cc
index 8dc5c07..541206d 100644
--- a/src/client/targets.cc
+++ b/src/client/targets.cc
@@ -364,7 +364,7 @@ void draw_target()
+ plane_normal.y * (entity->state()->location().y - render::Camera::eye().y)
+ plane_normal.z * (entity->state()->location().z - render::Camera::eye().z);
- Vector3f intersection = render::Camera::eye() + (entity->state()->location() - render::Camera::eye()) * t;
+ Vector3f intersection = (entity->state()->location() - render::Camera::eye()) * t;
// draw the target cursor in the frustum front plane, but in real world coordinates
const float r = 0.05;
diff --git a/src/render/camera.cc b/src/render/camera.cc
index 283f40f..a9aa1ca 100644
--- a/src/render/camera.cc
+++ b/src/render/camera.cc
@@ -322,7 +322,8 @@ void Camera::draw()
// apply camera offset
gl::translate(distance * camera_axis.forward());
*/
- gl::translate(-1.0f * camera_eye);
+ // camera sticks at 0,0,0
+ //gl::translate(camera_target - camera_eye);
}
void Camera::set_direction(float direction)
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 4399c60..13f9ee6 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -527,7 +527,7 @@ void draw_pass_default()
// draw entities without model
if (!entity->model()) {
gl::push();
- gl::translate(entity->state()->location());
+ gl::translate(entity->state()->location() - Camera::eye());
gl::multmatrix(entity->state()->axis());
if (flag_is_set(entity->flags(), core::Entity::Bright)) {
@@ -568,7 +568,7 @@ void draw_pass_default()
gl::color(entity->color());
gl::push();
- gl::translate(entity->state()->location());
+ gl::translate(entity->state()->location() - Camera::eye());
gl::multmatrix(entity->state()->axis());
// top
@@ -612,7 +612,7 @@ void draw_pass_model_fragments()
if (entity->model() && entity->state()->visible()) {
gl::push();
- gl::translate(entity->state()->location());
+ gl::translate(entity->state()->location() - Camera::eye());
gl::multmatrix(entity->state()->axis());
draw_model_fragments(entity);
@@ -661,7 +661,7 @@ void draw_pass_model_fx(float elapsed)
t = (core::application()->time() + entity->state()->fuzz() - light->offset()) * light->frequency();
if ((!light->strobe()) || (( t - floorf(t)) <= light->time())) {
- location.assign(entity->state()->location() + (entity->state()->axis() * light->location()));
+ location.assign(entity->state()->location() - Camera::eye() + (entity->state()->axis() * light->location()));
light_size = 0.0625 * light->radius();
if (flare_texture != light->texture()) {
@@ -708,7 +708,7 @@ void draw_pass_model_fx(float elapsed)
if (flare->angle())
flare_axis.change_direction(flare->angle());
- location.assign(entity->state()->location() + (entity->state()->axis() * flare->location()));
+ location.assign(entity->state()->location() - Camera::eye() + (entity->state()->axis() * flare->location()));
light_size = 0.0625 * flare->radius();
if (flare_texture != flare->texture()) {
@@ -762,7 +762,7 @@ void draw_pass_model_fx(float elapsed)
model::Engine *engine = (*eit);
- location.assign(entity->state()->location() + (entity->state()->axis() * engine->location()));
+ location.assign(entity->state()->location() - Camera::eye() + (entity->state()->axis() * engine->location()));
engine_size = 0.0625 * engine->radius();
color.assign(engine->color());
color.a = 0.9f * u;
@@ -849,7 +849,7 @@ void draw_pass_model_corona()
if (entity->model() && entity->state()->visible()) {
gl::push();
- gl::translate(entity->state()->location());
+ gl::translate(entity->state()->location() - Camera::eye());
math::Color color = entity->color();
color.a = 0.25f;
draw_sphere(color, entity->model()->radius());
@@ -883,7 +883,7 @@ void draw_pass_sky()
gl::enable(GL_TEXTURE_2D);
gl::push();
- gl::translate(Camera::eye());
+ //gl::translate(Camera::eye());
draw_sphere_inside(math::Color(), 128);
gl::pop();
@@ -903,7 +903,7 @@ void draw_pass_spacegrid()
float dy = Camera::target().y - floorf(Camera::target().y);
gl::push();
- gl::translate(Camera::target());
+ gl::translate(Camera::target() - Camera::eye());
gl::color(0,0, 1.0f);
gl::normal(0, 0, 1.0f);
diff --git a/src/render/dust.cc b/src/render/dust.cc
index 05266e8..a3eac6d 100644
--- a/src/render/dust.cc
+++ b/src/render/dust.cc
@@ -4,6 +4,7 @@
the terms of the GNU General Public License version 2
*/
+#include "render/camera.h"
#include "render/dust.h"
#include "render/gl.h"
#include "core/cvar.h"
@@ -54,6 +55,9 @@ void Dust::reset()
void Dust::draw()
{
+ float alpha = 0.0f;
+ float traillength = 0.0f;
+
if (!r_dust->value()) {
if (dust) {
delete dust;
@@ -95,14 +99,19 @@ void Dust::draw()
}
}
- if (!core::localcontrol()->speed())
+ if (! core::localcontrol()->speed())
return;
- math::Color color;
- if (core::localcontrol()->speed() < LOWSPEEDLIMIT) {
- color.a = core::localcontrol()->speed() / LOWSPEEDLIMIT;
- }
- color.a *= DUSTMAXALPHA;
+ math::Color color(1.0f, 1.0f);
+ alpha = core::localcontrol()->speed() / LOWSPEEDLIMIT;
+ if (alpha > DUSTMAXALPHA)
+ alpha = DUSTMAXALPHA;
+ color.a = alpha;
+
+ traillength = core::localcontrol()->speed() / LOWSPEEDLIMIT;
+ if (traillength > 1)
+ traillength = 1.0f;
+ traillength *= TRAILLENGHT;
gl::color(color);
gl::begin(gl::Lines);
@@ -120,11 +129,11 @@ void Dust::draw()
dust[i*3+2] = core::localcontrol()->location().z + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius());
}
- glVertex3fv(dust+3*i);
-
for (size_t j = 0; j < 3; j++)
v[j] = dust[i*3+j];
- v -= core::localcontrol()->state()->axis().forward() * color.a * TRAILLENGHT;
+ v -= Camera::eye();
+ gl::vertex(v);
+ v -= core::localcontrol()->state()->axis().forward() * traillength;
gl::vertex(v);
}