Hm, but where would I perform the cast exactly? I want it to happen onclick so that's why I do it in my eventreceiver. Also, I don't change the camera at all since each smgr has its on camera (and the camera of smgr2 is fixed).
Anyhow, I simply tried to cast using the 2nd cam/smgr and the cursor position. This basically works but the collision is wrong, so there are hits when there shouldn't be and vice versa.
Code: Select all
recti smallviewport = recti(0,0,512,512);
[...]
// on click
if ( smallviewport.isPointInside(device->getCursorControl()->getPosition()) )
{
line3df ray2 = smgr2->getSceneCollisionManager()->getRayFromScreenCoordinates(device->getCursorControl()->getPosition(), smgr2->getActiveCamera());
vector3df collPoint2;
triangle3df collTriangle2;
SelectedNode = smgr2->getSceneCollisionManager()->getSceneNodeAndCollisionPointFromRay(ray2, collPoint2, collTriangle2, 0, 0, true);
if (SelectedNode) mySound->play(SFX_CLICK_1);
}
Obviously, you cannot use the cursor position directly since it is the position used for camera1 and the full screen only. I assume that it should be possible to calculate the relative cursor position for camera2 so that I could use that calculated position to perform the cast on camera2 just like for camera1 (if the cursor is inside the viewport rect).
However, since not only the sizes of the viewports are different but also the aspect ratios of the cameras I have no clue how to calculate that.
camera1 : 4.0f/3.0f , recti(0,0,1024,768)
camera2 : 1.0f , recti(0,0,512,512) or in general any rect
Feels like there must be a way but hell -- I don't get it. Trial & error didn't help much either.
I could really need some help here, please
Never take advice from someone who likes to give advice, so take my advice and don't take it.