Changeset 370 in flair-src


Ignore:
Timestamp:
Nov 19, 2020, 11:17:30 AM (13 months ago)
Author:
Sanahuja Guillaume
Message:

add abilitiy to change x4 and x8 arm color from ground station

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

Legend:

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

    r339 r370  
    2525#ifdef GL
    2626#include <ISceneManager.h>
     27#include <IMeshManipulator.h>
    2728#include "Blade.h"
    2829#include "MeshSceneNode.h"
     
    7677                           
    7778  motorTimeout = new SpinBox(setup_tab->NewRow(), "motor timeout:","ms", 0, 1000, 100,100);
     79 
     80  Tab *visual_tab = new Tab(GetTabWidget(), "visual");
     81  armColorR = new SpinBox(visual_tab->NewRow(), "arm color (R):", 0, 255, 1,255);
     82  armColorG = new SpinBox(visual_tab->LastRowLastCol(), "arm color (G):", 0, 255, 1,0);
     83  armColorB = new SpinBox(visual_tab->LastRowLastCol(), "arm color (B):", 0, 255, 1,0);
    7884
    7985  motors = new SimuBldc(this, name, 4, modelId,0);
     
    98104
    99105  // cylinders are aligned with y axis
    100   IMesh *red_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 255, 0, 0));
     106  colored_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, armColorR->Value(), armColorG->Value(), armColorB->Value()));
    101107  IMesh *black_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 128, 128, 128));
    102108  IMesh *motor = geo->createCylinderMesh(7.5, 15, 16); //,SColor(0, 128, 128, 128));
     
    104110
    105111  ITexture *texture = getGui()->getTexture("carbone.jpg");
    106   MeshSceneNode *fl_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
     112  MeshSceneNode *fl_arm = new MeshSceneNode(this, colored_arm, vector3df(0, 0, 0),
    107113                             vector3df(0, 0, -135));
    108   MeshSceneNode *fr_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
     114  MeshSceneNode *fr_arm = new MeshSceneNode(this, colored_arm, vector3df(0, 0, 0),
    109115                             vector3df(0, 0, -45));
    110116  MeshSceneNode *rl_arm = new MeshSceneNode(this, black_arm, vector3df(0, 0, 0),
     
    141147  rr_blade->SetRotationSpeed(K_MOT *vector3df(0, 0, motor_speed[3]));
    142148  motor_speed_mutex->ReleaseMutex();
     149 
     150  if (armColorR->ValueChanged() == true || armColorG->ValueChanged() == true || armColorB->ValueChanged() == true) {
     151    getGui()->getSceneManager()->getMeshManipulator()->setVertexColors(colored_arm, SColor(0,armColorR->Value(), armColorG->Value(), armColorB->Value()));
     152  }
    143153
    144154  // adapt UAV size
  • trunk/lib/FlairSimulator/src/X4.h

    r286 r370  
    3333}
    3434
     35#ifdef GL
     36namespace irr {
     37namespace scene {
     38class IMesh;
     39}
     40}
     41#endif
     42
    3543namespace flair {
    3644namespace simulator {
     
    5563  Blade *fl_blade, *fr_blade, *rl_blade, *rr_blade;
    5664  core::Mutex *motor_speed_mutex;
     65  irr::scene::IMesh *colored_arm;
    5766#endif
    5867
     
    6473  gui::DoubleSpinBox *j_roll, *j_pitch, *j_yaw;
    6574  gui::SpinBox *motorTimeout;
     75  gui::SpinBox *armColorR,*armColorG,*armColorB;
    6676};
    6777} // end namespace simulator
  • trunk/lib/FlairSimulator/src/X8.cpp

    r339 r370  
    2525#ifdef GL
    2626#include <ISceneManager.h>
     27#include <IMeshManipulator.h>
    2728#include "Blade.h"
    2829#include "MeshSceneNode.h"
     
    8586  motorTimeout = new SpinBox(setup_tab->NewRow(), "motor timeout:","ms", 0, 1000, 100,100);
    8687
     88  Tab *visual_tab = new Tab(GetTabWidget(), "visual");
     89  armColorR = new SpinBox(visual_tab->NewRow(), "arm color (R):", 0, 255, 1,255);
     90  armColorG = new SpinBox(visual_tab->LastRowLastCol(), "arm color (G):", 0, 255, 1,0);
     91  armColorB = new SpinBox(visual_tab->LastRowLastCol(), "arm color (B):", 0, 255, 1,0);
     92 
    8793  motors = new SimuBldc(this, name, 8, modelId,0);
    8894 
     
    102108
    103109  // cylinders are aligned with y axis
    104   IMesh *red_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 255, 0, 0));
     110  colored_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, armColorR->Value(), armColorG->Value(), armColorB->Value()));
    105111  IMesh *black_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 128, 128, 128));
    106112  IMesh *motor = geo->createCylinderMesh(7.5, 15, 16); //,SColor(0, 128, 128, 128));
     
    108114
    109115  ITexture *texture = getGui()->getTexture("carbone.jpg");
    110   MeshSceneNode *fl_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
     116  MeshSceneNode *fl_arm = new MeshSceneNode(this, colored_arm, vector3df(0, 0, 0),
    111117                             vector3df(0, 0, -135));
    112   MeshSceneNode *fr_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
     118  MeshSceneNode *fr_arm = new MeshSceneNode(this, colored_arm, vector3df(0, 0, 0),
    113119                             vector3df(0, 0, -45));
    114120  MeshSceneNode *rl_arm = new MeshSceneNode(this, black_arm, vector3df(0, 0, 0),
     
    171177  brr_blade->SetRotationSpeed(-K_MOT * vector3df(0, 0,motor_speed[7]));
    172178  motor_speed_mutex->ReleaseMutex();
     179
     180  if (armColorR->ValueChanged() == true || armColorG->ValueChanged() == true || armColorB->ValueChanged() == true) {
     181    getGui()->getSceneManager()->getMeshManipulator()->setVertexColors(colored_arm, SColor(0,armColorR->Value(), armColorG->Value(), armColorB->Value()));
     182  }
     183
    173184
    174185  // adapt UAV size
  • trunk/lib/FlairSimulator/src/X8.h

    r286 r370  
    3333}
    3434
     35#ifdef GL
     36namespace irr {
     37namespace scene {
     38class IMesh;
     39}
     40}
     41#endif
     42
    3543namespace flair {
    3644namespace simulator {
     
    5664  Blade *tfl_blade, *tfr_blade, *trl_blade, *trr_blade;
    5765  Blade *bfl_blade, *bfr_blade, *brl_blade, *brr_blade;
     66  irr::scene::IMesh *colored_arm;
    5867#endif
    5968
     
    6675  gui::DoubleSpinBox *j_r, *sigma, *S;
    6776  gui::SpinBox *motorTimeout;
     77  gui::SpinBox *armColorR,*armColorG,*armColorB;
    6878};
    6979} // end namespace simulator
Note: See TracChangeset for help on using the changeset viewer.