Changeset 69 in flair-src for trunk/lib/FlairSimulator
- Timestamp:
- Sep 2, 2016, 5:48:40 PM (8 years ago)
- Location:
- trunk/lib/FlairSimulator/src
- Files:
-
- 4 added
- 14 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSimulator/src/FollowMeCamera.cpp
r51 r69 4 4 // %flair:license} 5 5 // created: 2012/08/21 6 // filename: AnimPoursuite.cpp6 // filename: FollowMeCamera.cpp 7 7 // 8 8 // author: Guillaume Sanahuja … … 16 16 #ifdef GL 17 17 18 #include " AnimPoursuite.h"18 #include "FollowMeCamera.h" 19 19 #include "Simulator.h" 20 20 #include "Model.h" 21 21 #include "Model_impl.h" 22 #include "Gui.h" 22 23 #include <ICursorControl.h> 23 24 #include <ICameraSceneNode.h> 25 #include <IrrlichtDevice.h> 26 #include <ISceneManager.h> 24 27 25 28 using namespace irr; … … 31 34 namespace simulator { 32 35 33 AnimPoursuite::AnimPoursuite(const ISceneNode *parent, float rotateSpeed,34 float zoomSpeed) {36 FollowMeCamera::FollowMeCamera(const ISceneNode *parent, float rotateSpeed, 37 float zoomSpeed):VisualizationCamera(rotateSpeed,zoomSpeed) { 35 38 this->parent = parent; 36 this->zoomSpeed = zoomSpeed;37 this->rotateSpeed = rotateSpeed;38 currentZoom = 100;39 39 RotY = 20; 40 40 RotZ = 0; 41 41 Rotating = false; 42 LMouseKey = false;43 42 } 44 43 45 AnimPoursuite::~AnimPoursuite() {}44 FollowMeCamera::~FollowMeCamera() {} 46 45 47 void AnimPoursuite::setPositionOffset(vector3df newpos) { pos_offset = newpos; }46 void FollowMeCamera::setPositionOffset(vector3df newpos) { pos_offset = newpos; } 48 47 49 void AnimPoursuite::setTargetOffset(vector3df newpos) {48 void FollowMeCamera::setTargetOffset(vector3df newpos) { 50 49 target_offset = newpos; 51 50 } 52 51 53 float AnimPoursuite::sat(float value) {52 float FollowMeCamera::sat(float value) { 54 53 if (value > 89) 55 54 value = 89; … … 59 58 } 60 59 61 void AnimPoursuite::animateNode(ISceneNode *node, u32 timeMs) { 62 ICameraSceneNode *camera = static_cast<ICameraSceneNode *>(node); 60 void FollowMeCamera::animateNode(ISceneNode *node, u32 timeMs) { 63 61 vector3df pos; 64 62 … … 97 95 } 98 96 99 ISceneNodeAnimator *AnimPoursuite::createClone(ISceneNode *node,100 ISceneManager *newManager) {101 return NULL;102 }103 104 bool AnimPoursuite::MouseMoved(const SEvent &event,105 irr::core::position2df MousePos) {106 if (event.EventType != EET_MOUSE_INPUT_EVENT)107 return false;108 109 switch (event.MouseInput.Event) {110 111 case EMIE_MOUSE_WHEEL:112 currentZoom -= event.MouseInput.Wheel * zoomSpeed;113 if (currentZoom <= 0)114 currentZoom = zoomSpeed;115 break;116 case EMIE_LMOUSE_PRESSED_DOWN:117 LMouseKey = true;118 break;119 case EMIE_LMOUSE_LEFT_UP:120 LMouseKey = false;121 break;122 case EMIE_MOUSE_MOVED:123 this->MousePos = MousePos;124 break;125 default:126 return false;127 break;128 }129 130 return true;131 }132 97 133 98 } // end namespace simulator -
trunk/lib/FlairSimulator/src/GenericObject.cpp
r15 r69 19 19 #include "Simulator_impl.h" 20 20 21 #include "ConditionVariable.h"22 21 #include "Quaternion.h" 23 #include "Gui.h"24 #include "Gui_impl.h"25 #include <IMesh.h>26 22 #include <ISceneManager.h> 27 #include <IMetaTriangleSelector.h> 28 #include <IVideoDriver.h> 29 #include "AnimPoursuite.h" 23 30 24 using namespace irr; 31 25 using namespace video; 32 26 using namespace scene; 33 27 using namespace core; 34 using namespace io;35 28 36 29 using namespace flair::core; -
trunk/lib/FlairSimulator/src/Gui.cpp
r45 r69 19 19 #include "Gui_impl.h" 20 20 #include "Simulator.h" 21 #include "Simulator_impl.h"22 21 #include "Model.h" 23 #include "Model_impl.h"24 #include "AnimPoursuite.h"25 #include <Euler.h>26 #include <Object.h>27 22 #include <IMeshSceneNode.h> 28 23 #include <IVideoDriver.h> 29 24 #include <ISceneManager.h> 30 #include <unistd.h>31 25 #include <algorithm> 32 26 #include <GL/gl.h> … … 37 31 38 32 void constructor() { 39 compile_info("FlairS ensorActuator");33 compile_info("FlairSimulator"); 40 34 } 41 35 -
trunk/lib/FlairSimulator/src/Gui.h
r15 r69 62 62 irr::scene::IAnimatedMesh *getMesh(std::string filename) const; 63 63 irr::scene::ISceneManager *getSceneManager(void) const; 64 irr::IrrlichtDevice *getDevice(void) const; 64 65 float getAspectRatio(void) const; 65 66 66 67 protected: 67 irr::IrrlichtDevice *getDevice(void) const;68 68 void setMesh(std::string file, 69 69 irr::core::vector3df position = irr::core::vector3df(0, 0, 0), -
trunk/lib/FlairSimulator/src/Gui_impl.cpp
r15 r69 22 22 #include "Model.h" 23 23 #include "Model_impl.h" 24 #include "AnimPoursuite.h"25 24 #include <Object.h> 26 25 #include <Euler.h> … … 40 39 public: 41 40 // This is the one method that we have to implement 42 virtualbool OnEvent(const SEvent &event) {41 bool OnEvent(const SEvent &event) { 43 42 // Remember whether each key is down or up 44 43 if (event.EventType == EET_KEY_INPUT_EVENT) 45 44 KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown; 46 45 47 // Send all other events to camera48 if (event.EventType == EET_MOUSE_INPUT_EVENT && camera)49 // return camera->OnEvent(event);50 return camera->MouseMoved(event, cursorControl->getRelativePosition());51 52 46 if (model) 53 47 return model->OnEvent(event); … … 57 51 58 52 // This is used to check whether a key is being held down 59 virtualbool IsKeyDown(EKEY_CODE keyCode) {53 bool IsKeyDown(EKEY_CODE keyCode) { 60 54 if (KeyIsDown[keyCode] == true) { 61 55 KeyIsDown[keyCode] = false; … … 66 60 } 67 61 68 MyEventReceiver(ICursorControl *cursorControl) { 69 this->cursorControl = cursorControl; 70 camera = NULL; 62 MyEventReceiver(void) { 71 63 model = NULL; 72 64 for (u32 i = 0; i < KEY_KEY_CODES_COUNT; ++i) 73 65 KeyIsDown[i] = false; 74 66 } 75 void SetCamera(AnimPoursuite *camera) { this->camera = camera; }76 67 void SetModel(Model *model) { this->model = model; } 77 68 … … 79 70 // We use this array to store the current state of each key 80 71 bool KeyIsDown[KEY_KEY_CODES_COUNT]; 81 AnimPoursuite *camera;82 72 Model *model; 83 ICursorControl *cursorControl;84 73 }; 85 74 … … 96 85 device = createDevice(driver_type, dimension2d<u32>(app_width, app_height), 97 86 16, false, false, false); 98 receiver = new MyEventReceiver( device->getCursorControl());87 receiver = new MyEventReceiver(); 99 88 device->setEventReceiver(receiver); 100 89 device->getLogger()->setLogLevel(ELL_NONE); … … 109 98 smgr->setAmbientLight(video::SColorf(1, 1, 1)); 110 99 100 /* 101 // camera 102 camera = smgr->addCameraSceneNode(); 103 104 camera->setAspectRatio( 105 (float)scene_width / (float)scene_height); // on force a cause du view port 106 107 camera->setUpVector(vector3df(0, 0, 1)); 108 109 FixedCamera* animator = new FixedCamera(vector3df(1,1,1)); 110 camera->addAnimator(animator); 111 112 camera->setFarValue(8000);*/ 111 113 /* 112 114 env = device->getGUIEnvironment(); … … 185 187 int cam_id = 0; 186 188 187 receiver->SetCamera(models.at(cam_id)->pimpl_->animator);188 189 receiver->SetModel(models.at(cam_id)); 189 190 … … 199 200 } 200 201 for (size_t j = 0; j < models.size(); j++) { 201 if (i == j) 202 continue; 202 if (i == j) continue; 203 203 models.at(i)->pimpl_->MetaTriangleSelector()->addTriangleSelector( 204 204 models.at(j)->pimpl_->TriangleSelector()); … … 247 247 248 248 // vue poursuite 249 smgr->setActiveCamera(models.at(cam_id)-> pimpl_->camera);249 smgr->setActiveCamera(models.at(cam_id)->getFollowMeCamera()->getCameraSceneNode()); 250 250 driver->setViewPort(core::rect<s32>(0, 0, scene_width, scene_height)); 251 251 smgr->drawAll(); // commente voir plus bas … … 279 279 // mais a priori souci avec models.at(i)->pimpl_->CheckCollision(); 280 280 // (setelipsoid?) 281 smgr->setActiveCamera(models.at(cam_id)-> pimpl_->camera);281 smgr->setActiveCamera(models.at(cam_id)->getFollowMeCamera()->getCameraSceneNode()); 282 282 driver->setViewPort(core::rect<s32>(0, 0, scene_width, scene_height)); 283 283 smgr->drawAll(); … … 294 294 if (receiver->IsKeyDown(KEY_PRIOR)) { 295 295 cam_id++; 296 if (cam_id >= (int)models.size()) 297 cam_id = 0; 298 receiver->SetCamera(models.at(cam_id)->pimpl_->animator); 296 if (cam_id >= (int)models.size()) cam_id = 0; 299 297 receiver->SetModel(models.at(cam_id)); 300 298 setWindowCaption(models.at(cam_id), fps); … … 302 300 if (receiver->IsKeyDown(KEY_NEXT)) { 303 301 cam_id--; 304 if (cam_id < 0) 305 cam_id = models.size() - 1; 306 receiver->SetCamera(models.at(cam_id)->pimpl_->animator); 302 if (cam_id < 0) cam_id = models.size() - 1; 307 303 receiver->SetModel(models.at(cam_id)); 308 304 setWindowCaption(models.at(cam_id), fps); … … 355 351 } 356 352 357 receiver->SetCamera(NULL);358 353 receiver->SetModel(NULL); 359 354 } -
trunk/lib/FlairSimulator/src/Man.cpp
r15 r69 25 25 #include <Tab.h> 26 26 #include <DoubleSpinBox.h> 27 #include " AnimPoursuite.h"27 #include "FollowMeCamera.h" 28 28 29 29 using namespace irr; … … 47 47 node->getMaterial(0).Lighting = false; 48 48 49 get Camera()->setPositionOffset(vector3df(0, 0, 100));50 get Camera()->setTargetOffset(vector3df(0, 0, 100));49 getFollowMeCamera()->setPositionOffset(vector3df(0, 0, 100)); 50 getFollowMeCamera()->setTargetOffset(vector3df(0, 0, 100)); 51 51 52 52 setTriangleSelector( -
trunk/lib/FlairSimulator/src/Model.cpp
r15 r69 19 19 #include "Simulator.h" 20 20 #include "Simulator_impl.h" 21 #include "FollowMeCamera.h" 21 22 #include <DoubleSpinBox.h> 22 23 … … 63 64 aabbox3d<f32> *Model::Box() const { return &(pimpl_->box); } 64 65 65 AnimPoursuite *Model::getCamera(void) const { return pimpl_->animator; }66 FollowMeCamera *Model::getFollowMeCamera(void) const { return pimpl_->camera; } 66 67 67 68 void Model::setTriangleSelector(ITriangleSelector *selector) { … … 71 72 } 72 73 73 void Model::setCameraFarValue(float zf) { pimpl_->camera-> setFarValue(zf); }74 void Model::setCameraFarValue(float zf) { pimpl_->camera->getCameraSceneNode()->setFarValue(zf); } 74 75 #endif 75 76 -
trunk/lib/FlairSimulator/src/Model.h
r15 r69 25 25 #ifdef GL 26 26 #include <aabbox3d.h> 27 #include <IEventReceiver.h> 27 28 namespace irr { 28 29 class SEvent; … … 51 52 namespace simulator { 52 53 class Simulator; 53 class AnimPoursuite;54 class FollowMeCamera; 54 55 55 class Model : public core::IODevice { 56 class Model : public core::IODevice 57 #ifdef GL 58 , public irr::IEventReceiver 59 #endif 60 { 56 61 friend class ::Gui_impl; 57 62 friend class ::Simulator_impl; 58 63 friend class ::Model_impl; 59 friend class AnimPoursuite;60 64 friend class sensor::SensorGL; 61 65 … … 80 84 virtual void WritedbtBuf(char *dbtbuf) = 0; 81 85 virtual void ReaddbtBuf(char *dbtbuf) = 0; 82 virtual bool OnEvent(const irr::SEvent &event) = 0; 86 87 //default event handling 88 bool OnEvent(const irr::SEvent &event) { return false;}; 83 89 84 90 //! Sets the value of the camera's far clipping plane (default: 2000.0f) … … 93 99 virtual void CalcModel(void) = 0; 94 100 #ifdef GL 95 AnimPoursuite *getCamera(void) const;101 FollowMeCamera *getFollowMeCamera(void) const; 96 102 virtual void AnimateModel(void) = 0; 97 103 // void setPosition(core::Vector3D pos); -
trunk/lib/FlairSimulator/src/Model_impl.cpp
r15 r69 37 37 #include <IVideoDriver.h> 38 38 #include <ICameraSceneNode.h> 39 #include "AnimPoursuite.h" 39 #include "FollowMeCamera.h" 40 40 41 using namespace irr; 41 42 using namespace video; … … 82 83 83 84 // camera 84 camera = getSceneManager()->addCameraSceneNode(); 85 camera->setAspectRatio( 86 getGui()->getAspectRatio()); // on force a cause du view port 87 camera->setUpVector(vector3df(0, 0, 1)); 88 89 animator = new AnimPoursuite(this); 90 camera->addAnimator(animator); 91 camera->setFarValue(8000); 85 camera = new FollowMeCamera(this); 92 86 93 87 position_init = false; -
trunk/lib/FlairSimulator/src/Parser.cpp
r15 r69 20 20 #include "GenericObject.h" 21 21 #include <vector3d.h> 22 #include <irrlicht.h> 22 #include <IrrlichtDevice.h> 23 #include <IFileSystem.h> 23 24 #include "GenericObject.h" 24 25 -
trunk/lib/FlairSimulator/src/X4.h
r15 r69 66 66 void CalcModel(void); 67 67 #ifdef GL 68 bool OnEvent(const irr::SEvent &event){};69 68 void AnimateModel(void); 70 69 size_t dbtSize(void) const; -
trunk/lib/FlairSimulator/src/X8.h
r15 r69 66 66 void CalcModel(void); 67 67 #ifdef GL 68 bool OnEvent(const irr::SEvent &event){};69 68 void AnimateModel(void); 70 69 size_t dbtSize(void) const; -
trunk/lib/FlairSimulator/src/unexported/FollowMeCamera.h
r51 r69 4 4 // %flair:license} 5 5 // created: 2012/08/21 6 // filename: AnimPoursuite.h6 // filename: FollowMeCamera.h 7 7 // 8 8 // author: Guillaume Sanahuja … … 15 15 /*********************************************************************/ 16 16 17 #ifndef ANIMPOURSUITE_H18 #define ANIMPOURSUITE_H17 #ifndef FOLLOWMECAMERA_H 18 #define FOLLOWMECAMERA_H 19 19 20 #include <ISceneNodeAnimator.h> 21 #include <position2d.h> 22 #include <vector3d.h> 20 #include "VisualizationCamera.h" 21 23 22 24 23 namespace flair { 25 24 namespace simulator { 26 25 27 class AnimPoursuite : public irr::scene::ISceneNodeAnimator{26 class FollowMeCamera : public VisualizationCamera { 28 27 public: 29 AnimPoursuite(const irr::scene::ISceneNode *parent,28 FollowMeCamera(const irr::scene::ISceneNode *parent, 30 29 float rotateSpeed = -500.0f, float zoomSpeed = 4.0f); 31 ~ AnimPoursuite();30 ~FollowMeCamera(); 32 31 33 32 void animateNode(irr::scene::ISceneNode *node, irr::u32 timeMs); 34 ISceneNodeAnimator *createClone(irr::scene::ISceneNode *node,35 irr::scene::ISceneManager *newManager = 0);36 bool MouseMoved(const irr::SEvent &event, irr::core::position2df MousePos);37 33 void setPositionOffset(irr::core::vector3df newpos); 38 34 void setTargetOffset(irr::core::vector3df newpos); 39 35 40 36 private: 41 virtual bool isEventReceiverEnabled(void) const { return true; }42 43 37 irr::core::vector3df pos_offset, target_offset; 44 bool LMouseKey;45 38 irr::core::position2df RotateStart; 46 irr::core::position2df MousePos;47 39 const irr::scene::ISceneNode *parent; 48 40 bool Rotating; 49 41 float RotY, RotZ; 50 float rotateSpeed;51 float zoomSpeed;52 float currentZoom;53 42 float sat(float value); 54 43 }; … … 57 46 } // end namespace flair 58 47 59 #endif // ANIMPOURSUITE_H48 #endif // FOLLOWMECAMERA_H -
trunk/lib/FlairSimulator/src/unexported/GenericObject.h
r15 r69 29 29 #include <IVideoDriver.h> 30 30 #include <ICameraSceneNode.h> 31 #include " AnimPoursuite.h"31 #include "FollowMeCamera.h" 32 32 33 33 #include <IODevice.h> -
trunk/lib/FlairSimulator/src/unexported/Gui_impl.h
r15 r69 30 30 class IMeshSceneNode; 31 31 class ITriangleSelector; 32 //class ICameraSceneNode; 32 33 } 33 34 namespace video { … … 48 49 class GenericObject; 49 50 class Gui; 51 class FixedCamera; 50 52 } 51 53 } … … 83 85 size_t dbtSize(std::vector<flair::simulator::Model *> modeles); 84 86 char *dbtbuf; 87 flair::simulator::FixedCamera *fixedCamera; 85 88 flair::simulator::Gui *self; 89 //irr::scene::ICameraSceneNode * camera; 86 90 }; 87 91 -
trunk/lib/FlairSimulator/src/unexported/Model_impl.h
r15 r69 38 38 namespace simulator { 39 39 class Simulator; 40 class AnimPoursuite;40 class FollowMeCamera; 41 41 } 42 42 } … … 52 52 class IMetaTriangleSelector; 53 53 class ISceneNodeAnimatorCollisionResponse; 54 class ICameraSceneNode;55 54 } 56 55 } … … 94 93 irr::core::aabbox3d<irr::f32> box; 95 94 void SynchronizationPoint(); 96 irr::scene::ICameraSceneNode *camera; 97 flair::simulator::AnimPoursuite *animator; 95 flair::simulator::FollowMeCamera *camera; 98 96 irr::scene::ITriangleSelector *selector; 99 97 #endif
Note:
See TracChangeset
for help on using the changeset viewer.