Changeset 286 in flair-src for trunk/lib/FlairSimulator
- Timestamp:
- Jan 8, 2019, 10:13:03 AM (6 years ago)
- Location:
- trunk/lib/FlairSimulator/src
- Files:
-
- 4 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSimulator/src/Blade.cpp
r15 r286 64 64 } 65 65 66 Blade::Blade(ISceneNode *parent, const vector3df &position, bool inverted, s32 id) 67 : ISceneNode(parent, getGui()->getSceneManager(), id, 68 position) { 69 ISceneManager *mgr = getGui()->getSceneManager(); 70 71 const IGeometryCreator *geo; 72 geo = mgr->getGeometryCreator(); 73 pale = geo->createCubeMesh(vector3df(63.5, 0.5, 5)); 74 75 float angle; 76 if (inverted == false) { 77 angle = 20; 78 } else { 79 angle = -20; 80 } 81 82 ITexture *texture = getGui()->getTexture("carbone.jpg"); 83 pale_1 = new MeshSceneNode(parent, pale, vector3df(-30, 0, 0), 84 vector3df(-angle + 90, 0, 0), texture); 85 pale_1->setParent(this); 86 pale_2 = new MeshSceneNode(parent, pale, vector3df(30, 0, 0), 87 vector3df(angle + 90, 0, 0), texture); 88 pale_2->setParent(this); 89 90 anim = mgr->createRotationAnimator(vector3df(0.f, 0.f, 0.f)); 91 addAnimator(anim); 92 } 93 66 94 void Blade::OnRegisterSceneNode() { 67 95 if (IsVisible) -
trunk/lib/FlairSimulator/src/Blade.h
r15 r286 36 36 const irr::core::vector3df &position = irr::core::vector3df(0, 0, 0), 37 37 bool inverted = false, irr::s32 id = -1); 38 39 Blade(irr::scene::ISceneNode *parent, 40 const irr::core::vector3df &position = irr::core::vector3df(0, 0, 0), 41 bool inverted = false, irr::s32 id = -1); 42 38 43 virtual void OnRegisterSceneNode(void); 39 44 virtual void render(void); -
trunk/lib/FlairSimulator/src/FixedCamera.cpp
r167 r286 27 27 #include <Euler.h> 28 28 29 29 30 using namespace irr; 30 31 using namespace gui; … … 51 52 void FixedCamera::animateNode(ISceneNode *node, u32 timeMs) { 52 53 ICameraSceneNode *camera = static_cast<ICameraSceneNode *>(node); 53 54 54 55 if (LMouseKey == true) { 55 56 if (!Rotating) { -
trunk/lib/FlairSimulator/src/FollowMeCamera.cpp
r70 r286 63 63 64 64 void FollowMeCamera::animateNode(ISceneNode *node, u32 timeMs) { 65 66 65 float nRotY = RotY; 67 66 float nRotZ = RotZ; -
trunk/lib/FlairSimulator/src/GenericObject.cpp
r158 r286 40 40 { 41 41 meshSceneNode=getGui()->getSceneManager()->addMeshSceneNode(mesh); 42 42 /* 43 43 selector = getGui()->getSceneManager()->createTriangleSelector(mesh, meshSceneNode); 44 44 meshSceneNode->setTriangleSelector(selector); 45 45 */ 46 46 meshSceneNode->setMaterialFlag(EMF_LIGHTING, false); 47 47 … … 53 53 ITriangleSelector *GenericObject::TriangleSelector(void) { return selector; } 54 54 55 void GenericObject::setVisible(bool isVisible) { 56 meshSceneNode->setVisible(isVisible); 57 } 55 58 void GenericObject::setScale(float value) { 56 59 meshSceneNode->setScale(vector3df(value, value, value)); -
trunk/lib/FlairSimulator/src/Gui_impl.cpp
r166 r286 94 94 device->setResizable(false); 95 95 96 // font = device->getGUIEnvironment()->getBuiltInFont();97 96 driver = device->getVideoDriver(); 98 97 smgr = device->getSceneManager(); … … 179 178 int lastFPS = -1; 180 179 int cam_id = 0; 180 ITexture* texture=0; 181 IGUIFont* font =0; 182 183 if (!driver->queryFeature(video::EVDF_RENDER_TO_TARGET)) { 184 self->Warn("rendering to texture is not possible, axis will not be displayed\n"); 185 } else { 186 texture= getGui()->getSceneManager()->getVideoDriver()->addRenderTargetTexture(dimension2d<u32>(128,128)); 187 device->getGUIEnvironment()->addImage(texture,position2d<s32>(0,scene_height-texture->getSize().Height)); 188 font = getGui()->getDevice()->getGUIEnvironment()->getFont((media_path+"/font/simu_axis_font.xml").c_str()); 189 } 181 190 182 191 receiver->SetModel(models.at(0)); … … 242 251 driver->setViewPort(core::rect<s32>(0, 0, scene_width, scene_height)); 243 252 smgr->drawAll(); // commente voir plus bas 244 /* 245 env->drawAll(); 246 if (font) 247 { 248 font->draw(L"This demo shows that Irrlicht is also capable 249 of drawing 2D graphics.", 250 core::rect<s32>(130,10,300,50), 251 video::SColor(255,255,255,255)); 252 } 253 else 254 { 255 printf("err\n"); 256 } 257 device->setWindowCaption(L"toto");*/ 258 253 259 254 if (dbtFile_r == NULL) {// mode normal 260 255 for (size_t i = 0; i < models.size(); i++) { … … 263 258 } 264 259 260 //render to texture for axis if possible 261 if (texture) { 262 cameras.at(cam_id)->renderAxisToTexture(texture); 263 } 264 265 //process update for sensors (cam, us...) 266 //also draws embedded cameras (see SimuCameraGL::UpdateFrom) 265 267 for (size_t i = 0; i < models.size(); i++) { 266 268 models.at(i)->ProcessUpdate(NULL); 267 269 } 268 270 269 271 // on fait ca ici, devrait etre un peu plus haut 270 272 // mais a priori souci avec models.at(i)->pimpl_->CheckCollision(); … … 274 276 driver->setViewPort(core::rect<s32>(0, 0, scene_width, scene_height)); 275 277 smgr->drawAll(); 276 278 279 driver->setViewPort(core::rect<s32>(0, 0, smgr->getVideoDriver()->getScreenSize().Width, smgr->getVideoDriver()->getScreenSize().Height)); 280 if(font) { 281 font->draw(L"VRPN:",rect<s32>(10,scene_height-30,100,50),SColor(128,255,255,255)); 282 font->draw(L"X",rect<s32>(60,scene_height-30,100,50),SColor(255,255,0,0)); 283 font->draw(L"Y",rect<s32>(70,scene_height-30,100,50),SColor(255,0,255,0)); 284 font->draw(L"Z",rect<s32>(80,scene_height-30,100,50),SColor(255,0,0,255)); 285 286 } 287 device->getGUIEnvironment()->drawAll(); 277 288 driver->endScene(); 278 289 279 290 int fps = driver->getFPS(); 280 291 -
trunk/lib/FlairSimulator/src/MeshSceneNode.cpp
r15 r286 49 49 } 50 50 51 MeshSceneNode::MeshSceneNode(ISceneNode *parent, IMesh *mesh, 52 const vector3df &position, 53 const vector3df &rotation, ITexture *texture, 54 s32 id) 55 : IMeshSceneNode(parent, getGui()->getSceneManager(), id, 56 position, rotation) { 57 Material.Wireframe = false; 58 Material.Lighting = false; 59 60 setMesh(mesh); 61 62 if (texture != NULL) { 63 setMaterialTexture(0, texture); 64 } 65 66 //parent->getBoundingBox().addInternalBox(getTransformedBoundingBox()); 67 } 68 51 69 void MeshSceneNode::OnRegisterSceneNode(void) { 52 70 if (IsVisible) -
trunk/lib/FlairSimulator/src/MeshSceneNode.h
r15 r286 31 31 const irr::core::vector3df &rotation = irr::core::vector3df(0, 0, 0), 32 32 irr::video::ITexture *texture = NULL, irr::s32 id = -1); 33 34 MeshSceneNode( 35 irr::scene::ISceneNode *parent, irr::scene::IMesh *mesh, 36 const irr::core::vector3df &position = irr::core::vector3df(0, 0, 0), 37 const irr::core::vector3df &rotation = irr::core::vector3df(0, 0, 0), 38 irr::video::ITexture *texture = NULL, irr::s32 id = -1); 33 39 34 40 virtual void OnRegisterSceneNode(void); -
trunk/lib/FlairSimulator/src/SimuBldc.cpp
r224 r286 73 73 } 74 74 75 } // end namespace sensor75 } // end namespace actuator 76 76 } // end namespace flair -
trunk/lib/FlairSimulator/src/Simulator.cpp
r167 r286 36 36 Simulator *getSimulator(void) { return simu; } 37 37 38 Simulator::Simulator(string name, int optitrack_mstime, float yaw_deg )38 Simulator::Simulator(string name, int optitrack_mstime, float yaw_deg, int port) 39 39 : FrameworkManager(name) { 40 40 if (simu != NULL) 41 41 Err("Simulator should be instanced only one time\n"); 42 42 43 pimpl_ = new Simulator_impl(this, optitrack_mstime, yaw_deg );43 pimpl_ = new Simulator_impl(this, optitrack_mstime, yaw_deg,port); 44 44 simu = this; 45 45 } -
trunk/lib/FlairSimulator/src/Simulator.h
r167 r286 44 44 // yaw_deg: rotation of the vrpn coordinate with respect to the earth 45 45 // coordinate, around z axis 46 Simulator(std::string name, int optitrack_mstime = 10, float yaw_deg = 30 );46 Simulator(std::string name, int optitrack_mstime = 10, float yaw_deg = 30, int port=3883); 47 47 ~Simulator(); 48 48 void RunSimu(void); -
trunk/lib/FlairSimulator/src/Simulator_impl.cpp
r218 r286 31 31 32 32 Simulator_impl::Simulator_impl(Simulator *self, int optitrack_mstime, 33 float yaw_deg )34 : vrpn_Connection_IP( ), Thread(self, "simulator", 1) {33 float yaw_deg,int port) 34 : vrpn_Connection_IP(port), Thread(self, "simulator", 1) { 35 35 this->self = self; 36 36 this->optitrack_mstime = optitrack_mstime; -
trunk/lib/FlairSimulator/src/VisualizationCamera.cpp
r70 r286 31 31 using namespace core; 32 32 using namespace scene; 33 using namespace video; 33 34 34 35 namespace flair { … … 40 41 LMouseKey = false; 41 42 42 // camera43 // camera for visualization 43 44 camera = getGui()->getSceneManager()->addCameraSceneNode(); 44 45 camera->setAspectRatio(getGui()->getAspectRatio()); // on force a cause du view port … … 48 49 49 50 getGui()->pimpl_->AddVisualizationCamera(this); 51 52 // camera to draw axis, in a new dedicated scene manager 53 axis_scenemanager=getGui()->getSceneManager()->createNewSceneManager(); 54 axis_camera = axis_scenemanager->addCameraSceneNode(); 55 axis_camera->setAspectRatio(1); // same as texture ratio, TODO: get it from texture in renderAxisToTexture 56 axis_camera->setUpVector(vector3df(0, 0, 1)); 57 axis_camera->setFOV(PI / 2.5f); 58 axis_scenemanager->setActiveCamera(axis_camera); 59 prendre en compte le yaw monde/optitrack (rotation de axis_scenemanager?) 60 IAnimatedMesh* arrowMeshRed = axis_scenemanager->addArrowMesh( "x_axisArrow",video::SColor(255, 255, 0, 0),video::SColor(255, 255, 0, 0)); 61 nodeX = axis_scenemanager->addMeshSceneNode(arrowMeshRed); 62 nodeX->setMaterialFlag(video::EMF_LIGHTING, false); 63 nodeX->setRotation(vector3df(0,0,-90)); 64 nodeX->setScale(vector3df(1,3,1)); 65 66 IAnimatedMesh* arrowMeshGreen = axis_scenemanager->addArrowMesh( "y_axisArrow",video::SColor(255, 0, 255, 0),video::SColor(255, 0, 255, 0)); 67 nodeY = axis_scenemanager->addMeshSceneNode(arrowMeshGreen); 68 nodeY->setMaterialFlag(video::EMF_LIGHTING, false); 69 nodeY->setScale(vector3df(1,3,1)); 70 71 IAnimatedMesh* arrowMeshBlue = axis_scenemanager->addArrowMesh( "z_axisArrow",video::SColor(255, 0, 0, 255),video::SColor(255, 0, 0, 255)); 72 nodeZ = axis_scenemanager->addMeshSceneNode(arrowMeshBlue); 73 nodeZ->setMaterialFlag(video::EMF_LIGHTING, false); 74 nodeZ->setRotation(vector3df(-90,0,0));//irrlicht is left handed, draw a right handed axis 75 nodeZ->setScale(vector3df(1,3,1)); 50 76 } 51 77 52 78 VisualizationCamera::~VisualizationCamera() {} 79 80 void VisualizationCamera::renderAxisToTexture(ITexture* texture) { 81 //put axis at a "normalized" distance 82 vector3df direction=camera->getTarget()-camera->getPosition(); 83 direction.normalize(); 84 nodeX->setPosition(camera->getPosition()+direction*6); 85 nodeY->setPosition(camera->getPosition()+direction*6); 86 nodeZ->setPosition(camera->getPosition()+direction*6); 87 88 axis_camera->setPosition(camera->getPosition()); 89 axis_camera->setRotation(camera->getRotation()); 90 axis_camera->setTarget(camera->getTarget()); 91 92 axis_scenemanager->getVideoDriver()->setRenderTarget(texture, true, true, SColor(0,0,0,0)); 93 axis_scenemanager->drawAll(); 94 axis_scenemanager->getVideoDriver()->setRenderTarget(0, true, true, 0); 95 } 53 96 54 97 std::string VisualizationCamera::getName(void) { -
trunk/lib/FlairSimulator/src/VisualizationCamera.h
r70 r286 27 27 class ICameraSceneNode; 28 28 } 29 namespace video { 30 class ITexture; 31 } 29 32 } 30 33 … … 42 45 irr::scene::ICameraSceneNode *getCameraSceneNode(void); 43 46 std::string getName(void); 47 void renderAxisToTexture(irr::video::ITexture* texture); 44 48 45 49 private: 46 50 virtual bool isEventReceiverEnabled(void) const { return true; } 47 51 irr::scene::ISceneNode *nodeX,*nodeY,*nodeZ; 52 irr::scene::ISceneManager *axis_scenemanager; 53 48 54 protected: 49 55 bool LMouseKey; 50 56 irr::scene::ICameraSceneNode *camera; 57 irr::scene::ICameraSceneNode *axis_camera; 51 58 irr::core::position2df MousePos; 52 59 float currentZoom; -
trunk/lib/FlairSimulator/src/X4.h
r214 r286 43 43 #ifdef GL 44 44 virtual void Draw(void); 45 virtual void ExtraDraw(void){}; 45 virtual void ExtraDraw(void){}; 46 #endif 46 47 47 protected:48 Blade *fl_blade, *fr_blade, *rl_blade, *rr_blade;49 core::Mutex *motor_speed_mutex;50 #endif51 48 private: 52 49 void CalcModel(void); … … 56 53 void WritedbtBuf(char *dbtbuf); 57 54 void ReaddbtBuf(char *dbtbuf); 55 Blade *fl_blade, *fr_blade, *rl_blade, *rr_blade; 56 core::Mutex *motor_speed_mutex; 58 57 #endif 59 58 -
trunk/lib/FlairSimulator/src/X8.h
r214 r286 45 45 46 46 protected: 47 #ifdef GL 48 Blade *tfl_blade, *tfr_blade, *trl_blade, *trr_blade; 49 Blade *bfl_blade, *bfr_blade, *brl_blade, *brr_blade; 50 #endif 47 51 48 private: 52 49 void CalcModel(void); … … 57 54 void ReaddbtBuf(char *dbtbuf); 58 55 core::Mutex *motor_speed_mutex; 56 Blade *tfl_blade, *tfr_blade, *trl_blade, *trr_blade; 57 Blade *bfl_blade, *bfr_blade, *brl_blade, *brr_blade; 59 58 #endif 60 59 -
trunk/lib/FlairSimulator/src/unexported/GenericObject.h
r158 r286 47 47 void setPosition(const irr::core::vector3df& position); 48 48 void setRotation(const irr::core::vector3df& rotation); 49 void setVisible(bool isVisible);//visible by default at construction 49 50 50 51 private: -
trunk/lib/FlairSimulator/src/unexported/Model_impl.h
r218 r286 72 72 void OnRegisterSceneNode(void); 73 73 void render(void); 74 void Draw(void) {75 printf("CA MARCHE PAS PUNAISE\r\n");76 ExtraDraw();77 };78 void ExtraDraw(void) { printf("nope\r\n"); };79 74 80 75 const irr::core::aabbox3d<irr::f32> &getBoundingBox(void) const { -
trunk/lib/FlairSimulator/src/unexported/Simulator_impl.h
r158 r286 37 37 public: 38 38 Simulator_impl(flair::simulator::Simulator *self, int optitrack_mstime = 10, 39 float yaw_deg = 30 );39 float yaw_deg = 30, int port=3883); 40 40 ~Simulator_impl(); 41 41
Note:
See TracChangeset
for help on using the changeset viewer.