Index: /code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.cc
===================================================================
--- /code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.cc	(revision 12216)
+++ /code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.cc	(revision 12217)
@@ -1,25 +1,61 @@
 #include "mouseapi.h"
 
-MouseAPI::MouseAPI()
+MouseAPI::MouseAPI(Camera& camera)
 {
+    cam = camera.getOgreCamera();
+    state = InputManager::getInstance().createInputState("MouseAPI");
+    state->setMouseExclusive(false);
+    state->setMouseHandler(this);
+    InputManager::getInstance().enterState("MouseAPI");
 
 }
 
-MouseAPI::~MouseAPI(){}
+MouseAPI::~MouseAPI(){
+    //todo look at gslevel destructor and implement this one
+}
 
-virtual void MouseAPI::buttonPressed (MouseButtonCode::ByEnum button){}
-virtual void MouseAPI::mouseMoved    (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize){}
-virtual void MouseAPI::mouseScrolled (int abs, int rel){}
+virtual void MouseAPI::buttonPressed (MouseButtonCode::ByEnum button)
+{
+    Ogre::Viewport vp = GraphicsManager::getInstance().getViewport();
+    Ogre::Ray ray = getCameraToViewPortRay(mousePos.x/((float)vp.getActualWidth()),mousePos.y/((float)vp.getActualHeight()));
+    for(auto event: clickEvents)
+    {
+        for(auto wantedButton:buttons){
+            if(wantedButton == button && ray.intersects(Ogre::Sphere(event.position,radius)))
+                (&(event.onClickedFunction))(button);
+        }
+    }
+}
 
-void addClickableObject(const Vector3& position,float radius,const list<ClickEvent>& events,void (*onClickedFunction)())
+virtual void MouseAPI::mouseMoved    (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
 {
-    clickEvents.insert({position,radius,events,onClickedFunction});
+    mousePos = abs;
 }
-void addScrollElement(const Vector3& position,float radius,void (*onScrolledFunction)(int abs,int rel,const IntVector2&  mousePos))
+
+virtual void MouseAPI::mouseScrolled (int abs, int rel)
+{
+    Ogre::Viewport vp = GraphicsManager::getInstance().getViewport();
+    Ogre::Ray ray = getCameraToViewPortRay(mousePos.x/((float)vp.getActualWidth()),mousePos.y/((float)vp.getActualHeight()));
+    for(auto event:scrollEvents){
+        if(!event.considerPosition || ray.intersects(Ogre::Sphere(event.position,radius)))
+            (*(event.onScrolledFunction))(abs,rel,mousePos);
+    }
+}
+
+void MouseAPI::addClickableObject(const Vector3& position,float radius,const list<MouseButtonCode::ByEnum>& buttons,void (*onClickedFunction)(MouseButtonCode::ByEnum button))
+{
+    clickEvents.insert({position,radius,buttons,onClickedFunction});
+}
+void MouseAPI::addScrollElement(const Vector3& position,float radius,void (*onScrolledFunction)(int abs,int rel,const IntVector2&  mousePos))
 {
     scrollEvents.insert(position,radius,onScrolledFunction);
 }
-void addScrollElement(void (*onScrolledFunction)(int abs,int rel,const IntVector2&  mousePos))
+void MouseAPI::addScrollElement(void (*onScrolledFunction)(int abs,int rel,const IntVector2&  mousePos))
 {
     scrollEvents.insert(onScrolledFunction);
 }
+
+void MouseAPI::changeCamera(Camera& camera)
+{
+    cam = camera.getOgreCamera();
+}
Index: /code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.h
===================================================================
--- /code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.h	(revision 12216)
+++ /code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.h	(revision 12217)
@@ -5,4 +5,7 @@
 #include <list>
 #include <core/input/InputHandler.h>
+#include <graphics/Camera.h>
+#include <core/GraphicsManager.h>
+#include <core/input/InputState.h>
 
 namespace orxonox
@@ -18,8 +21,8 @@
         Vector3 position;
         float radius;
-        list<ClickEvent> events;
-        void (*onClickedFunction)();
-        clickableElement(const Vector3& position,float radius,const list<ClickEvent>& events,void (*onClickedFunction)()):position(position),
-            radius(radius), events(events), onClickedFunction(onClickedFunction){}
+        list<MouseButtonCode::ByEnum> buttons;
+        void (*onClickedFunction)(MouseButtonCode::ByEnum button);
+        clickableElement(const Vector3& position,float radius,const list<MouseButtonCode::ByEnum>& buttons,void (*onClickedFunction)()):position(position),
+            radius(radius), buttons(buttons), onClickedFunction(onClickedFunction){}
     };
 
@@ -39,23 +42,24 @@
     std::list<clickableElement> clickEvents;
     std::list<scrollElement> scrollEvents;
+    Ogre::Camera cam;
+    IntVector2 mousePos;
+    InputState* state;
 
 
 public:
-    enum ClickEvent
-    {
-        rightClick,leftClick,middleCLick
-    };
 
-    MouseAPI();
+    MouseAPI(Camera& cam);
     ~MouseAPI();
-    virtual void buttonPressed (MouseButtonCode::ByEnum button);
-    virtual void buttonReleased(MouseButtonCode::ByEnum button){}
-    virtual void buttonHeld    (MouseButtonCode::ByEnum button){}
-    virtual void mouseMoved    (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
-    virtual void mouseScrolled (int abs, int rel);
+    virtual void buttonPressed (MouseButtonCode::ByEnum button) override;
+    virtual void buttonReleased(MouseButtonCode::ByEnum button)  override{}
+    virtual void buttonHeld    (MouseButtonCode::ByEnum button) override{}
+    virtual void mouseMoved    (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) override;
+    virtual void mouseScrolled (int abs, int rel) override;
 
-    void addClickableObject(const Vector3& position,float radius,const list<ClickEvent>& events,void (*onClickedFunction)());
+    void addClickableObject(const Vector3& position,float radius,const list<MouseButtonCode::ByEnum>& buttons,void (*onClickedFunction)(MouseButtonCode::ByEnum button));
     void addScrollElement(const Vector3& position,float radius,void (*onScrolledFunction)(int abs,int rel,const IntVector2&  mousePos));
     void addScrollElement(void (*onScrolledFunction)(int abs,int rel,const IntVector2&  mousePos));
+
+    void changeCamera(Camera& camera);
 };
 }
