Changeset 15 in flair-src for trunk/lib/FlairSimulator/src/SimuUsGL.cpp


Ignore:
Timestamp:
04/08/16 15:40:57 (8 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

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

    r10 r15  
    3636using namespace flair::simulator;
    3737
    38 namespace flair
    39 {
    40 namespace sensor
    41 {
    42 SimuUsGL::SimuUsGL(const Model* parent,std::string name,int dev_id) :SimuUs(parent,name,dev_id),SensorGL(parent)
    43 {
    44     Tab* setup_tab=new Tab(parent->GetTabWidget(),name);
    45             position=new Vector3DSpinBox(setup_tab->NewRow(),"position",-2,2,.01);
    46             direction=new Vector3DSpinBox(setup_tab->NewRow(),"direction",-2,2,.01);
    47             range=new DoubleSpinBox(setup_tab->NewRow(),"range:",0,6,1);
     38namespace flair {
     39namespace sensor {
     40SimuUsGL::SimuUsGL(const Model *parent, std::string name, int dev_id)
     41    : SimuUs(parent, name, dev_id), SensorGL(parent) {
     42  Tab *setup_tab = new Tab(parent->GetTabWidget(), name);
     43  position = new Vector3DSpinBox(setup_tab->NewRow(), "position", -2, 2, .01);
     44  direction = new Vector3DSpinBox(setup_tab->NewRow(), "direction", -2, 2, .01);
     45  range = new DoubleSpinBox(setup_tab->NewRow(), "range:", 0, 6, 1);
    4846}
    4947
    50 SimuUsGL::~SimuUsGL()
    51 {
     48SimuUsGL::~SimuUsGL() {}
    5249
    53 }
     50void SimuUsGL::UpdateFrom(const io_data *data) {
     51  float value;
     52#ifdef GL
     53  if (noGui() == true) {
     54#endif
     55    // todo: utiliser le placement de l'us dans le drone et sa portée
     56    cvmatrix *input = (cvmatrix *)data;
     57    value = input->Value(9, 0);
     58    shmem->Write((char *)&value, sizeof(float));
     59#ifdef GL
     60  }
    5461
    55 void SimuUsGL::UpdateFrom(const io_data *data)
    56 {
    57     float value;
    58 #ifdef GL
    59     if(noGui()==true)
    60     {
    61 #endif
    62         //todo: utiliser le placement de l'us dans le drone et sa portée
    63         cvmatrix *input=(cvmatrix*)data;
    64         value=input->Value(9,0);
    65         shmem->Write((char*)&value,sizeof(float));
    66 #ifdef GL
     62  if (noGui() == false && data == NULL) {
     63    line3d<f32> ray_us;         // rayon provenant de l'ultra son
     64    vector3df intersection_us;  // point intersection us avec le sol
     65    triangle3df hitTriangle_us; // triangle intersection us avec le sol
     66
     67    // get rotation matrix of node - Zeuss must be getRotation not
     68    // getRelativeTransformation
     69    matrix4 m;
     70    m.setRotationDegrees(Node()->getRotation());
     71
     72    // transform forward vector of us
     73    vector3df frv = ToIrrlichtCoordinates(direction->Value());
     74    m.transformVect(frv);
     75    frv.normalize();
     76
     77    // transform pos vector of us
     78    vector3df pos = ToIrrlichtCoordinates(position->Value());
     79    m.transformVect(pos);
     80
     81    ray_us.start = Node()->getPosition() + pos;
     82    ray_us.end = ray_us.start + ToIrrlichtScale(range->Value()) * frv;
     83
     84    scene::ISceneNode *selectedSceneNode =
     85        CollMan()->getSceneNodeAndCollisionPointFromRay(ray_us, intersection_us,
     86                                                        hitTriangle_us);
     87
     88    if (selectedSceneNode) {
     89      float value =
     90          ToSimulatorScale(ray_us.start.getDistanceFrom(intersection_us));
     91      shmem->Write((char *)&value, sizeof(float));
    6792    }
    68 
    69     if(noGui()==false && data==NULL)
    70     {
    71         line3d<f32> ray_us;//rayon provenant de l'ultra son
    72         vector3df intersection_us;//point intersection us avec le sol
    73         triangle3df hitTriangle_us;//triangle intersection us avec le sol
    74 
    75          //get rotation matrix of node - Zeuss must be getRotation not getRelativeTransformation
    76         matrix4 m;
    77         m.setRotationDegrees(Node()->getRotation());
    78 
    79         // transform forward vector of us
    80         vector3df frv =ToIrrlichtCoordinates(direction->Value());
    81         m.transformVect(frv);
    82         frv.normalize();
    83 
    84          // transform pos vector of us
    85         vector3df pos =ToIrrlichtCoordinates(position->Value());
    86         m.transformVect(pos);
    87 
    88         ray_us.start =Node()->getPosition() +pos;
    89         ray_us.end = ray_us.start + ToIrrlichtScale(range->Value())*frv;
    90 
    91         scene::ISceneNode * selectedSceneNode =
    92             CollMan()->getSceneNodeAndCollisionPointFromRay(ray_us,intersection_us,hitTriangle_us);
    93 
    94         if(selectedSceneNode)
    95         {
    96             float value=ToSimulatorScale(ray_us.start.getDistanceFrom(intersection_us));
    97             shmem->Write((char*)&value,sizeof(float));
    98         }
    99     }
     93  }
    10094#endif
    10195}
Note: See TracChangeset for help on using the changeset viewer.