From 9cbea9d27344e8bcfc0b6eae193fb1e4fd97c1c5 Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Sun, 12 May 2013 03:21:47 +0200 Subject: frustum view aspect now influences observer frustum drawing --- samples/OpenGL/frustum/frustum.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'samples/OpenGL/frustum/frustum.c') diff --git a/samples/OpenGL/frustum/frustum.c b/samples/OpenGL/frustum/frustum.c index f74b6a5..493d2eb 100644 --- a/samples/OpenGL/frustum/frustum.c +++ b/samples/OpenGL/frustum/frustum.c @@ -125,6 +125,9 @@ void draw_arrow( }; normalize_v(d); + double r[3] = { mv[0], mv[4], mv[8] }; + int rev = scalarproduct_v(d, r) < 0.; + double n[3] = { mv[2], mv[6], mv[10] }; { double const s = scalarproduct_v(d,n); @@ -173,9 +176,9 @@ void draw_arrow( w += glutStrokeWidth(GLUT_STROKE_ROMAN, *c); w *= annot_size / 100.; - float tx = (ax + bx - w*d[0])/2.; - float ty = (ay + by - w*d[1])/2.; - float tz = (az + bz - w*d[2])/2.; + float tx = (ax + bx)/2.; + float ty = (ay + by)/2.; + float tz = (az + bz)/2.; GLdouble r[16] = { d[0], d[1], d[2], 0, @@ -186,7 +189,9 @@ void draw_arrow( glPushMatrix(); glTranslatef(tx, ty, tz); glMultMatrixd(r); - glTranslatef(0, annot_size*0.1, 0); + if(rev) + glScalef(-1, -1, 1); + glTranslatef(-w/2., annot_size*0.1, 0); draw_strokestring(GLUT_STROKE_ROMAN, annot_size, annotation); glPopMatrix(); } -- cgit v1.2.3