MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / computeOverlayPositionHead

Method computeOverlayPositionHead

source/render/MovableTextOverlay.cpp:262–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260}
261
262bool MovableTextOverlay::computeOverlayPositionHead(Ogre::Vector2& position)
263{
264 // the AABB of the target
265 const Ogre::AxisAlignedBox& AABB = mFollowedMov->getWorldBoundingBox();
266 if (!mCamera->isVisible(AABB))
267 return false;
268
269 const Ogre::Vector3 farLeftTop = AABB.getCorner(Ogre::AxisAlignedBox::NEAR_RIGHT_TOP);
270 const Ogre::Vector3 nearRightTop = AABB.getCorner(Ogre::AxisAlignedBox::NEAR_LEFT_BOTTOM);
271
272 const Ogre::Vector3 centerTop = (farLeftTop + nearRightTop) * 0.5;
273
274 // Is the camera facing that point?
275 Ogre::Plane cameraPlane(Ogre::Vector3(mCamera->getDerivedOrientation().zAxis()), mCamera->getDerivedPosition());
276 if(cameraPlane.getSide(centerTop) != Ogre::Plane::NEGATIVE_SIDE)
277 return false;
278
279 // Transform 3D point to screen
280 Ogre::Vector3 screenPosition = mCamera->getProjectionMatrix() * (mCamera->getViewMatrix() * centerTop);
281
282 // We transform from coordinate space [-1, 1] to [0, 1]
283 position.x = 0.5 + (screenPosition.x * 0.5);
284 position.y = 0.5 - (screenPosition.y * 0.5);
285
286 return true;
287}
288
289void MovableTextOverlay::displayOverlay(uint32_t childOverlayId, Ogre::Real time)
290{

Callers

nothing calls this directly

Calls 2

Vector3Class · 0.85
isVisibleMethod · 0.45

Tested by

no test coverage detected