Changeset 167 in flair-src for trunk/lib/FlairSimulator/src


Ignore:
Timestamp:
04/12/17 13:59:38 (5 years ago)
Author:
Sanahuja Guillaume
Message:

modifs pour template vectors

Location:
trunk/lib/FlairSimulator/src
Files:
16 edited

Legend:

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

    r120 r167  
    3535namespace simulator {
    3636
    37 FixedCamera::FixedCamera(std::string name,core::Vector3D position,core::Vector3D lookat,float inRotateSpeed,float inZoomSpeed):VisualizationCamera(name)  {
     37FixedCamera::FixedCamera(std::string name,core::Vector3Df position,core::Vector3Df lookat,float inRotateSpeed,float inZoomSpeed):VisualizationCamera(name)  {
    3838  Rotating = false;
    3939  rotateSpeed=inRotateSpeed;
     
    6262
    6363      //normal between target and up vector
    64       cameraAxeY=target.crossProduct(irr::core::vector3df(0,0,1));
     64      cameraAxeY=target.crossProduct(vector3df(0,0,1));
    6565      cameraAxeY.normalize();
    6666
     
    8181
    8282      //check angle
    83       irr::core::vector3df newTarget(q3.X,q3.Y,q3.Z);
    84       float angle=acos(newTarget.dotProduct(irr::core::vector3df(0,0,1))/newTarget.getLength());
    85       irr::core::vector3df cross = newTarget.crossProduct(irr::core::vector3df(0,0,1));
     83      vector3df newTarget(q3.X,q3.Y,q3.Z);
     84      float angle=acos(newTarget.dotProduct(vector3df(0,0,1))/newTarget.getLength());
     85      vector3df cross = newTarget.crossProduct(vector3df(0,0,1));
    8686      if (cross.dotProduct(cameraAxeY) > 0) {
    8787        newTarget += camera->getAbsolutePosition();
  • trunk/lib/FlairSimulator/src/FixedCamera.h

    r120 r167  
    2626class FixedCamera : public VisualizationCamera {
    2727public:
    28   FixedCamera(std::string name,core::Vector3D position,core::Vector3D lookat=core::Vector3D(0,0,0),float rotateSpeed = -3.0f, float zoomSpeed = .05f);
     28  FixedCamera(std::string name,core::Vector3Df position,core::Vector3Df lookat=core::Vector3Df(0,0,0),float rotateSpeed = -3.0f, float zoomSpeed = .05f);
    2929  ~FixedCamera();
    3030
  • trunk/lib/FlairSimulator/src/Gui.cpp

    r158 r167  
    109109}
    110110
    111 vector3df ToIrrlichtCoordinates(Vector3D vect) {
     111template<typename T> vector3df ToIrrlichtCoordinates(Vector3D<T> vect) {
    112112  return ToIrrlichtScale(1) * vector3df(vect.x, vect.y, -vect.z);
    113113}
    114114
    115 Vector3D ToSimulatorCoordinates(vector3df vect) {
    116   return ToSimulatorScale(1) * Vector3D(vect.X, vect.Y, -vect.Z);
     115Vector3Df ToSimulatorCoordinates(vector3df vect) {
     116  return ToSimulatorScale(1) * Vector3Df(vect.X, vect.Y, -vect.Z);
    117117}
    118118
     
    132132  return Quaternion(quat.q0, -quat.q1, -quat.q2, quat.q3);
    133133}
     134
     135
     136template irr::core::vector3df ToIrrlichtCoordinates(core::Vector3D<double>);
     137template irr::core::vector3df ToIrrlichtCoordinates(core::Vector3D<float>);
    134138
    135139Gui::Gui(std::string name, int app_width,
  • trunk/lib/FlairSimulator/src/Gui.h

    r158 r167  
    1919
    2020#include <Object.h>
     21#include <Vector3D.h>
    2122#include <EDriverTypes.h>
    2223#include <vector3d.h>
     
    3637namespace core {
    3738class Object;
    38 class Vector3D;
    3939class Euler;
    4040class Quaternion;
     
    125125* \return vector in irrlicht coordinates
    126126*/
    127 irr::core::vector3df ToIrrlichtCoordinates(core::Vector3D vect);
     127template<typename T>  irr::core::vector3df ToIrrlichtCoordinates(core::Vector3D<T> vect);
    128128
    129129/*!
     
    136136* \return vector in simulator coordinates
    137137*/
    138 core::Vector3D ToSimulatorCoordinates(irr::core::vector3df vect);
     138core::Vector3Df ToSimulatorCoordinates(irr::core::vector3df vect);
    139139
    140140/*!
  • trunk/lib/FlairSimulator/src/Man.cpp

    r158 r167  
    7373  state[0].Quat.Normalize();
    7474
    75   Vector3D dir = state[0].Vel;
     75  Vector3D<double> dir = state[0].Vel;
    7676  dir.Rotate(state[0].Quat);
    7777  state[0].Pos = state[-1].Pos + dT() * dir;
  • trunk/lib/FlairSimulator/src/Model.cpp

    r158 r167  
    6969TabWidget *Model::GetTabWidget(void) const { return pimpl_->tabwidget; }
    7070
    71 float Model::dT(void) const { return pimpl_->dT->Value(); }
     71double Model::dT(void) const { return pimpl_->dT->Value(); }
    7272
    7373int Model::GetId(void) const {
  • trunk/lib/FlairSimulator/src/Model.h

    r158 r167  
    6969  typedef struct simu_state {
    7070    core::Quaternion Quat;
    71     core::Vector3D W;
    72     core::Vector3D Pos;
    73     core::Vector3D Vel;
     71    core::Vector3Df W;
     72    core::Vector3D<double> Pos;
     73    core::Vector3D<double> Vel;
    7474  } simu_state_t;
    7575
     
    9696protected:
    9797  DiscreteTimeVariable<simu_state_t, 3> state;
    98   float dT(void) const;
     98  double dT(void) const;
    9999  virtual void CalcModel(void) = 0;
    100100#ifdef GL
  • trunk/lib/FlairSimulator/src/Model_impl.cpp

    r163 r167  
    160160  states_mutex->GetMutex();
    161161  Quaternion quat = getSimulator()->ToVRPNReference(self->state[0].Quat);
    162   Vector3D position = getSimulator()->ToVRPNReference(self->state[0].Pos);
     162  Vector3D<double> position = getSimulator()->ToVRPNReference(self->state[0].Pos);
    163163  states_mutex->ReleaseMutex();
    164164
  • trunk/lib/FlairSimulator/src/Parser.cpp

    r158 r167  
    210210}
    211211
    212 Vector3D Parser::getMeshVector3D(xmlNode *mesh_node, xmlChar *param) {
     212Vector3Df Parser::getMeshVector3D(xmlNode *mesh_node, xmlChar *param) {
    213213  xmlNode *cur_node = NULL;
    214214  for (cur_node = mesh_node; cur_node; cur_node = cur_node->next) {
    215215    if (xmlStrEqual(cur_node->name, param)) {
    216       return Vector3D(atof((char *)xmlGetProp(cur_node, (xmlChar *)"x")),
     216      return Vector3Df(atof((char *)xmlGetProp(cur_node, (xmlChar *)"x")),
    217217                       atof((char *)xmlGetProp(cur_node, (xmlChar *)"y")),
    218218                       atof((char *)xmlGetProp(cur_node, (xmlChar *)"z")));
    219219    }
    220220  }
    221   return Vector3D(0, 0, 0);
     221  return Vector3Df(0, 0, 0);
    222222}
    223223
  • trunk/lib/FlairSimulator/src/Parser.h

    r158 r167  
    1919
    2020#include <Gui.h>
     21#include <Vector3D.h>
    2122#include <libxml/parser.h>
    2223#include <libxml/tree.h>
    2324#include <SColor.h>
    24 
    25 namespace flair {
    26   namespace core {
    27     class Vector3D;
    28   }
    29 }
    3025
    3126namespace flair {
     
    5348  irr::core::vector3df getSceneVect(xmlNode *mesh_node, xmlChar *param,
    5449                                    bool isScale = false);
    55   core::Vector3D getMeshVector3D(xmlNode *mesh_node, xmlChar *param);
     50  core::Vector3Df getMeshVector3D(xmlNode *mesh_node, xmlChar *param);
    5651};
    5752}
  • trunk/lib/FlairSimulator/src/SimuUsGL.cpp

    r158 r167  
    4343  position = new Vector3DSpinBox(setup_tab->NewRow(), "position", -2, 2, .01);
    4444  direction = new Vector3DSpinBox(setup_tab->NewRow(), "direction", -2, 2, .01);
    45   range = new DoubleSpinBox(setup_tab->NewRow(), "range:", 0, 6, 1);
     45  range = new DoubleSpinBox(setup_tab->NewRow(), "range:", 0, 1000, 1,0,6.);
    4646}
    4747
  • trunk/lib/FlairSimulator/src/Simulator.cpp

    r15 r167  
    5656}
    5757
    58 Vector3D Simulator::ToVRPNReference(Vector3D point_in) {
     58Vector3D<double> Simulator::ToVRPNReference(Vector3D<double> point_in) {
    5959  Quaternion yaw_rot_quat;
    6060  Euler yaw_rot_euler(
  • trunk/lib/FlairSimulator/src/Simulator.h

    r158 r167  
    1919
    2020#include <FrameworkManager.h>
     21#include <Vector3D.h>
    2122#include <stdint.h>
    2223
     
    2728namespace core {
    2829class Quaternion;
    29 class Vector3D;
    3030}
    3131}
     
    5353  // coordinate, around z axis
    5454  core::Quaternion ToVRPNReference(core::Quaternion quat_in);
    55   core::Vector3D ToVRPNReference(core::Vector3D point_in);
     55  core::Vector3D<double> ToVRPNReference(core::Vector3D<double> point_in);
    5656
    5757private:
  • trunk/lib/FlairSimulator/src/X4.cpp

    r158 r167  
    282282  u_thrust = k_mot->Value() * (fl_speed * fl_speed + fr_speed * fr_speed +
    283283                               rl_speed * rl_speed + rr_speed * rr_speed);
    284   Vector3D vect(0, 0, -u_thrust);
     284  Vector3D<double> vect(0, 0, -u_thrust);
    285285  vect.Rotate(state[0].Quat);
    286286
     
    291291      ** ===================================================================
    292292      */
     293     
    293294  state[0].Pos.x =
    294295      (dT() * dT() / m->Value()) *
    295           (vect.x -
    296            f_air_lat->Value() * (state[-1].Pos.x - state[-2].Pos.x) / dT()) +
     296          (vect.x - f_air_lat->Value() * (state[-1].Pos.x - state[-2].Pos.x) / dT()) +
    297297      2 * state[-1].Pos.x - state[-2].Pos.x;
    298298  state[0].Vel.x = (state[0].Pos.x - state[-1].Pos.x) / dT();
    299 
     299 
    300300  /*
    301301  ** ===================================================================
  • trunk/lib/FlairSimulator/src/X8.cpp

    r158 r167  
    339339       sigma->Value() * trr_speed * trr_speed + bfl_speed * bfl_speed +
    340340       bfr_speed * bfr_speed + brl_speed * brl_speed + brr_speed * brr_speed);
    341   Vector3D vect(0, 0, -u_thrust);
     341  Vector3D<double> vect(0, 0, -u_thrust);
    342342  vect.Rotate(state[0].Quat);
    343343
  • trunk/lib/FlairSimulator/src/unexported/Model_impl.h

    r158 r167  
    120120  flair::core::Mutex *collision_mutex;
    121121  bool collision_occured;
    122   flair::core::Vector3D collision_point;
     122  flair::core::Vector3D<double> collision_point;
    123123#endif
    124124};
Note: See TracChangeset for help on using the changeset viewer.