Hi,
I'm trying to write a simple third-person camera manipulator, and I seem to be
confused about something to do with how it handles the coordinate system. I am
inheriting from the osgGA::StandardManipulator.
Code:
ThirdPersonManipulator::ThirdPersonManipulator()
: osgGA::StandardManipulator(),
distance(100),
eye(0, -distance, 0),
center(0, 0, 0),
up(0, 0, 1)
{
setHomePosition(eye, center, up);
}
void ThirdPersonManipulator::setByMatrix(const osg::Matrixd& matrix_)
{
matrix = matrix_;
}
void ThirdPersonManipulator::setByInverseMatrix(const osg::Matrixd& matrix_)
{
setByMatrix(osg::Matrixd::inverse(matrix_));
}
osg::Matrixd ThirdPersonManipulator::getMatrix() const { return matrix; }
osg::Matrixd ThirdPersonManipulator::getInverseMatrix() const
{
return osg::Matrixd::inverse(matrix);
}
bool ThirdPersonManipulator::handleFrame(const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter&)
{
osg::Vec3d pos = GameManager::instance().player.pos;
matrix =
osg::Matrixd::translate(pos);
return false;
}
This kind of produces the results I wanted, but what I expect to be "forwards"
is actually "up".
Here is a screenshot showing that it affects the models and the placement of
the camera: http://imgur.com/ZUsRYvU
I'm exporting the models from blender using the built-in fbx exporter. And I
export them with a coordinate system that is "Y Forwards / Z Up". I believe
that is the same coordinate system that osg uses by default.
Thank you!
Cheers,
Michael
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65357#65357
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org