I want to place the camera in some place each time when i click. I mean, I want camera to move to the correct place. For example i click in A=(500,200) (my app's window is 800x600). I want the camera to move to that place, where I clicked. I wrote something like this:
Code: Select all
if(event.MouseInput.Event==EMIE_LMOUSE_PRESSED_DOWN) {
pozycja_2d = device->getCursorControl()->getPosition();
przes_x = static_cast<int>(pozycja_2d.X) - 400;
przes_y = static_cast<int>(pozycja_2d.Y) - 300;
}
(...)
obecne_x = static_cast<int>(camera->getPosition().X);
obecne_y = static_cast<int>(camera->getPosition().Y);
camera->setPosition(vector3df((obecne_x + przes_x),500,(obecne_y + przes_y)));
camera->setTarget(vector3df((obecne_x + przes_x),0,(obecne_y + przes_y)));
przes_x = 0;
przes_y = 0;
But it doesn't work - the numbers it returns as przes_x and przes_y are somehow strange (they are never smaller then 0, and usually somewhere over 300000). Why does it happen?? I only know that it isn't coused by too big or too small values for int becouse I've counted it on the paper and all was ok (ofc they were between (-400, 400) and (-300, 300)).