Changeset 370 in flair-src for trunk/lib/FlairSimulator/src/X4.cpp


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

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

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.