Changeset 13 in flair-dev for trunk/include/FlairSimulator
- Timestamp:
- Apr 8, 2016, 3:39:24 PM (9 years ago)
- Location:
- trunk/include/FlairSimulator
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/FlairSimulator/Blade.h
r9 r13 20 20 #include <ISceneNode.h> 21 21 22 namespace irr 23 { 24 namespace scene 25 { 26 class IMesh; 27 } 22 namespace irr { 23 namespace scene { 24 class IMesh; 25 } 28 26 } 29 27 30 namespace flair 31 { 32 namespace simulator 33 { 34 class MeshSceneNode; 35 class Model; 28 namespace flair { 29 namespace simulator { 30 class MeshSceneNode; 31 class Model; 36 32 37 class Blade : public irr::scene::ISceneNode 38 { 39 public: 33 class Blade : public irr::scene::ISceneNode { 34 public: 35 Blade(Model *parent, 36 const irr::core::vector3df &position = irr::core::vector3df(0, 0, 0), 37 bool inverted = false, irr::s32 id = -1); 38 virtual void OnRegisterSceneNode(void); 39 virtual void render(void); 40 virtual const irr::core::aabbox3d<irr::f32> &getBoundingBox(void) const { 41 return Box; 42 } 43 void SetRotationSpeed(float value); 40 44 41 Blade(Model* parent,const irr::core::vector3df& position = irr::core::vector3df(0,0,0),bool inverted=false,irr::s32 id=-1); 42 virtual void OnRegisterSceneNode(void); 43 virtual void render(void); 44 virtual const irr::core::aabbox3d<irr::f32>& getBoundingBox(void) const 45 { 46 return Box; 47 } 48 void SetRotationSpeed(float value); 49 50 51 private: 52 irr::scene::IMesh *pale; 53 irr::core::aabbox3d<irr::f32> Box; 54 MeshSceneNode *pale_1,*pale_2; 55 irr::scene::ISceneNodeAnimator *anim; 56 }; 45 private: 46 irr::scene::IMesh *pale; 47 irr::core::aabbox3d<irr::f32> Box; 48 MeshSceneNode *pale_1, *pale_2; 49 irr::scene::ISceneNodeAnimator *anim; 50 }; 57 51 } // end namespace simulator 58 52 } // end namespace flair -
trunk/include/FlairSimulator/Castle.h
r9 r13 19 19 20 20 #include <Gui.h> 21 namespace flair 22 { 23 namespace simulator 24 { 25 class Castle:public Gui 26 { 27 public: 28 Castle(const flair::simulator::Simulator* parent,int app_width, int app_height,int scene_width, int scene_height,std::string media_path); 29 ~Castle(); 21 namespace flair { 22 namespace simulator { 23 class Castle : public Gui { 24 public: 25 Castle(const flair::simulator::Simulator *parent, int app_width, 26 int app_height, int scene_width, int scene_height, 27 std::string media_path); 28 ~Castle(); 30 29 31 private: 32 33 }; 30 private: 31 }; 34 32 } // end namespace simulator 35 33 } // end namespace flair -
trunk/include/FlairSimulator/DiscreteTimeVariable.h
r9 r13 20 20 #include <stdlib.h> 21 21 22 namespace flair 23 { 24 namespace simulator 25 { 26 template <typename T,size_t size> 27 class DiscreteTimeVariable 28 { 29 public: 30 DiscreteTimeVariable(){}; 31 ~DiscreteTimeVariable(){}; 32 T& operator[](ssize_t idx) 33 { 34 if(idx>0) idx=0; 35 if(idx<(ssize_t)(-size+1)) idx=-size+1; 36 return array[-idx]; 37 } 38 const T&operator[](ssize_t idx) const 39 { 40 return const_cast<T&>(*this)[idx]; 41 }; 42 void Update(void) 43 { 44 for(int i=size-1;i>0;i--) 45 { 46 array[i]=array[i-1]; 47 } 48 } 22 namespace flair { 23 namespace simulator { 24 template <typename T, size_t size> class DiscreteTimeVariable { 25 public: 26 DiscreteTimeVariable(){}; 27 ~DiscreteTimeVariable(){}; 28 T &operator[](ssize_t idx) { 29 if (idx > 0) 30 idx = 0; 31 if (idx < (ssize_t)(-size + 1)) 32 idx = -size + 1; 33 return array[-idx]; 34 } 35 const T &operator[](ssize_t idx) const { 36 return const_cast<T &>(*this)[idx]; 37 }; 38 void Update(void) { 39 for (int i = size - 1; i > 0; i--) { 40 array[i] = array[i - 1]; 41 } 42 } 49 43 50 private: 51 T array[size]; 52 53 }; 44 private: 45 T array[size]; 46 }; 54 47 } // end namespace simulator 55 48 } // end namespace flair -
trunk/include/FlairSimulator/Gui.h
r9 r13 22 22 #include <vector3d.h> 23 23 24 namespace irr 25 { 26 class IrrlichtDevice; 27 namespace video 28 { 29 class ITexture; 30 } 31 namespace scene 32 { 33 class IAnimatedMesh; 34 class ISceneManager; 35 } 24 namespace irr { 25 class IrrlichtDevice; 26 namespace video { 27 class ITexture; 28 } 29 namespace scene { 30 class IAnimatedMesh; 31 class ISceneManager; 32 } 36 33 } 37 34 38 namespace flair 39 { 40 namespace core 41 { 42 class Object; 43 class Vector3D; 44 class Euler; 45 class Quaternion; 46 } 35 namespace flair { 36 namespace core { 37 class Object; 38 class Vector3D; 39 class Euler; 40 class Quaternion; 41 } 47 42 } 48 43 … … 51 46 class Model_impl; 52 47 53 namespace flair 54 { 55 namespace simulator 56 { 57 class Simulator; 48 namespace flair { 49 namespace simulator { 50 class Simulator; 58 51 59 class Gui: public core::Object 60 { 61 friend class ::Simulator_impl; 52 class Gui : public core::Object { 53 friend class ::Simulator_impl; 62 54 63 public: 64 Gui(const Simulator* parent,std::string name,int app_width, int app_height,int scene_width, int scene_height,std::string media_path,irr::video::E_DRIVER_TYPE driver_type=irr::video::EDT_OPENGL); 65 ~Gui(); 66 irr::core::vector3df getRotation(void) const; 67 irr::video::ITexture* getTexture(std::string filename) const; 68 irr::scene::IAnimatedMesh* getMesh(std::string filename) const; 69 irr::scene::ISceneManager* getSceneManager(void) const; 70 float getAspectRatio(void) const; 55 public: 56 Gui(const Simulator *parent, std::string name, int app_width, int app_height, 57 int scene_width, int scene_height, std::string media_path, 58 irr::video::E_DRIVER_TYPE driver_type = irr::video::EDT_OPENGL); 59 ~Gui(); 60 irr::core::vector3df getRotation(void) const; 61 irr::video::ITexture *getTexture(std::string filename) const; 62 irr::scene::IAnimatedMesh *getMesh(std::string filename) const; 63 irr::scene::ISceneManager *getSceneManager(void) const; 64 float getAspectRatio(void) const; 71 65 72 protected: 73 irr::IrrlichtDevice *getDevice(void) const; 74 void setMesh(std::string file,irr::core::vector3df position = irr::core::vector3df(0,0,0),irr::core::vector3df rotation= irr::core::vector3df(0,0,0),irr::core::vector3df scale= irr::core::vector3df(1,1,1)); 66 protected: 67 irr::IrrlichtDevice *getDevice(void) const; 68 void setMesh(std::string file, 69 irr::core::vector3df position = irr::core::vector3df(0, 0, 0), 70 irr::core::vector3df rotation = irr::core::vector3df(0, 0, 0), 71 irr::core::vector3df scale = irr::core::vector3df(1, 1, 1)); 75 72 76 77 78 73 private: 74 Gui_impl *pimpl_; 75 }; 79 76 80 81 82 83 84 85 Gui*getGui(void);77 /*! 78 * \brief get Gui 79 * 80 * \return the Gui 81 */ 82 Gui *getGui(void); 86 83 87 84 bool noGui(void); 88 85 89 bool isGlExtensionSupported(const std::string& ext); // check if a extension is supported 86 bool isGlExtensionSupported( 87 const std::string &ext); // check if a extension is supported 90 88 91 92 93 94 95 96 97 98 89 /*! 90 * \brief Convert to irrlicht scale 91 * 92 * \param value value in simulator scale 93 * 94 * \return value in irrlicht scale 95 */ 96 float ToIrrlichtScale(float value); 99 97 100 101 102 103 104 105 106 107 98 /*! 99 * \brief Convert to simulator scale 100 * 101 * \param value value in irrlicht scale 102 * 103 * \return value in simulator scale 104 */ 105 float ToSimulatorScale(float value); 108 106 109 110 111 112 113 114 115 116 117 118 107 /*! 108 * \brief Convert to irrlicht coordinates 109 * 110 * irrlicht is left handed and as a different scale 111 * 112 * \param vect vector in simulator coordinates 113 * 114 * \return vector in irrlicht coordinates 115 */ 116 irr::core::vector3df ToIrrlichtCoordinates(irr::core::vector3df vect); 119 117 120 121 122 123 124 125 126 127 128 129 118 /*! 119 * \brief Convert to irrlicht coordinates 120 * 121 * irrlicht is left handed and as a different scale 122 * 123 * \param vect vector in simulator coordinates 124 * 125 * \return vector in irrlicht coordinates 126 */ 127 irr::core::vector3df ToIrrlichtCoordinates(core::Vector3D vect); 130 128 131 132 133 134 135 136 137 138 139 140 129 /*! 130 * \brief Convert to simulator coordinates 131 * 132 * irrlicht is left handed and as a different scale 133 * 134 * \param vect vector in irrlicht coordinates 135 * 136 * \return vector in simulator coordinates 137 */ 138 core::Vector3D ToSimulatorCoordinates(irr::core::vector3df vect); 141 139 142 143 144 145 146 147 148 149 150 151 140 /*! 141 * \brief Convert to irrlicht orientation 142 * 143 * irrlicht is left handed 144 * 145 * \param quat quaternion in simulator frame 146 * 147 * \return quaternion in irrlicht frame 148 */ 149 core::Quaternion ToIrrlichtOrientation(core::Quaternion quat); 152 150 153 151 } // end namespace simulator -
trunk/include/FlairSimulator/Man.h
r9 r13 20 20 #include <Model.h> 21 21 22 namespace irr 23 { 24 namespace scene 25 { 26 class IAnimatedMeshSceneNode; 27 } 22 namespace irr { 23 namespace scene { 24 class IAnimatedMeshSceneNode; 25 } 28 26 } 29 27 30 namespace flair 31 { 32 namespace gui 33 { 34 class DoubleSpinBox; 35 } 28 namespace flair { 29 namespace gui { 30 class DoubleSpinBox; 31 } 36 32 } 37 33 38 namespace flair 39 { 40 namespace simulator 41 { 42 class Simulator; 34 namespace flair { 35 namespace simulator { 36 class Simulator; 43 37 44 class Man: private Model 45 { 46 public: 47 Man(const Simulator* parent,std::string name); 48 ~Man(); 38 class Man : private Model { 39 public: 40 Man(const Simulator *parent, std::string name); 41 ~Man(); 49 42 50 51 52 void WritedbtBuf(char*dbtbuf);53 void ReaddbtBuf(char*dbtbuf);54 55 56 bool OnEvent(const irr::SEvent&event);43 private: 44 size_t dbtSize(void) const; 45 void WritedbtBuf(char *dbtbuf); 46 void ReaddbtBuf(char *dbtbuf); 47 void CalcModel(void); 48 void AnimateModel(void){}; 49 bool OnEvent(const irr::SEvent &event); 57 50 58 irr::scene::IAnimatedMeshSceneNode*node;59 gui::DoubleSpinBox *t_speed,*r_speed;60 51 irr::scene::IAnimatedMeshSceneNode *node; 52 gui::DoubleSpinBox *t_speed, *r_speed; 53 }; 61 54 } // end namespace simulator 62 55 } // end namespace flair -
trunk/include/FlairSimulator/MeshSceneNode.h
r9 r13 20 20 #include <IMeshSceneNode.h> 21 21 22 namespace flair 23 { 24 namespace simulator 25 { 26 class Model; 22 namespace flair { 23 namespace simulator { 24 class Model; 27 25 28 class MeshSceneNode : public irr::scene::IMeshSceneNode 29 { 30 public:31 MeshSceneNode(Model* parent,irr::scene::IMesh*mesh,32 const irr::core::vector3df& position = irr::core::vector3df(0,0,0),33 const irr::core::vector3df& rotation = irr::core::vector3df(0,0,0),34 irr::video::ITexture* texture=NULL, irr::s32 id=-1);26 class MeshSceneNode : public irr::scene::IMeshSceneNode { 27 public: 28 MeshSceneNode( 29 Model *parent, irr::scene::IMesh *mesh, 30 const irr::core::vector3df &position = irr::core::vector3df(0, 0, 0), 31 const irr::core::vector3df &rotation = irr::core::vector3df(0, 0, 0), 32 irr::video::ITexture *texture = NULL, irr::s32 id = -1); 35 33 36 virtual void OnRegisterSceneNode(void); 37 virtual void render(void); 38 virtual const irr::core::aabbox3d<irr::f32>& getBoundingBox() const 39 { 40 return Box; 41 } 42 virtual irr::u32 getMaterialCount(void) const 43 { 44 return 1; 45 } 46 virtual irr::video::SMaterial& getMaterial(irr::u32 i); 47 virtual void setMesh( irr::scene::IMesh* ptr); 48 virtual irr::scene::IMesh* getMesh(void); 49 virtual void setReadOnlyMaterials(bool readonly); 50 virtual bool isReadOnlyMaterials(void) const 51 { 52 return false; 53 } 54 virtual irr::scene::IShadowVolumeSceneNode* addShadowVolumeSceneNode(const irr::scene::IMesh* shadowMesh=0, 55 irr::s32 id=-1, bool zfailmethod=true, irr::f32 infinity=1000.0f) 56 { 57 return NULL; 58 } 34 virtual void OnRegisterSceneNode(void); 35 virtual void render(void); 36 virtual const irr::core::aabbox3d<irr::f32> &getBoundingBox() const { 37 return Box; 38 } 39 virtual irr::u32 getMaterialCount(void) const { return 1; } 40 virtual irr::video::SMaterial &getMaterial(irr::u32 i); 41 virtual void setMesh(irr::scene::IMesh *ptr); 42 virtual irr::scene::IMesh *getMesh(void); 43 virtual void setReadOnlyMaterials(bool readonly); 44 virtual bool isReadOnlyMaterials(void) const { return false; } 45 virtual irr::scene::IShadowVolumeSceneNode * 46 addShadowVolumeSceneNode(const irr::scene::IMesh *shadowMesh = 0, 47 irr::s32 id = -1, bool zfailmethod = true, 48 irr::f32 infinity = 1000.0f) { 49 return NULL; 50 } 59 51 60 61 62 63 64 52 private: 53 irr::scene::IMesh *mesh; 54 irr::core::aabbox3d<irr::f32> Box; 55 irr::video::SMaterial Material; 56 }; 65 57 } // end namespace simulator 66 58 } // end namespace flair -
trunk/include/FlairSimulator/Model.h
r9 r13 25 25 #ifdef GL 26 26 #include <aabbox3d.h> 27 namespace irr 28 { 29 class SEvent; 30 namespace scene 31 { 32 class ISceneManager; 33 class ISceneNode; 34 class ITriangleSelector; 35 } 27 namespace irr { 28 class SEvent; 29 namespace scene { 30 class ISceneManager; 31 class ISceneNode; 32 class ITriangleSelector; 33 } 36 34 } 37 35 #endif 38 36 39 namespace flair 40 { 41 namespace gui 42 { 43 class TabWidget; 44 } 45 namespace sensor 46 { 47 class SensorGL; 48 } 37 namespace flair { 38 namespace gui { 39 class TabWidget; 40 } 41 namespace sensor { 42 class SensorGL; 43 } 49 44 } 50 45 … … 53 48 class Model_impl; 54 49 55 namespace flair 56 { 57 namespace simulator 58 { 59 class Simulator; 60 class AnimPoursuite; 50 namespace flair { 51 namespace simulator { 52 class Simulator; 53 class AnimPoursuite; 61 54 62 class Model : public core::IODevice 63 { 64 friend class ::Gui_impl; 65 friend class ::Simulator_impl; 66 friend class ::Model_impl; 67 friend class AnimPoursuite; 68 friend class sensor::SensorGL; 55 class Model : public core::IODevice { 56 friend class ::Gui_impl; 57 friend class ::Simulator_impl; 58 friend class ::Model_impl; 59 friend class AnimPoursuite; 60 friend class sensor::SensorGL; 69 61 70 71 Model(const Simulator* parent,std::string name);72 62 public: 63 Model(const Simulator *parent, std::string name); 64 virtual ~Model(); 73 65 66 typedef struct simu_state { 67 core::Quaternion Quat; 68 core::Vector3D W; 69 core::Vector3D Pos; 70 core::Vector3D Vel; 71 } simu_state_t; 74 72 75 typedef struct simu_state { 76 core::Quaternion Quat; 77 core::Vector3D W; 78 core::Vector3D Pos; 79 core::Vector3D Vel; 80 } simu_state_t; 73 #ifdef GL 74 irr::scene::ISceneNode *getSceneNode() const; 75 irr::core::aabbox3d<irr::f32> *Box() const; 81 76 82 #ifdef GL 83 irr::scene::ISceneNode* getSceneNode() const; 84 irr::core::aabbox3d<irr::f32>* Box() const; 77 virtual size_t dbtSize(void) const = 0; 78 virtual void Draw(void){}; 79 virtual void ExtraDraw(void){}; 80 virtual void WritedbtBuf(char *dbtbuf) = 0; 81 virtual void ReaddbtBuf(char *dbtbuf) = 0; 82 virtual bool OnEvent(const irr::SEvent &event) = 0; 85 83 86 virtual size_t dbtSize(void) const =0; 87 virtual void Draw(void){}; 88 virtual void ExtraDraw(void){}; 89 virtual void WritedbtBuf(char* dbtbuf)=0; 90 virtual void ReaddbtBuf(char* dbtbuf)=0; 91 virtual bool OnEvent(const irr::SEvent& event)=0; 84 //! Sets the value of the camera's far clipping plane (default: 2000.0f) 85 /** \param zf: New z far value. */ 86 void setCameraFarValue(float zf); 87 #endif 88 gui::TabWidget *GetTabWidget(void) const; 92 89 93 //! Sets the value of the camera's far clipping plane (default: 2000.0f) 94 /** \param zf: New z far value. */ 95 void setCameraFarValue(float zf); 96 #endif 97 gui::TabWidget* GetTabWidget(void) const; 90 protected: 91 DiscreteTimeVariable<simu_state_t, 3> state; 92 float dT(void) const; 93 virtual void CalcModel(void) = 0; 94 #ifdef GL 95 AnimPoursuite *getCamera(void) const; 96 virtual void AnimateModel(void) = 0; 97 // void setPosition(core::Vector3D pos); 98 void setScale(float value); 99 void setTriangleSelector(irr::scene::ITriangleSelector *selector); 100 #endif 98 101 99 protected: 100 DiscreteTimeVariable<simu_state_t,3> state; 101 float dT(void) const; 102 virtual void CalcModel(void)=0; 103 #ifdef GL 104 AnimPoursuite* getCamera(void) const; 105 virtual void AnimateModel(void)=0; 106 //void setPosition(core::Vector3D pos); 107 void setScale(float value); 108 void setTriangleSelector(irr::scene::ITriangleSelector* selector); 109 #endif 110 111 private: 112 void UpdateFrom(const core::io_data *data){}; 113 class Model_impl* pimpl_; 114 }; 102 private: 103 void UpdateFrom(const core::io_data *data){}; 104 class Model_impl *pimpl_; 105 }; 115 106 } // end namespace simulator 116 107 } // end namespace flair -
trunk/include/FlairSimulator/Parser.h
r9 r13 22 22 #include <libxml/tree.h> 23 23 24 namespace flair 25 { 26 namespace simulator 27 { 28 class Parser:public Gui 29 { 24 namespace flair { 25 namespace simulator { 26 class Parser : public Gui { 30 27 31 /*can create:32 - cylinders: in y axis28 /*can create: 29 - cylinders: in y axis 33 30 34 */ 35 public: 36 Parser(Simulator* parent,int app_width, int app_height,int scene_width, int scene_height,std::string media_path, std::string xmlFile); 37 ~Parser(); 31 */ 32 public: 33 Parser(Simulator *parent, int app_width, int app_height, int scene_width, 34 int scene_height, std::string media_path, std::string xmlFile); 35 ~Parser(); 38 36 39 40 private:41 xmlDoc *doc;42 std::string media_path;43 Simulator* parent;44 void processElements(xmlNode *a_node);45 void processObjects(xmlNode *a_node);46 void processParams(xmlNode * a_node);47 irr::core::vector3df getMeshVect(xmlNode * mesh_node, xmlChar * param);48 irr::core::vector3df getSceneVect(xmlNode * mesh_node, xmlChar * param, bool isScale=false);37 private: 38 xmlDoc *doc; 39 std::string media_path; 40 Simulator *parent; 41 void processElements(xmlNode *a_node); 42 void processObjects(xmlNode *a_node); 43 void processParams(xmlNode *a_node); 44 irr::core::vector3df getMeshVect(xmlNode *mesh_node, xmlChar *param); 45 irr::core::vector3df getSceneVect(xmlNode *mesh_node, xmlChar *param, 46 bool isScale = false); 49 47 }; 50 48 } -
trunk/include/FlairSimulator/SensorGL.h
r9 r13 18 18 #define SENSORGL_H 19 19 20 namespace irr 21 { 22 namespace scene 23 { 24 class ISceneNode; 25 class ISceneCollisionManager; 26 } 20 namespace irr { 21 namespace scene { 22 class ISceneNode; 23 class ISceneCollisionManager; 24 } 27 25 } 28 26 29 namespace flair 30 { 31 namespace simulator 32 { 33 class Model; 34 } 27 namespace flair { 28 namespace simulator { 29 class Model; 30 } 35 31 } 36 32 37 namespace flair 38 { 39 namespace sensor 40 { 41 class SensorGL 42 { 43 public: 44 SensorGL(const simulator::Model *parent); 45 virtual ~SensorGL()=0; 33 namespace flair { 34 namespace sensor { 35 class SensorGL { 36 public: 37 SensorGL(const simulator::Model *parent); 38 virtual ~SensorGL() = 0; 46 39 47 48 49 irr::scene::ISceneCollisionManager*CollMan(void) const;50 irr::scene::ISceneNode*Node(void) const;51 52 53 54 irr::scene::ISceneCollisionManager*collMan;55 irr::scene::ISceneNode*node;56 57 40 protected: 41 #ifdef GL 42 irr::scene::ISceneCollisionManager *CollMan(void) const; 43 irr::scene::ISceneNode *Node(void) const; 44 #endif 45 private: 46 #ifdef GL 47 irr::scene::ISceneCollisionManager *collMan; 48 irr::scene::ISceneNode *node; 49 #endif 50 }; 58 51 } // end namespace sensor 59 52 } // end namespace flair -
trunk/include/FlairSimulator/SimuCameraGL.h
r9 r13 18 18 #include <ISceneNodeAnimator.h> 19 19 20 // in order to get function prototypes from glext.h, define GL_GLEXT_PROTOTYPES before including glext.h 20 // in order to get function prototypes from glext.h, define GL_GLEXT_PROTOTYPES 21 // before including glext.h 21 22 #define GL_GLEXT_PROTOTYPES 22 23 #include <GL/gl.h> 23 24 24 namespace irr 25 { 26 namespace scene 27 { 28 class ICameraSceneNode; 29 } 25 namespace irr { 26 namespace scene { 27 class ICameraSceneNode; 28 } 30 29 } 31 30 32 namespace flair 33 { 34 namespace gui 35 { 36 class DoubleSpinBox; 37 class Vector3DSpinBox; 38 } 39 namespace simulator 40 { 41 class Model; 42 } 31 namespace flair { 32 namespace gui { 33 class DoubleSpinBox; 34 class Vector3DSpinBox; 35 } 36 namespace simulator { 37 class Model; 38 } 43 39 } 44 40 45 namespace flair 46 {47 namespace sensor 48 { 49 /*! \class SimuCameraGL 50 * \brief Class for a simulation camera 51 * 52 */53 class SimuCameraGL : public SimuCamera, public SensorGL, public irr::scene::ISceneNodeAnimator54 { 55 public:56 //top left origin57 SimuCameraGL(const simulator::Model* parent,std::string name,int width,int height,int x,int y,int dev_id);58 59 60 61 41 namespace flair { 42 namespace sensor { 43 /*! \class SimuCameraGL 44 * \brief Class for a simulation camera 45 * 46 */ 47 class SimuCameraGL : public SimuCamera, 48 public SensorGL, 49 public irr::scene::ISceneNodeAnimator { 50 public: 51 // top left origin 52 SimuCameraGL(const simulator::Model *parent, std::string name, int width, 53 int height, int x, int y, int dev_id); 54 ~SimuCameraGL(); 55 //! Sets the value of the near clipping plane. (default: 1.0f) 56 /** \param zn: New z near value. */ 57 void setNearValue(float zn); 62 58 63 64 65 59 //! Sets the value of the far clipping plane (default: 2000.0f) 60 /** \param zf: New z far value. */ 61 void setFarValue(float zf); 66 62 67 private: 68 void UpdateFrom(const core::io_data *data); 69 void animateNode(irr::scene::ISceneNode* node, irr::u32 timeMs); 70 ISceneNodeAnimator* createClone(irr::scene::ISceneNode* node,irr::scene::ISceneManager* newManager=0); 71 void getImage(void); 72 void putImage(char* pixels); 73 irr::scene::ICameraSceneNode* camera; 74 irr::scene::ISceneManager* smgr; 75 gui::Vector3DSpinBox *position,*direction,*up; 76 gui::DoubleSpinBox *fov; 77 int width,height,x,y; 78 char* buffer; 79 bool use_pbo,invert_pixel,disable_output; 80 GLuint *pboIds; 81 int index ; 82 }; 63 private: 64 void UpdateFrom(const core::io_data *data); 65 void animateNode(irr::scene::ISceneNode *node, irr::u32 timeMs); 66 ISceneNodeAnimator *createClone(irr::scene::ISceneNode *node, 67 irr::scene::ISceneManager *newManager = 0); 68 void getImage(void); 69 void putImage(char *pixels); 70 irr::scene::ICameraSceneNode *camera; 71 irr::scene::ISceneManager *smgr; 72 gui::Vector3DSpinBox *position, *direction, *up; 73 gui::DoubleSpinBox *fov; 74 int width, height, x, y; 75 char *buffer; 76 bool use_pbo, invert_pixel, disable_output; 77 GLuint *pboIds; 78 int index; 79 }; 83 80 } // end namespace simulator 84 81 } // end namespace flair -
trunk/include/FlairSimulator/SimuLaserGL.h
r9 r13 17 17 #include <SensorGL.h> 18 18 19 namespace flair 20 { 21 namespace gui 22 { 23 class DoubleSpinBox; 24 class Vector3DSpinBox; 25 } 19 namespace flair { 20 namespace gui { 21 class DoubleSpinBox; 22 class Vector3DSpinBox; 23 } 26 24 } 27 25 28 namespace flair 29 { 30 namespace simulator 31 { 32 class Model; 33 } 26 namespace flair { 27 namespace simulator { 28 class Model; 29 } 34 30 } 35 31 36 namespace flair 37 { 38 namespace sensor 39 { 40 /*! \class SimuUsGL 41 * \brief Class for a simulation us 42 * 43 */ 44 class SimuLaserGL : public SimuLaser, public SensorGL 45 { 46 public: 47 SimuLaserGL(const simulator::Model* parent,std::string name,int dev_id); 48 ~SimuLaserGL(); 32 namespace flair { 33 namespace sensor { 34 /*! \class SimuUsGL 35 * \brief Class for a simulation us 36 * 37 */ 38 class SimuLaserGL : public SimuLaser, public SensorGL { 39 public: 40 SimuLaserGL(const simulator::Model *parent, std::string name, int dev_id); 41 ~SimuLaserGL(); 49 42 50 51 52 53 gui::Vector3DSpinBox *position,*direction;54 43 private: 44 void UpdateFrom(const core::io_data *data); 45 gui::DoubleSpinBox *range; 46 gui::Vector3DSpinBox *position, *direction; 47 }; 55 48 } // end namespace sensor 56 49 } // end namespace flair -
trunk/include/FlairSimulator/SimuUsGL.h
r9 r13 17 17 #include <SensorGL.h> 18 18 19 namespace flair 20 { 21 namespace gui 22 { 23 class DoubleSpinBox; 24 class Vector3DSpinBox; 25 } 19 namespace flair { 20 namespace gui { 21 class DoubleSpinBox; 22 class Vector3DSpinBox; 23 } 26 24 } 27 25 28 namespace flair 29 { 30 namespace simulator 31 { 32 class Model; 33 } 26 namespace flair { 27 namespace simulator { 28 class Model; 29 } 34 30 } 35 31 36 namespace flair 37 { 38 namespace sensor 39 { 40 /*! \class SimuUsGL 41 * \brief Class for a simulation us 42 * 43 */ 44 class SimuUsGL : public SimuUs, public SensorGL 45 { 46 public: 47 SimuUsGL(const simulator::Model* parent,std::string name,int dev_id); 48 ~SimuUsGL(); 32 namespace flair { 33 namespace sensor { 34 /*! \class SimuUsGL 35 * \brief Class for a simulation us 36 * 37 */ 38 class SimuUsGL : public SimuUs, public SensorGL { 39 public: 40 SimuUsGL(const simulator::Model *parent, std::string name, int dev_id); 41 ~SimuUsGL(); 49 42 50 51 52 53 gui::Vector3DSpinBox *position,*direction;54 43 private: 44 void UpdateFrom(const core::io_data *data); 45 gui::DoubleSpinBox *range; 46 gui::Vector3DSpinBox *position, *direction; 47 }; 55 48 } // end namespace sensor 56 49 } // end namespace flair -
trunk/include/FlairSimulator/Simulator.h
r9 r13 24 24 25 25 namespace flair { 26 27 28 29 26 namespace core { 27 class Quaternion; 28 class Vector3D; 29 } 30 30 } 31 31 32 namespace flair 33 { 34 namespace simulator 35 { 36 class Model; 37 class Gui; 32 namespace flair { 33 namespace simulator { 34 class Model; 35 class Gui; 38 36 39 class Simulator: public core::FrameworkManager 40 { 41 friend class Model; 42 friend class Gui; 43 friend class GenericObject; 37 class Simulator : public core::FrameworkManager { 38 friend class Model; 39 friend class Gui; 40 friend class GenericObject; 44 41 45 public: 46 //yaw_deg: rotation of the vrpn coordinate with respect to the earth coordinate, around z axis 47 Simulator(std::string name,int optitrack_mstime=10,float yaw_deg=30); 48 ~Simulator(); 49 void RunSimu(void); 50 //get rotation of the vrpn coordinate with respect to the earth coordinate, around z axis; in radians 51 float Yaw(void) const; 52 //compute rotation of the vrpn coordinate with respect to the earth coordinate, around z axis 53 core::Quaternion ToVRPNReference(core::Quaternion quat_in); 54 core::Vector3D ToVRPNReference(core::Vector3D point_in); 42 public: 43 // yaw_deg: rotation of the vrpn coordinate with respect to the earth 44 // coordinate, around z axis 45 Simulator(std::string name, int optitrack_mstime = 10, float yaw_deg = 30); 46 ~Simulator(); 47 void RunSimu(void); 48 // get rotation of the vrpn coordinate with respect to the earth coordinate, 49 // around z axis; in radians 50 float Yaw(void) const; 51 // compute rotation of the vrpn coordinate with respect to the earth 52 // coordinate, around z axis 53 core::Quaternion ToVRPNReference(core::Quaternion quat_in); 54 core::Vector3D ToVRPNReference(core::Vector3D point_in); 55 55 56 57 Simulator_impl*pimpl_;58 56 private: 57 Simulator_impl *pimpl_; 58 }; 59 59 60 61 62 63 64 65 Simulator*getSimulator(void);60 /*! 61 * \brief get Simulator 62 * 63 * \return the Simulator 64 */ 65 Simulator *getSimulator(void); 66 66 67 67 } // end namespace simulator -
trunk/include/FlairSimulator/X4.h
r9 r13 22 22 #include <stdio.h> 23 23 24 namespace flair 25 { 26 namespace core 27 { 28 class Mutex; 29 } 30 namespace gui 31 { 32 class DoubleSpinBox; 33 } 34 namespace actuator 35 { 36 class SimuBldc; 37 } 24 namespace flair { 25 namespace core { 26 class Mutex; 27 } 28 namespace gui { 29 class DoubleSpinBox; 30 } 31 namespace actuator { 32 class SimuBldc; 33 } 38 34 } 39 35 40 36 #ifdef GL 41 namespace irr 42 { 43 namespace scene 44 { 45 class IMesh; 46 } 37 namespace irr { 38 namespace scene { 39 class IMesh; 40 } 47 41 } 48 42 #endif 49 43 50 namespace flair 51 { 52 namespace simulator 53 { 54 class Simulator; 55 class Blade; 56 class MeshSceneNode; 44 namespace flair { 45 namespace simulator { 46 class Simulator; 47 class Blade; 48 class MeshSceneNode; 57 49 58 class X4 : public Model 59 { 60 public: 61 X4(const Simulator* parent,std::string name, int dev_id); 62 ~X4(); 50 class X4 : public Model { 51 public: 52 X4(const Simulator *parent, std::string name, int dev_id); 53 ~X4(); 63 54 #ifdef GL 64 65 55 virtual void Draw(void); 56 virtual void ExtraDraw(void){}; 66 57 67 68 irr::scene::IMesh *red_arm,*black_arm,*motor;69 MeshSceneNode *fl_arm,*fr_arm,*rl_arm,*rr_arm;70 MeshSceneNode *fl_motor,*fr_motor,*rl_motor,*rr_motor;71 Blade *fl_blade,*fr_blade,*rl_blade,*rr_blade;72 58 protected: 59 irr::scene::IMesh *red_arm, *black_arm, *motor; 60 MeshSceneNode *fl_arm, *fr_arm, *rl_arm, *rr_arm; 61 MeshSceneNode *fl_motor, *fr_motor, *rl_motor, *rr_motor; 62 Blade *fl_blade, *fr_blade, *rl_blade, *rr_blade; 63 core::Mutex *motor_speed_mutex; 73 64 #endif 74 75 76 77 bool OnEvent(const irr::SEvent&event){};78 79 80 void WritedbtBuf(char*dbtbuf);81 void ReaddbtBuf(char*dbtbuf);82 65 private: 66 void CalcModel(void); 67 #ifdef GL 68 bool OnEvent(const irr::SEvent &event){}; 69 void AnimateModel(void); 70 size_t dbtSize(void) const; 71 void WritedbtBuf(char *dbtbuf); 72 void ReaddbtBuf(char *dbtbuf); 73 #endif 83 74 84 85 86 gui::DoubleSpinBox *m,*arm_length,*l_cg;87 gui::DoubleSpinBox *k_mot,*c_mot;88 gui::DoubleSpinBox *f_air_vert,*f_air_lat;89 gui::DoubleSpinBox *j_roll,*j_pitch,*j_yaw;90 75 actuator::SimuBldc *motors; 76 float motor_speed[4]; 77 gui::DoubleSpinBox *m, *arm_length, *l_cg; 78 gui::DoubleSpinBox *k_mot, *c_mot; 79 gui::DoubleSpinBox *f_air_vert, *f_air_lat; 80 gui::DoubleSpinBox *j_roll, *j_pitch, *j_yaw; 81 }; 91 82 } // end namespace simulator 92 83 } // end namespace flair -
trunk/include/FlairSimulator/X8.h
r9 r13 21 21 #include <stdint.h> 22 22 23 namespace flair 24 { 25 namespace core 26 { 27 class Mutex; 28 } 29 namespace gui 30 { 31 class DoubleSpinBox; 32 } 33 namespace actuator 34 { 35 class SimuBldc; 36 } 23 namespace flair { 24 namespace core { 25 class Mutex; 26 } 27 namespace gui { 28 class DoubleSpinBox; 29 } 30 namespace actuator { 31 class SimuBldc; 32 } 37 33 } 38 34 39 35 #ifdef GL 40 namespace irr 41 { 42 namespace scene 43 { 44 class IMesh; 45 } 36 namespace irr { 37 namespace scene { 38 class IMesh; 39 } 46 40 } 47 41 #endif 48 42 49 namespace flair 50 { 51 namespace simulator 52 { 53 class Simulator; 54 class Blade; 55 class MeshSceneNode; 43 namespace flair { 44 namespace simulator { 45 class Simulator; 46 class Blade; 47 class MeshSceneNode; 56 48 57 class X8 : public Model 58 { 59 public:60 X8(const Simulator* parent,std::string name, int dev_id);61 ~X8();62 virtual void Draw(void);63 virtual void ExtraDraw(void){}; 64 49 class X8 : public Model { 50 public: 51 X8(const Simulator *parent, std::string name, int dev_id); 52 ~X8(); 53 virtual void Draw(void); 54 virtual void ExtraDraw(void){}; 55 56 protected: 65 57 #ifdef GL 66 irr::scene::IMesh *red_arm,*black_arm,*motor;67 MeshSceneNode *fl_arm,*fr_arm,*rl_arm,*rr_arm;68 MeshSceneNode *tfl_motor,*tfr_motor,*trl_motor,*trr_motor;69 MeshSceneNode *bfl_motor,*bfr_motor,*brl_motor,*brr_motor;70 Blade *tfl_blade,*tfr_blade,*trl_blade,*trr_blade;71 Blade *bfl_blade,*bfr_blade,*brl_blade,*brr_blade;58 irr::scene::IMesh *red_arm, *black_arm, *motor; 59 MeshSceneNode *fl_arm, *fr_arm, *rl_arm, *rr_arm; 60 MeshSceneNode *tfl_motor, *tfr_motor, *trl_motor, *trr_motor; 61 MeshSceneNode *bfl_motor, *bfr_motor, *brl_motor, *brr_motor; 62 Blade *tfl_blade, *tfr_blade, *trl_blade, *trr_blade; 63 Blade *bfl_blade, *bfr_blade, *brl_blade, *brr_blade; 72 64 #endif 73 74 75 76 bool OnEvent(const irr::SEvent&event){};77 78 79 void WritedbtBuf(char*dbtbuf);80 void ReaddbtBuf(char*dbtbuf);81 82 65 private: 66 void CalcModel(void); 67 #ifdef GL 68 bool OnEvent(const irr::SEvent &event){}; 69 void AnimateModel(void); 70 size_t dbtSize(void) const; 71 void WritedbtBuf(char *dbtbuf); 72 void ReaddbtBuf(char *dbtbuf); 73 core::Mutex *motor_speed_mutex; 74 #endif 83 75 84 85 86 gui::DoubleSpinBox *m,*arm_length,*l_cg;87 gui::DoubleSpinBox *k_mot,*c_mot;88 gui::DoubleSpinBox *f_air_vert,*f_air_lat;89 gui::DoubleSpinBox *j_roll,*j_pitch,*j_yaw;90 gui::DoubleSpinBox *j_r,*sigma,*S;91 76 actuator::SimuBldc *motors; 77 float motor_speed[8]; 78 gui::DoubleSpinBox *m, *arm_length, *l_cg; 79 gui::DoubleSpinBox *k_mot, *c_mot; 80 gui::DoubleSpinBox *f_air_vert, *f_air_lat; 81 gui::DoubleSpinBox *j_roll, *j_pitch, *j_yaw; 82 gui::DoubleSpinBox *j_r, *sigma, *S; 83 }; 92 84 } // end namespace simulator 93 85 } // end namespace flair
Note:
See TracChangeset
for help on using the changeset viewer.