Changeset 370 in flair-src for trunk/lib/FlairSimulator/src/X8.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/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
Note: See TracChangeset for help on using the changeset viewer.