From e247b118619e15fe373a4f8e604542e98299accc Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 23 Jan 2004 21:47:39 +0000 Subject: [PATCH] Added proper handling of the rotation of billboards about an artbitary axis. Note, this code while mathermatically is not optimal, and will need to reviewed in the future to optimize it. --- src/osg/Billboard.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/osg/Billboard.cpp b/src/osg/Billboard.cpp index 5b0e88213..4725698c8 100644 --- a/src/osg/Billboard.cpp +++ b/src/osg/Billboard.cpp @@ -73,7 +73,7 @@ void Billboard::updateCache() else _cachedMode = _mode; _side = _axis^_normal; - _side.normalize(); + _side.normalize(); } bool Billboard::addDrawable(Drawable *gset) @@ -140,8 +140,6 @@ bool Billboard::computeMatrix(Matrix& modelview, const Vec3& eye_local, const Ve float ev_length = ev.length(); if (ev_length>0.0f) { - - matrix.makeIdentity(); //float rotation_zrotation_z = atan2f(ev.x(),ev.y()); //mat.makeRotate(inRadians(rotation_z),0.0f,0.0f,1.0f); float inv = 1.0f/ev_length; @@ -160,8 +158,6 @@ bool Billboard::computeMatrix(Matrix& modelview, const Vec3& eye_local, const Ve float ev_length = ev.length(); if (ev_length>0.0f) { - - matrix.makeIdentity(); //float rotation_zrotation_z = atan2f(ev.x(),ev.y()); //mat.makeRotate(inRadians(rotation_z),0.0f,0.0f,1.0f); float inv = 1.0f/ev_length; @@ -181,7 +177,6 @@ bool Billboard::computeMatrix(Matrix& modelview, const Vec3& eye_local, const Ve if (ev_length>0.0f) { - matrix.makeIdentity(); //float rotation_zrotation_z = atan2f(ev.x(),ev.y()); //mat.makeRotate(inRadians(rotation_z),0.0f,0.0f,1.0f); float inv = 1.0f/ev_length; @@ -195,6 +190,13 @@ bool Billboard::computeMatrix(Matrix& modelview, const Vec3& eye_local, const Ve break; } case(AXIAL_ROT): // need to implement + { + float ev_side = ev*_side; + float ev_normal = ev*_normal; + float rotation = atan2f(ev_side,ev_normal); + matrix.makeRotate(rotation,_axis); + break; + } case(POINT_ROT_WORLD): case(POINT_ROT_EYE): {