Hi Miguel,
What I do is just leave the trackball to do its own thing, but before I pass the matrix from it to the camera group or whatever else you are using, multiply it by a matrix that represents your center point. I think you might have to multiply it by the inverse of that if I remember correctly.
-- Rick
On 11/7/06, Don Burns <[EMAIL PROTECTED]> wrote:
Hi Miguel,
Could you subscribe to Producer-users for these questions? We will try to leave the OSG folks alone with Producer problems. ( http://openscenegraph.net/mailman/listinfo/Producer-users),
The reason you are getting identical behavior is that you are setting the matrix directly on the Trackball, rather than using the internal computation within Trackball::update(). Using makeLookAt will always return the same value.
I may not be understanding exactly what you want to do, but a probable solution is the following:
trackball->translate(
-new_center[0], -new_center[1], -new_center[2]);
trackball->setDistance( (new_center - eye).length());
trackball->setTransformOrder(Producer::Trackball::RotateTranslate);
Hope this helps,
-don
On 11/7/06, Miguel Martinez < [EMAIL PROTECTED]> wrote:Hi_______________________________________________
I have a problem with the Producer::TackBall
When I use my own function LookAtSelection (code below), I get the focus
at the center point of the screen, but then the trackball doesn't work as I want,
because it doesn't rotate around the new center point.
I've been many days trying to solve it, but I can't see why it happens.
I've tried
_trackBall->setTransformOrder(Producer::Trackball::TransformOrder::RotateTranslate);
and
_trackBall->setTransformOrder(Producer::Trackball::TransformOrder::TranslateRotate);
but the behaviour I obtain is the same.
¿Any Idea?
------------------------------
void MFCKeyboardMouseCallback::LookAtSelection()
{
// Get the new Center
osg::Vec3 new_center = selection.GetSelectionCenter();
osg::Vec3 eye, cent, up;
// get current trackball matrix
Producer::Matrix m = _trackBall->getMatrix();
osg::Matrix mm;
Producer::Matrix::value_type ff[16];
for(int i=0; i< 4; i++)
for(int j=0;j<4;j++)
ff[4*i+j] = m(i,j);
mm.set(ff);
// Get trackball Lookat values
mm.getLookAt(eye, cent, up);
// Set the lookat with the new center
m.makeLookAt(Producer::Vec3(eye.x(), eye.y(), eye.z()),
Producer::Vec3(new_center.x(), new_center.y(), new_center.z()),
Producer::Vec3(up.x(), up.y(), up.z()));
_trackBall->setMatrix(m);
_trackBall->update();
}
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
