Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 11, 2019, 1:16:08 PM (6 years ago)
Author:
tkuonen
Message:

MouseAPI: improve getting mouse pos

Location:
code/branches/MouseAPI_FS19/src/modules/MouseAPI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.cc

    r12279 r12287  
    5252    cam = CameraManager::getInstance().getActiveCamera()->getOgreCamera();//todo: trycatch
    5353    Ogre::Viewport *vp = GraphicsManager::getInstance().getViewport();
    54     Ogre::Ray ray = cam->getCameraToViewportRay(mousePos.x/((float)vp->getActualWidth()),mousePos.y/((float)vp->getActualHeight()));
     54    int mouseposX = InputManager::getInstance().getMousePosition().first;
     55    int mouseposY = InputManager::getInstance().getMousePosition().second;
     56    Ogre::Ray ray = cam->getCameraToViewportRay(mouseposX/((float)vp->getActualWidth()),mouseposY/((float)vp->getActualHeight()));
    5557    for(auto event: clickEvents)
    5658    {
     
    6567void MouseAPI::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
    6668{
    67     mousePos = abs;
     69    //mousePos = abs;
    6870}
    6971
     
    7274    cam = CameraManager::getInstance().getActiveCamera()->getOgreCamera();
    7375    Ogre::Viewport *vp = GraphicsManager::getInstance().getViewport();
    74     Ogre::Ray ray = cam->getCameraToViewportRay(mousePos.x/((float)vp->getActualWidth()),mousePos.y/((float)vp->getActualHeight()));
     76    int mouseposX = InputManager::getInstance().getMousePosition().first;
     77    int mouseposY = InputManager::getInstance().getMousePosition().second;
     78    Ogre::Ray ray = cam->getCameraToViewportRay(mouseposX/((float)vp->getActualWidth()),mouseposY/((float)vp->getActualHeight()));
    7579    for(auto event:scrollEvents)
    7680    {
    7781        if(!event.considerPosition || ray.intersects(Ogre::Sphere(event.position,event.radius)).first)
    78             event.onScrolledFunction(abs,rel,mousePos);
     82            event.onScrolledFunction(abs,rel,IntVector2(mouseposX,mouseposY));
    7983    }
    8084}
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.h

    r12275 r12287  
    5656    std::list<scrollElement> scrollEvents;
    5757    Ogre::Camera *cam ;
    58     IntVector2 mousePos;
     58    //IntVector2 mousePos;
    5959    InputState* state;
    6060    bool active = false;
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapiexample.cc

    r12285 r12287  
    11#include "mouseapiexample.h"
     2#include "gametypes/Gametype.h"
    23
    34namespace orxonox
     
    910{
    1011    RegisterObject(MouseAPIExample);
     12    //this->getGametype()->getPlayers().begin()->first->getControllableEntity()...
     13
    1114
    1215}
     
    1619    if(MouseAPI::isActive())
    1720        MouseAPI::getInstance().deactivate();
     21
    1822}
    1923
Note: See TracChangeset for help on using the changeset viewer.