Index: trunk/lib/FlairCore/CMakeLists.txt
===================================================================
--- trunk/lib/FlairCore/CMakeLists.txt	(revision 118)
+++ trunk/lib/FlairCore/CMakeLists.txt	(revision 120)
@@ -19,5 +19,5 @@
 
 FILE(GLOB FLAIRCORE_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
-message(${CMAKE_C_COMPILER})
+
 INCLUDE_DIRECTORIES(
 	${LIBXML2_INCLUDE_DIR}
Index: trunk/lib/FlairSimulator/src/FixedCamera.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/FixedCamera.cpp	(revision 118)
+++ trunk/lib/FlairSimulator/src/FixedCamera.cpp	(revision 120)
@@ -43,8 +43,5 @@
   camera->setPosition(vector3df(ToIrrlichtCoordinates(position)));
   camera->setTarget(vector3df(ToIrrlichtCoordinates(lookat)));
-  target=vector3df(ToIrrlichtCoordinates(lookat));
-  init=false;
-  rotation=camera->getRotation();
-  printf("%f %f %f\n",rotation.X,rotation.Y,rotation.Z);
+
   fov=camera->getFOV();
 }
@@ -52,24 +49,6 @@
 FixedCamera::~FixedCamera() {}
 
-float FixedCamera::sat(float value) {
-  if (value >= -1)
-    value = -1;
-  if (value <= -179)
-    value = -179;
-  return value;
-}
-
 void FixedCamera::animateNode(ISceneNode *node, u32 timeMs) {
   ICameraSceneNode *camera = static_cast<ICameraSceneNode *>(node);
-  vector3df newRotation=rotation;
-  vector3df newTarget=target;
-
-if(init==false) {
-  rotation=camera->getRotation();
-  printf("%f %f %f\n",rotation.X,rotation.Y,rotation.Z);
-  init=true;
-}
-  float nRotY = 0;//rotation.Y;
-  float nRotZ = rotation.Z;
 
   if (LMouseKey == true) {
@@ -77,28 +56,42 @@
       RotateStart = MousePos;
       Rotating = true;
-      //nRotY = rotation.Y;
-      //nRotZ =0;// rotation.Z;
+      target = (camera->getTarget() - camera->getAbsolutePosition());
     } else {
-      nRotY = (RotateStart.Y - MousePos.Y) * rotateSpeed;
-      nRotZ = (RotateStart.X - MousePos.X) * rotateSpeed;
-      newRotation.rotateXZBy(-nRotY);
-      //nRotY = sat(nRotY);
+      float nRotY = (RotateStart.Y - MousePos.Y) * rotateSpeed;
+      float nRotZ = -(RotateStart.X - MousePos.X) * rotateSpeed;
 
-      //newTarget.rotateXZBy(-nRotY,camera->getPosition());
-      newTarget.rotateXYBy( nRotZ,camera->getPosition());
-      camera->setTarget(newTarget);
+      //normal between target and up vector
+      cameraAxeY=target.crossProduct(irr::core::vector3df(0,0,1));
+      cameraAxeY.normalize();
+
+      //rotation around z axis
+      irr::core::quaternion q1(target.X,target.Y,target.Z,0);
+      irr::core::quaternion q2;
+      q2.fromAngleAxis(nRotZ,vector3df(0,0,1));
+      irr::core::quaternion q3=q2*q1;
+      q2.makeInverse();
+      q3=q3*q2;
+
+      //rotation around cameraAxeY
+      q1.set(q3.X,q3.Y,q3.Z,0);
+      q2.fromAngleAxis(nRotY,cameraAxeY);
+      q3=q2*q1;
+      q2.makeInverse();
+      q3=q3*q2;
+
+      //check angle
+      irr::core::vector3df newTarget(q3.X,q3.Y,q3.Z);
+      float angle=acos(newTarget.dotProduct(irr::core::vector3df(0,0,1))/newTarget.getLength());
+      irr::core::vector3df cross = newTarget.crossProduct(irr::core::vector3df(0,0,1));
+      if (cross.dotProduct(cameraAxeY) > 0) {
+        newTarget += camera->getAbsolutePosition();
+        camera->setTarget(newTarget);
+      }
     }
   } else if (Rotating) {
-    //rotation.Y += (RotateStart.Y - MousePos.Y) * rotateSpeed;
-    //rotation.Z += (RotateStart.X - MousePos.X) * rotateSpeed;
-    //rotation.Y = sat(rotation.Y);
-    //nRotY = rotation.Y;
-    //nRotZ = rotation.Z;
     Rotating = false;
-    target=camera->getTarget();
-    rotation=camera->getRotation();
-  printf("%f %f %f\n",rotation.X,rotation.Y,rotation.Z);
   }
 
+  //handle zoom
   float newFov=fov+currentZoom*zoomSpeed;
   if(newFov>fov) {
@@ -110,16 +103,4 @@
     currentZoom=1-fov/zoomSpeed;
   }
-
-//newTarget.rotateXZBy(-nRotY,camera->getPosition());
-//  newTarget.rotateXYBy( nRotZ,camera->getPosition());
-
-  //camera->setRotation(vector3df(rotation.X,-180-nRotY,nRotZ));
-  //camera->setRotation(vector3df(rotation.X,nRotY,0));
-  //camera->bindTargetAndRotation(true);
- // camera->setRotation(rotation);
- // camera->setTarget(newTarget);
-  //rotation=camera->getRotation();
-  //printf("%f %f %f\n",rotation.X,rotation.Y,rotation.Z);
-
   camera->setFOV(newFov);
 }
Index: trunk/lib/FlairSimulator/src/FixedCamera.h
===================================================================
--- trunk/lib/FlairSimulator/src/FixedCamera.h	(revision 118)
+++ trunk/lib/FlairSimulator/src/FixedCamera.h	(revision 120)
@@ -26,5 +26,5 @@
 class FixedCamera : public VisualizationCamera {
 public:
-  FixedCamera(std::string name,core::Vector3D position,core::Vector3D lookat=core::Vector3D(0,0,0),float rotateSpeed = -500.0f, float zoomSpeed = .05f);
+  FixedCamera(std::string name,core::Vector3D position,core::Vector3D lookat=core::Vector3D(0,0,0),float rotateSpeed = -3.0f, float zoomSpeed = .05f);
   ~FixedCamera();
 
@@ -32,12 +32,10 @@
 
 private:
-  float sat(float value);
   irr::core::position2df RotateStart;
-  irr::core::vector3df rotation,target;
   bool Rotating;
   float rotateSpeed;
   float zoomSpeed;
   float fov;
-  bool init;
+  irr::core::vector3df target,cameraAxeY;
 };
 
