|
(Ha! Chris and I first had this conversation over a decade ago on the
old comp.graphics.api.opengl list... :-) Hi -- I missed the first part of this thread, sorry. I assume you're trying to transform some model so it's always oriented to face a specified point? This is essentially what the OSG AutoTransform node does, so you might want to take a look at it to see if it does what you want. I always just cook my own. Assuming you know where your model is located, subtract that position from the specified point to get a direction vector d. Then I assume you have an up vector u. Take their cross product to generate a vector c. (Cross product is not commutative, so you might need to swap the order of d and u until you get the right result, 'right handed' or 'left handed' depending on what you're after.) Tricky part: u was probably not at a 90 degree angle to d, so create a new up vector by taking the cross product of d and c (again being mindful of the order of the vectors). Call this u2. Normalize c, u2, and d so you have c', u', and d'. These should all be unit length and at 90 degree angles to each other (in other words, orthonormalized). Then the orientation matrix is: c'[0] c'[1] c'[2] 0 u'[0] u'[1] u'[2] 0 d'[0] d'[1] d'[2] 0 0 0 0 1 I'm leaving the bottom row 0 0 0 1 because I assume you only need to orient, not translate. For testing, the OSG example data set contains a model called axes.osg. Hope that helps. Paul Martz |
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

