diff options
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/camera.cc | 24 | ||||
-rw-r--r-- | src/render/camera.h | 9 | ||||
-rw-r--r-- | src/render/draw.cc | 6 | ||||
-rw-r--r-- | src/render/draw.h | 5 |
4 files changed, 37 insertions, 7 deletions
diff --git a/src/render/camera.cc b/src/render/camera.cc index ba056d0..092cc26 100644 --- a/src/render/camera.cc +++ b/src/render/camera.cc @@ -374,6 +374,30 @@ void Camera::frustum() gl::translate(-1.0f * camera_eye); } +void Camera::frustum_default(float distance, float cx, float cy) +{ + // Change to the projection matrix and set our viewing volume large enough for the skysphere + gl::matrixmode(GL_PROJECTION); + gl::loadidentity(); + + // note: the factor 2.0f probably has to be 1.0f/frustum_size + gl::translate(2.0f*(-State::width() * 0.5f + cx)/State::width() , 2.0f*(State::height() * 0.5f - cy)/State::height(), 0.0f); + + gl::frustum(-camera_frustum_size, camera_frustum_size, -camera_frustum_size/State::aspect(), camera_frustum_size/State::aspect(), camera_frustum_front, 1023.0f); + + gl::matrixmode(GL_MODELVIEW); + gl::loadidentity(); + + // map world coordinates to opengl coordinates + gl::rotate(90.0f, 0.0f, 1.0f, 0.0f); + gl::rotate(-90.0f, 1.0f , 0.0f, 0.0f); + + gl::translate(distance+1.0f, 0.0f, 0.0f); + + // extra model rotation + gl::rotate(-core::application()->time() / 8.0f *360.0f , 0.0f, 0.0f, 1.0f); +} + void Camera::ortho() { // switch to orthographic projection diff --git a/src/render/camera.h b/src/render/camera.h index 400c4b0..349aef8 100644 --- a/src/render/camera.h +++ b/src/render/camera.h @@ -43,11 +43,16 @@ public: /// progress the camera static void frame(float elapsed); - /// enable frustum projection - /** The frustum projection is used to draw the world + /// enable camera frustum projection + /** The camera frustum projection is used to draw the world */ static void frustum(); + /// enable default frustum projection + /** The default frustum projection is used to draw Gui 3D models + */ + static void frustum_default(float distance, float cx, float cy); + /// enable orthographic projection /** The ortographic projetion is used to draw the user interface */ diff --git a/src/render/draw.cc b/src/render/draw.cc index 6762b64..5784347 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -539,12 +539,8 @@ void draw_fragment(model::Fragment *fragment, bool draw_details) void draw_model_fragments(model::Model *model, const math::Color & color_primary, const math::Color & color_secondary, - const bool detail = true, const bool power = true, const float thrust = 0.0f) + const bool detail, const bool power, const float thrust) { - - if (!model) - return; - // default material, lighted and geometry color const model::Material *material = 0; bool use_light = true; // gl::disable(GL_LIGHTING) is set diff --git a/src/render/draw.h b/src/render/draw.h index bb42067..14a9767 100644 --- a/src/render/draw.h +++ b/src/render/draw.h @@ -26,6 +26,11 @@ void reset(); /// draw a sphere void draw_sphere(math::Color const & color, float radius); +/// draw a model +void draw_model_fragments(model::Model *model, + const math::Color & color_primary, const math::Color & color_secondary, + const bool detail = true, const bool power = true, const float thrust = 0.0f); + class Stats { public: static void clear(); |