Operating System: :Ubuntu 16.0:
Render System: :GL3:
Hello! I get very strange output from Ogre::Camera::getCameraToViewportRay(). In particular, I log 1) screen position in pixels, 2) screen relative position and 3) ray direction as an output from getCameraToViewportRay().
The problem is when mouse is smoothly moved ray.getDirection() either remains exactly the same or jumps a lot. Please, see the code and log attached.
Code: Select all
Ogre::Viewport * v = mCamera->getViewport();
int left, top, width, height;
v->getActualDimensions( left, top, width, height );
const Ogre::Real x = static_cast<Ogre::Real>( mouseAtX - left ) /
static_cast<Ogre::Real>( width );
const Ogre::Real y = static_cast<Ogre::Real>( mouseAtY - top ) /
static_cast<Ogre::Real>( height );
std::cout << "at: " << mouseAtX << " "
<< mouseAtY << " ";
std::cout << "xy: " << x << " "
<< y << " ";
ray = mCamera->getCameraToViewportRay( x, y );
Ogre::Vector3 a = ray.getDirection();
std::cout << "a_abs: " << a.x << " "
<< a.y << " "
<< a.z << std::endl;
at: 586 333 xy: 0.572266 0.433594 a_abs: -0.327264 0.930657 -0.163632
at: 585 334 xy: 0.571289 0.434896 a_abs: -0.327264 0.930657 -0.163632
at: 584 334 xy: 0.570312 0.434896 a_abs: -0.327264 0.930657 -0.163632
at: 583 334 xy: 0.569336 0.434896 a_abs: 0 0.984892 -0.173168
at: 582 334 xy: 0.568359 0.434896 a_abs: 0 0.984892 -0.173168