Changeset 87 in flair-src


Ignore:
Timestamp:
Sep 28, 2016, 8:41:02 AM (8 years ago)
Author:
Sanahuja Guillaume
Message:

camera

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ReleaseNotes

    r33 r87  
    33- tool/FlairGCS: added rx rate display
    44- demos/SimpleFleet: new demo, 2 UAVs coordination
     5- srs/FlairSimulator: added fixed camera
    56
    67-----------------------------------------------------------
  • 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}
  • trunk/lib/FlairSimulator/src/FixedCamera.h

    r70 r87  
    2626class FixedCamera : public VisualizationCamera {
    2727public:
    28   FixedCamera(std::string name,core::Vector3D position,float rotateSpeed = -500.0f, float zoomSpeed = .1f);
     28  FixedCamera(std::string name,core::Vector3D position,core::Vector3D lookat=core::Vector3D(0,0,0),float rotateSpeed = -500.0f, float zoomSpeed = .05f);
    2929  ~FixedCamera();
    3030
     
    3434  float sat(float value);
    3535  irr::core::position2df RotateStart;
     36  irr::core::vector3df rotation;
    3637  bool Rotating;
    3738  float rotateSpeed;
    3839  float zoomSpeed;
    39   float RotY, RotZ;
    4040  float fov;
     41  bool init;
    4142};
    4243
  • trunk/lib/FlairSimulator/src/Parser.cpp

    r69 r87  
    1919#include "Simulator.h"
    2020#include "GenericObject.h"
     21#include "FixedCamera.h"
    2122#include <vector3d.h>
     23#include <Vector3D.h>
    2224#include <IrrlichtDevice.h>
    2325#include <IFileSystem.h>
     
    188190              getSceneVect(cur_node->children, (xmlChar *)"rotation"),
    189191              getSceneVect(cur_node->children, (xmlChar *)"scale", true));
     192    } else if (xmlStrEqual(cur_node->name, (xmlChar *)"camera")) {
     193      FixedCamera* fixedCamera=new FixedCamera(std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name")),
     194                                               getMeshVector3D(cur_node->children, (xmlChar *)"position"),
     195                                               getMeshVector3D(cur_node->children, (xmlChar *)"lookat"));
    190196    }
    191197  }
     
    204210  }
    205211  return vector3df(0, 0, 0);
     212}
     213
     214Vector3D Parser::getMeshVector3D(xmlNode *mesh_node, xmlChar *param) {
     215  xmlNode *cur_node = NULL;
     216  for (cur_node = mesh_node; cur_node; cur_node = cur_node->next) {
     217    if (xmlStrEqual(cur_node->name, param)) {
     218      return Vector3D(atof((char *)xmlGetProp(cur_node, (xmlChar *)"x")),
     219                       atof((char *)xmlGetProp(cur_node, (xmlChar *)"y")),
     220                       atof((char *)xmlGetProp(cur_node, (xmlChar *)"z")));
     221    }
     222  }
     223  return Vector3D(0, 0, 0);
    206224}
    207225
  • trunk/lib/FlairSimulator/src/Parser.h

    r15 r87  
    2323
    2424namespace flair {
     25  namespace core {
     26    class Vector3D;
     27  }
     28}
     29
     30namespace flair {
    2531namespace simulator {
    2632class Parser : public Gui {
     
    2834  /*can create:
    2935  - cylinders: in y axis
     36  - fixed cameras
    3037
    3138  */
     
    4552  irr::core::vector3df getSceneVect(xmlNode *mesh_node, xmlChar *param,
    4653                                    bool isScale = false);
     54  core::Vector3D getMeshVector3D(xmlNode *mesh_node, xmlChar *param);
    4755};
    4856}
  • trunk/tools/Dbt2csv/cmake_codeblocks.sh

    r12 r87  
    11DIR=build_$(uname -m)
     2
     3### IMPORTANT: We don't use standard cmake_codeblocks script since we don't compile in release mode due to optimization problem (-03) ###
    24
    35#verifie l'existence du lien symbolique build
     
    911        fi
    1012        if ! readlink build | grep -w $DIR >/dev/null; then
    11                 echo "Warnink, build was pointing to another directory."
     13                echo "Warning, build was pointing to another directory."
    1214        fi
    1315        rm build
     
    2426rm -f CMakeCache.txt
    2527rm -rf CMakeFiles
    26 cmake ../ -G "CodeBlocks - Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=${OECORE_CMAKE_HOST_TOOLCHAIN}
     28${OECORE_HOST_NATIVE_SYSROOT}/usr/bin/cmake ../ -G "CodeBlocks - Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=${OECORE_CMAKE_HOST_TOOLCHAIN}
Note: See TracChangeset for help on using the changeset viewer.