Ignore:
Timestamp:
09/28/16 08:41:02 (7 years ago)
Author:
Sanahuja Guillaume
Message:

camera

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSimulator/src/FixedCamera.cpp

    r70 r87  
    3535namespace simulator {
    3636
    37 FixedCamera::FixedCamera(std::string name,core::Vector3D position,float inRotateSpeed,float inZoomSpeed):VisualizationCamera(name)  {
    38   RotY = -90;
    39   RotZ = 0;
     37FixedCamera::FixedCamera(std::string name,core::Vector3D position,core::Vector3D lookat,float inRotateSpeed,float inZoomSpeed):VisualizationCamera(name)  {
    4038  Rotating = false;
    4139  rotateSpeed=inRotateSpeed;
    4240  zoomSpeed=inZoomSpeed;
     41
     42  camera->bindTargetAndRotation(true);
    4343  camera->setPosition(vector3df(ToIrrlichtCoordinates(position)));
     44  camera->setTarget(vector3df(ToIrrlichtCoordinates(lookat)));
     45  init=false;
     46  rotation=camera->getRotation();
     47  printf("%f %f %f\n",rotation.X,rotation.Y,rotation.Z);
    4448  fov=camera->getFOV();
    4549}
     
    5761void FixedCamera::animateNode(ISceneNode *node, u32 timeMs) {
    5862  ICameraSceneNode *camera = static_cast<ICameraSceneNode *>(node);
     63  vector3df newRotation=rotation;
    5964
    60   float nRotY = RotY;
    61   float nRotZ = RotZ;
     65if(init==false) {
     66  rotation=camera->getRotation();
     67  printf("%f %f %f\n",rotation.X,rotation.Y,rotation.Z);
     68  init=true;
     69}
     70  float nRotY = 0;//rotation.Y;
     71  float nRotZ = rotation.Z;
    6272
    6373  if (LMouseKey == true) {
     
    6575      RotateStart = MousePos;
    6676      Rotating = true;
    67       nRotY = RotY;
    68       nRotZ = RotZ;
     77      //nRotY = rotation.Y;
     78      nRotZ = rotation.Z;
    6979    } else {
    70       nRotY += (RotateStart.Y - MousePos.Y) * rotateSpeed;
     80      nRotY = (RotateStart.Y - MousePos.Y) * rotateSpeed;
    7181      nRotZ += (RotateStart.X - MousePos.X) * rotateSpeed;
    72       nRotY = sat(nRotY);
     82      newRotation.rotateXZBy(-nRotY);
     83      //nRotY = sat(nRotY);
    7384    }
    7485  } else if (Rotating) {
    75     RotY += (RotateStart.Y - MousePos.Y) * rotateSpeed;
    76     RotZ += (RotateStart.X - MousePos.X) * rotateSpeed;
    77     RotY = sat(RotY);
    78     nRotY = RotY;
    79     nRotZ = RotZ;
     86    //rotation.Y += (RotateStart.Y - MousePos.Y) * rotateSpeed;
     87    //rotation.Z += (RotateStart.X - MousePos.X) * rotateSpeed;
     88    //rotation.Y = sat(rotation.Y);
     89    //nRotY = rotation.Y;
     90    nRotZ = rotation.Z;
    8091    Rotating = false;
    8192  }
     
    91102  }
    92103
    93   camera->setRotation(vector3df(0,nRotY,nRotZ));
    94   camera->bindTargetAndRotation(true);
     104
     105
     106  //camera->setRotation(vector3df(rotation.X,-180-nRotY,nRotZ));
     107  //camera->setRotation(vector3df(rotation.X,nRotY,0));
     108  //camera->bindTargetAndRotation(true);
     109  camera->setRotation(rotation);
     110  //camera->setTarget(vector3df(ToIrrlichtCoordinates(core::Vector3D(0,0,-2))));
     111  //rotation=camera->getRotation();
     112  //printf("%f %f %f\n",rotation.X,rotation.Y,rotation.Z);
     113
    95114  camera->setFOV(newFov);
    96115}
Note: See TracChangeset for help on using the changeset viewer.