diff options
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/draw.cc | 55 | ||||
-rw-r--r-- | src/render/gl.cc | 19 | ||||
-rw-r--r-- | src/render/gl.h | 8 |
3 files changed, 75 insertions, 7 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc index 4305b4d..e9976b6 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -276,7 +276,10 @@ void draw_pass_default() if (!entity->model()) { gl::push(); gl::translate(entity->location()); - gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f ); + + // FIXME + //gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f ); + gl::multmatrix(entity->axis()); if ((entity->flags() & core::Entity::Bright) == core::Entity::Bright) gl::disable(GL_LIGHTING); @@ -326,7 +329,9 @@ void draw_pass_model_vertex() if (test_draw_distance(entity)) { gl::push(); gl::translate(entity->location()); - gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f ); + // FIXME + //gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f ); + gl::multmatrix(entity->axis()); draw_model_vertex(entity); @@ -346,7 +351,9 @@ void draw_pass_model_evertex() if (test_draw_distance(entity)) { gl::push(); gl::translate(entity->location()); - gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f ); + // FIXME + //gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f ); + gl::multmatrix(entity->axis()); draw_model_evertex(entity); @@ -366,7 +373,9 @@ void draw_pass_model_fx() { gl::push(); gl::translate(entity->location()); - gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f ); + // FIXME + //gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f ); + gl::multmatrix(entity->axis()); draw_model_lights(entity); @@ -436,6 +445,42 @@ void draw_pass_spacegrid() gl::pop(); } +void draw_local_axis() +{ + if (!core::localcontrol()) + return; + + gl::push(); + gl::translate(core::localcontrol()->location()); + + gl::begin(gl::Lines); + gl::color(0.5f, 0.0f,0.0f); + gl::vertex(core::localcontrol()->axis()[0] * -1.0f); + gl::color(1.0f, 0.0f, 0.0f); + gl::vertex(core::localcontrol()->axis()[0]); + + gl::color(0.5f, 0.5f,0.0f); + gl::vertex(core::localcontrol()->axis()[1] * -1.0f); + gl::color(1.0f, 1.0f, 0.0f); + gl::vertex(0.0f, 0.0f, 0.0f); + + gl::color(0.5f, 0.5f,0.0f); + gl::vertex(core::localcontrol()->axis()[1]); + gl::color(1.0f, 1.0f, 0.0f); + gl::vertex(0.0f, 0.0f, 0.0f); + + gl::color(0.0f, 0.5f,0.0f); + gl::vertex(core::localcontrol()->axis()[2] * -1.0f); + gl::color(0.0f, 1.0f, 0.0f); + gl::vertex(0.0f, 0.0f, 0.0f); + + gl::color(0.0f, 0.5f,0.0f); + gl::vertex(core::localcontrol()->axis()[2]); + gl::color(0.0f, 1.0f, 0.0f); + gl::vertex(0.0f, 0.0f, 0.0f); + + gl::pop(); +} /* ----- Main draw routine ----------------------------------------- */ void draw(math::Vector3f const &eye, math::Vector3f const &target, float seconds) @@ -500,6 +545,8 @@ void draw(math::Vector3f const &eye, math::Vector3f const &target, float seconds gl::disable(GL_COLOR_MATERIAL); // disable color tracking gl::disable(GL_CULL_FACE); // disable culling + draw_local_axis(); + draw_pass_spacegrid(); // draw the blue spacegrid gl::disable(GL_DEPTH_TEST); // disable depth buffer writing diff --git a/src/render/gl.cc b/src/render/gl.cc index a5f2d99..37ff75f 100644 --- a/src/render/gl.cc +++ b/src/render/gl.cc @@ -7,6 +7,8 @@ #include "GL/gl.h" #include "render/gl.h" +#include "math/matrix4f.h" + using math::Vector3f; using math::Color; @@ -121,7 +123,7 @@ void scale(const float x, const float y, const float z) { } void vertex(const Vector3f& vector) { - glVertex3fv(vector.coord); + glVertex3fv(vector.ptr()); } void vertex(const float x, const float y, const float z) { @@ -129,7 +131,7 @@ void vertex(const float x, const float y, const float z) { } void normal(const Vector3f & vector) { - glNormal3fv(vector.coord); + glNormal3fv(vector.ptr()); } void normal(const float x, const float y, const float z) { @@ -144,11 +146,22 @@ void pop() { glPopMatrix(); } +void multmatrix(const math::Matrix4f & matrix) +{ + glMultMatrixf(matrix.ptr()); +} + +void multmatrix(const math::Axis & axis) +{ + math::Matrix4f matrix(axis); + glMultMatrixf(matrix.ptr()); +} + void color(const float r, const float g, const float b, const float a) { glColor4f(r,g,b,a); } void color(Color const & color) { - glColor4fv(color.rgba_data); + glColor4fv(color.ptr()); } void matrixmode(GLenum mode) { diff --git a/src/render/gl.h b/src/render/gl.h index 69eb412..4383e52 100644 --- a/src/render/gl.h +++ b/src/render/gl.h @@ -11,6 +11,8 @@ #include <GL/glu.h> #include "math/vector3f.h" +#include "math/matrix4f.h" +#include "math/axis.h" #include "math/color.h" #ifdef _WIN32 @@ -146,6 +148,12 @@ namespace gl */ void scale(const float x, const float y, const float z); + /// multiply the current matrix with a coordinate system transformation + void multmatrix(const math::Axis & axis); + + /// multiply the current matrix with a 4x4 float matrix + void multmatrix(const math::Matrix4f & matrix); + /// specify the drawing color for the next GL functions /** @param color the new drawing color */ |