From dade31c1d21c72cc369ce744a9edd5fe52f68473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Pe=C3=B1aranda?= Date: Wed, 4 Sep 2013 18:00:02 -0300 Subject: [PATCH] added orthographic projection --- openglcanvas.cpp | 18 ++++++++++++++++++ panowindow1.ui | 5 +++++ shaders/vertex_shader.vert | 5 +++++ 3 files changed, 28 insertions(+) diff --git a/openglcanvas.cpp b/openglcanvas.cpp index 16097fa..4c9a865 100644 --- a/openglcanvas.cpp +++ b/openglcanvas.cpp @@ -522,6 +522,15 @@ void OpenGLCanvas::vertex_transformation(float *positions, int m, int n, float c positions[3*(j+i*n)+1] = v/extent; positions[3*(j+i*n)+2] = z; } + + if (visualization=="Orthographic"){ + u = x; + v = y; + positions[3*(j+i*n)] = u/extent; + positions[3*(j+i*n)+1] = v/extent; + positions[3*(j+i*n)+2] = z; + } + } } @@ -598,6 +607,14 @@ float OpenGLCanvas::calculate_extent(float fov_rads){ u = x/(-z); v = y/(-z); } + if (visualization=="Orthographic"){ + if(z<0.){ + u=x; + v=y; + }else{ + u=v=1.f; + } + } return u; } @@ -789,6 +806,7 @@ void OpenGLCanvas::paintGL(){ else if (visualization=="Stereographic") vis_mode=4.0; else if (visualization=="Mercator") vis_mode=5.0; else if (visualization=="Zorin-Barr") vis_mode=6.0; + else if (visualization=="Orthographic") vis_mode=7.0; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 2.0/extent, 0.0, 2.0/scale, 0.0, -2.0/vis_mode); diff --git a/panowindow1.ui b/panowindow1.ui index aec84ac..e2164df 100644 --- a/panowindow1.ui +++ b/panowindow1.ui @@ -207,6 +207,11 @@ Zorin-Barr + + + Orthographic + + diff --git a/shaders/vertex_shader.vert b/shaders/vertex_shader.vert index 964f1c3..daa99b8 100644 --- a/shaders/vertex_shader.vert +++ b/shaders/vertex_shader.vert @@ -92,6 +92,11 @@ void main(void){ v=zbrho*sin(zbalpha); gl_Position = vec4(u/extent,v/extent,z,1.0); } + else if (vis_mode==7.0){ // Orthographic + u=x; + v=y; + gl_Position = vec4(u/extent,v/extent,z,1.0); + } // gl_Position = vec4(u/2.0,v/2.0,z,1.0); -- GitLab