Ignore:
Timestamp:
09/06/16 17:49:32 (5 years ago)
Author:
Sanahuja Guillaume
Message:

simu cameras

File:
1 edited

Legend:

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

    r69 r70  
    2525#include <IrrlichtDevice.h>
    2626#include <ISceneManager.h>
     27#include <Euler.h>
    2728
    2829using namespace irr;
     
    3435namespace simulator {
    3536
    36 FixedCamera::FixedCamera(core::Vector3D position,float rotateSpeed,float zoomSpeed):VisualizationCamera(rotateSpeed,zoomSpeed)  {
    37   RotY = 020;
     37FixedCamera::FixedCamera(std::string name,core::Vector3D position,float inRotateSpeed,float inZoomSpeed):VisualizationCamera(name)  {
     38  RotY = -90;
    3839  RotZ = 0;
    3940  Rotating = false;
    40 
    41    // camera
    42   camera->setPosition(vector3df(position.x,position.y,position.z));
     41  rotateSpeed=inRotateSpeed;
     42  zoomSpeed=inZoomSpeed;
     43  camera->setPosition(vector3df(ToIrrlichtCoordinates(position)));
     44  fov=camera->getFOV();
    4345}
    4446
    4547FixedCamera::~FixedCamera() {}
     48
     49float FixedCamera::sat(float value) {
     50  if (value >= -1)
     51    value = -1;
     52  if (value <= -179)
     53    value = -179;
     54  return value;
     55}
    4656
    4757void FixedCamera::animateNode(ISceneNode *node, u32 timeMs) {
     
    6070      nRotY += (RotateStart.Y - MousePos.Y) * rotateSpeed;
    6171      nRotZ += (RotateStart.X - MousePos.X) * rotateSpeed;
     72      nRotY = sat(nRotY);
    6273    }
    6374  } else if (Rotating) {
    6475    RotY += (RotateStart.Y - MousePos.Y) * rotateSpeed;
    6576    RotZ += (RotateStart.X - MousePos.X) * rotateSpeed;
     77    RotY = sat(RotY);
    6678    nRotY = RotY;
    6779    nRotZ = RotZ;
     
    6981  }
    7082
     83  float newFov=fov+currentZoom*zoomSpeed;
     84  if(newFov>fov) {
     85    newFov=fov;
     86    currentZoom=0;
     87  }
     88  if(newFov<0) {
     89    newFov=zoomSpeed;
     90    currentZoom=1-fov/zoomSpeed;
     91  }
     92
    7193  camera->setRotation(vector3df(0,nRotY,nRotZ));
    7294  camera->bindTargetAndRotation(true);
     95  camera->setFOV(newFov);
    7396}
    7497
Note: See TracChangeset for help on using the changeset viewer.