Index: trunk/lib/FlairSimulator/src/AnimPoursuite.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/AnimPoursuite.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/AnimPoursuite.cpp	(revision 15)
@@ -28,121 +28,105 @@
 using namespace scene;
 
-namespace flair
-{
-namespace simulator
-{
+namespace flair {
+namespace simulator {
 
-AnimPoursuite::AnimPoursuite(const ISceneNode* parent,float rotateSpeed , float zoomSpeed )
-{
-    this->parent=parent;
-    this->zoomSpeed=zoomSpeed;
-    this->rotateSpeed=rotateSpeed;
-    currentZoom=100;
-    RotY=20;
-    RotZ=0;
-    Rotating=false;
-    LMouseKey= false;
+AnimPoursuite::AnimPoursuite(const ISceneNode *parent, float rotateSpeed,
+                             float zoomSpeed) {
+  this->parent = parent;
+  this->zoomSpeed = zoomSpeed;
+  this->rotateSpeed = rotateSpeed;
+  currentZoom = 100;
+  RotY = 20;
+  RotZ = 0;
+  Rotating = false;
+  LMouseKey = false;
 }
 
-AnimPoursuite::~AnimPoursuite()
-{
+AnimPoursuite::~AnimPoursuite() {}
 
+void AnimPoursuite::setPositionOffset(vector3df newpos) { pos_offset = newpos; }
+
+void AnimPoursuite::setTargetOffset(vector3df newpos) {
+  target_offset = newpos;
 }
 
-void AnimPoursuite::setPositionOffset(vector3df newpos)
-{
-    pos_offset=newpos;
+float AnimPoursuite::sat(float value) {
+  if (value > 89)
+    value = 89;
+  if (value < -89)
+    value = -89;
+  return value;
 }
 
-void AnimPoursuite::setTargetOffset(vector3df newpos)
-{
-    target_offset=newpos;
+void AnimPoursuite::animateNode(ISceneNode *node, u32 timeMs) {
+  ICameraSceneNode *camera = static_cast<ICameraSceneNode *>(node);
+  vector3df pos;
+
+  float nRotY = RotY;
+  float nRotZ = RotZ;
+
+  if (LMouseKey == true) {
+    if (!Rotating) {
+      RotateStart = MousePos;
+      Rotating = true;
+      nRotY = RotY;
+      nRotZ = RotZ;
+    } else {
+      nRotY += (RotateStart.Y - MousePos.Y) * rotateSpeed;
+      nRotZ += (RotateStart.X - MousePos.X) * rotateSpeed;
+      nRotY = sat(nRotY);
+    }
+  } else if (Rotating) {
+    RotY += (RotateStart.Y - MousePos.Y) * rotateSpeed;
+    RotZ += (RotateStart.X - MousePos.X) * rotateSpeed;
+    RotY = sat(RotY);
+    nRotY = RotY;
+    nRotZ = RotZ;
+    Rotating = false;
+  }
+
+  pos.X = -currentZoom;
+  pos.Y = 0;
+  pos.Z = 0;
+
+  pos.rotateXZBy(-nRotY);
+  pos.rotateXYBy(getSimulator()->Yaw() + nRotZ + parent->getRotation().Z);
+
+  camera->setPosition(parent->getPosition() + pos + pos_offset);
+  camera->setTarget(parent->getPosition() + target_offset);
 }
 
-float AnimPoursuite::sat(float value)
-{
-    if(value>89) value=89;
-    if(value<-89) value=-89;
-    return value;
+ISceneNodeAnimator *AnimPoursuite::createClone(ISceneNode *node,
+                                               ISceneManager *newManager) {
+  return NULL;
 }
 
-void AnimPoursuite::animateNode(ISceneNode* node, u32 timeMs)
-{
-    ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node);
-    vector3df pos;
+bool AnimPoursuite::MouseMoved(const SEvent &event,
+                               irr::core::position2df MousePos) {
+  if (event.EventType != EET_MOUSE_INPUT_EVENT)
+    return false;
 
-    float nRotY = RotY;
-    float nRotZ = RotZ;
+  switch (event.MouseInput.Event) {
 
-    if (LMouseKey==true)
-    {
-        if (!Rotating)
-        {
-            RotateStart = MousePos;
-            Rotating = true;
-            nRotY = RotY;
-            nRotZ = RotZ;
-        }
-        else
-        {
-            nRotY += (RotateStart.Y - MousePos.Y) * rotateSpeed;
-            nRotZ += (RotateStart.X - MousePos.X) * rotateSpeed;
-            nRotY=sat(nRotY);
-        }
-    }
-    else if (Rotating)
-    {
-        RotY += (RotateStart.Y - MousePos.Y) * rotateSpeed;
-        RotZ += (RotateStart.X - MousePos.X) * rotateSpeed;
-        RotY=sat(RotY);
-        nRotY = RotY;
-        nRotZ = RotZ;
-        Rotating = false;
-    }
+  case EMIE_MOUSE_WHEEL:
+    currentZoom -= event.MouseInput.Wheel * zoomSpeed;
+    if (currentZoom <= 0)
+      currentZoom = zoomSpeed;
+    break;
+  case EMIE_LMOUSE_PRESSED_DOWN:
+    LMouseKey = true;
+    break;
+  case EMIE_LMOUSE_LEFT_UP:
+    LMouseKey = false;
+    break;
+  case EMIE_MOUSE_MOVED:
+    this->MousePos = MousePos;
+    break;
+  default:
+    return false;
+    break;
+  }
 
-    pos.X = -currentZoom;
-    pos.Y=0;
-    pos.Z=0;
-
-    pos.rotateXZBy(-nRotY);
-    pos.rotateXYBy(getSimulator()->Yaw()+nRotZ+parent->getRotation().Z);
-
-    camera->setPosition(parent->getPosition()+pos+pos_offset);
-    camera->setTarget(parent->getPosition()+target_offset);
-}
-
-ISceneNodeAnimator* AnimPoursuite::createClone(ISceneNode* node,
-            ISceneManager* newManager)
-{
-    return NULL;
-}
-
-bool AnimPoursuite::MouseMoved(const SEvent& event,irr::core::position2df MousePos)
-{
-    if (event.EventType != EET_MOUSE_INPUT_EVENT)
-        return false;
-
-    switch(event.MouseInput.Event)
-    {
-
-    case EMIE_MOUSE_WHEEL:
-        currentZoom -= event.MouseInput.Wheel * zoomSpeed;
-        if(currentZoom<=0) currentZoom=zoomSpeed;
-        break;
-    case EMIE_LMOUSE_PRESSED_DOWN:
-        LMouseKey = true;
-        break;
-    case EMIE_LMOUSE_LEFT_UP:
-        LMouseKey= false;
-        break;
-    case EMIE_MOUSE_MOVED:
-        this->MousePos = MousePos;
-        break;
-    default:
-        return false;
-        break;
-    }
-
-    return true;
+  return true;
 }
 
@@ -150,3 +134,3 @@
 } // end namespace flair
 
-#endif //GL
+#endif // GL
Index: trunk/lib/FlairSimulator/src/Blade.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/Blade.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/Blade.cpp	(revision 15)
@@ -33,64 +33,59 @@
 using namespace flair::core;
 
-namespace flair
-{
-namespace simulator
-{
+namespace flair {
+namespace simulator {
 
-Blade::Blade(Model* parent,const vector3df& position,bool inverted,s32 id)
-    : ISceneNode(parent->getSceneNode(), getGui()->getSceneManager(), id,position)
-{
-    ISceneManager* mgr=getGui()->getSceneManager();
+Blade::Blade(Model *parent, const vector3df &position, bool inverted, s32 id)
+    : ISceneNode(parent->getSceneNode(), getGui()->getSceneManager(), id,
+                 position) {
+  ISceneManager *mgr = getGui()->getSceneManager();
 
-    const IGeometryCreator *geo;
-    geo=mgr->getGeometryCreator();
-    pale=geo->createCubeMesh(vector3df(63.5,0.5,5));
+  const IGeometryCreator *geo;
+  geo = mgr->getGeometryCreator();
+  pale = geo->createCubeMesh(vector3df(63.5, 0.5, 5));
 
-    float angle;
-    if(inverted==false)
-    {
-        angle=20;
-    }
-    else
-    {
-        angle=-20;
-    }
+  float angle;
+  if (inverted == false) {
+    angle = 20;
+  } else {
+    angle = -20;
+  }
 
-    ITexture* texture=getGui()->getTexture("carbone.jpg");
-    pale_1=new MeshSceneNode(parent, pale, vector3df(-30,0,0),vector3df(-angle+90,0,0),texture);
-    pale_1->setParent(this);
-    pale_2=new MeshSceneNode(parent, pale, vector3df(30,0,0),vector3df(angle+90,0,0),texture);
-    pale_2->setParent(this);
+  ITexture *texture = getGui()->getTexture("carbone.jpg");
+  pale_1 = new MeshSceneNode(parent, pale, vector3df(-30, 0, 0),
+                             vector3df(-angle + 90, 0, 0), texture);
+  pale_1->setParent(this);
+  pale_2 = new MeshSceneNode(parent, pale, vector3df(30, 0, 0),
+                             vector3df(angle + 90, 0, 0), texture);
+  pale_2->setParent(this);
 
-    anim = mgr->createRotationAnimator(vector3df(0.f, 0.f, 0.f));
-    addAnimator(anim);
+  anim = mgr->createRotationAnimator(vector3df(0.f, 0.f, 0.f));
+  addAnimator(anim);
 }
 
-void Blade::OnRegisterSceneNode()
-{
-    if (IsVisible)
-        SceneManager->registerNodeForRendering(this);
+void Blade::OnRegisterSceneNode() {
+  if (IsVisible)
+    SceneManager->registerNodeForRendering(this);
 
-    ISceneNode::OnRegisterSceneNode();
+  ISceneNode::OnRegisterSceneNode();
 }
 
-void Blade::SetRotationSpeed(float value)
-{
-    IAttributes* attribs =getSceneManager()->getFileSystem()->createEmptyAttributes();
+void Blade::SetRotationSpeed(float value) {
+  IAttributes *attribs =
+      getSceneManager()->getFileSystem()->createEmptyAttributes();
 
-    attribs->setAttribute("Type","rotation");
-    attribs->setAttribute("Rotation",vector3df(0.f, 0.f,value));
-    anim->deserializeAttributes(attribs);
+  attribs->setAttribute("Type", "rotation");
+  attribs->setAttribute("Rotation", vector3df(0.f, 0.f, value));
+  anim->deserializeAttributes(attribs);
 
-    attribs->drop();
+  attribs->drop();
 }
 
-void Blade::render()
-{
-    IVideoDriver* driver = SceneManager->getVideoDriver();
-    driver->setTransform(ETS_WORLD, AbsoluteTransformation);
+void Blade::render() {
+  IVideoDriver *driver = SceneManager->getVideoDriver();
+  driver->setTransform(ETS_WORLD, AbsoluteTransformation);
 }
 
 } // end namespace simulator
 } // end namespace flair
-#endif //GL
+#endif // GL
Index: trunk/lib/FlairSimulator/src/Blade.h
===================================================================
--- trunk/lib/FlairSimulator/src/Blade.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/Blade.h	(revision 15)
@@ -20,39 +20,33 @@
 #include <ISceneNode.h>
 
-namespace irr
-{
-    namespace scene
-    {
-        class IMesh;
-    }
+namespace irr {
+namespace scene {
+class IMesh;
+}
 }
 
-namespace flair
-{
-namespace simulator
-{
-    class MeshSceneNode;
-    class Model;
+namespace flair {
+namespace simulator {
+class MeshSceneNode;
+class Model;
 
-    class Blade : public irr::scene::ISceneNode
-    {
-        public:
+class Blade : public irr::scene::ISceneNode {
+public:
+  Blade(Model *parent,
+        const irr::core::vector3df &position = irr::core::vector3df(0, 0, 0),
+        bool inverted = false, irr::s32 id = -1);
+  virtual void OnRegisterSceneNode(void);
+  virtual void render(void);
+  virtual const irr::core::aabbox3d<irr::f32> &getBoundingBox(void) const {
+    return Box;
+  }
+  void SetRotationSpeed(float value);
 
-            Blade(Model* parent,const irr::core::vector3df& position = irr::core::vector3df(0,0,0),bool inverted=false,irr::s32 id=-1);
-            virtual void OnRegisterSceneNode(void);
-            virtual void render(void);
-            virtual const irr::core::aabbox3d<irr::f32>& getBoundingBox(void) const
-            {
-                return Box;
-            }
-            void SetRotationSpeed(float value);
-
-
-        private:
-            irr::scene::IMesh *pale;
-            irr::core::aabbox3d<irr::f32> Box;
-            MeshSceneNode *pale_1,*pale_2;
-            irr::scene::ISceneNodeAnimator *anim;
-    };
+private:
+  irr::scene::IMesh *pale;
+  irr::core::aabbox3d<irr::f32> Box;
+  MeshSceneNode *pale_1, *pale_2;
+  irr::scene::ISceneNodeAnimator *anim;
+};
 } // end namespace simulator
 } // end namespace flair
Index: trunk/lib/FlairSimulator/src/Castle.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/Castle.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/Castle.cpp	(revision 15)
@@ -24,23 +24,20 @@
 using namespace flair::core;
 
-namespace flair
-{
-namespace simulator
-{
+namespace flair {
+namespace simulator {
 
-Castle::Castle(const Simulator* parent,int app_width, int app_height,int scene_width, int scene_height,std::string media_path): Gui(parent,"Castle",app_width,app_height,scene_width,scene_height, media_path)
-{
-    //carte
-    std::string file=media_path +"/map-20kdm2.pk3";
-	getDevice()->getFileSystem()->addFileArchive(file.c_str());
-	setMesh("20kdm2.bsp",vector3df(-1400,-65,-1349));
+Castle::Castle(const Simulator *parent, int app_width, int app_height,
+               int scene_width, int scene_height, std::string media_path)
+    : Gui(parent, "Castle", app_width, app_height, scene_width, scene_height,
+          media_path) {
+  // carte
+  std::string file = media_path + "/map-20kdm2.pk3";
+  getDevice()->getFileSystem()->addFileArchive(file.c_str());
+  setMesh("20kdm2.bsp", vector3df(-1400, -65, -1349));
 }
 
-Castle::~Castle()
-{
-
-}
+Castle::~Castle() {}
 
 } // end namespace simulator
 } // end namespace flair
-#endif //GL
+#endif // GL
Index: trunk/lib/FlairSimulator/src/Castle.h
===================================================================
--- trunk/lib/FlairSimulator/src/Castle.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/Castle.h	(revision 15)
@@ -19,17 +19,15 @@
 
 #include <Gui.h>
-namespace flair
-{
-namespace simulator
-{
-    class Castle:public Gui
-    {
-        public:
-            Castle(const flair::simulator::Simulator* parent,int app_width, int app_height,int scene_width, int scene_height,std::string media_path);
-            ~Castle();
+namespace flair {
+namespace simulator {
+class Castle : public Gui {
+public:
+  Castle(const flair::simulator::Simulator *parent, int app_width,
+         int app_height, int scene_width, int scene_height,
+         std::string media_path);
+  ~Castle();
 
-        private:
-
-    };
+private:
+};
 } // end namespace simulator
 } // end namespace flair
Index: trunk/lib/FlairSimulator/src/DiscreteTimeVariable.h
===================================================================
--- trunk/lib/FlairSimulator/src/DiscreteTimeVariable.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/DiscreteTimeVariable.h	(revision 15)
@@ -20,36 +20,29 @@
 #include <stdlib.h>
 
-namespace flair
-{
-namespace simulator
-{
-    template <typename T,size_t size>
-    class DiscreteTimeVariable
-    {
-        public:
-            DiscreteTimeVariable(){};
-            ~DiscreteTimeVariable(){};
-            T& operator[](ssize_t idx)
-            {
-                if(idx>0) idx=0;
-                if(idx<(ssize_t)(-size+1)) idx=-size+1;
-                return array[-idx];
-            }
-            const T&operator[](ssize_t idx) const
-            {
-                return const_cast<T&>(*this)[idx];
-            };
-            void Update(void)
-            {
-                for(int i=size-1;i>0;i--)
-                {
-                    array[i]=array[i-1];
-                }
-            }
+namespace flair {
+namespace simulator {
+template <typename T, size_t size> class DiscreteTimeVariable {
+public:
+  DiscreteTimeVariable(){};
+  ~DiscreteTimeVariable(){};
+  T &operator[](ssize_t idx) {
+    if (idx > 0)
+      idx = 0;
+    if (idx < (ssize_t)(-size + 1))
+      idx = -size + 1;
+    return array[-idx];
+  }
+  const T &operator[](ssize_t idx) const {
+    return const_cast<T &>(*this)[idx];
+  };
+  void Update(void) {
+    for (int i = size - 1; i > 0; i--) {
+      array[i] = array[i - 1];
+    }
+  }
 
-        private:
-            T array[size];
-
-    };
+private:
+  T array[size];
+};
 } // end namespace simulator
 } // end namespace flair
Index: trunk/lib/FlairSimulator/src/GenericObject.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/GenericObject.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/GenericObject.cpp	(revision 15)
@@ -37,88 +37,72 @@
 using namespace flair::simulator;
 
-namespace flair
+namespace flair {
+namespace simulator {
+
+GenericObject::GenericObject(Simulator *parent, std::string name,
+                             ISceneManager *sceneManager)
+    : IMeshSceneNode(sceneManager->getRootSceneNode(), sceneManager,
+                     -1) //, IODevice(parent,name)
 {
-namespace simulator
-{
+  setMaterialFlag(EMF_LIGHTING, false);
+  Material = getMaterial(0);
+  // setMaterialTexture(0,sceneManager->getVideoDriver()->getTexture("/home/cesar/igep/uav_dev_svn/trunk/media/nskinbl.jpg"));
+  Material.NormalizeNormals = true;
+  Material.Wireframe = false;
+  Material.Lighting = false;
 
-GenericObject::GenericObject(Simulator* parent,std::string name, ISceneManager* sceneManager) : IMeshSceneNode(sceneManager->getRootSceneNode(), sceneManager, -1)//, IODevice(parent,name)
-{
-    setMaterialFlag(EMF_LIGHTING,false);
-    Material=getMaterial(0);
-    //setMaterialTexture(0,sceneManager->getVideoDriver()->getTexture("/home/cesar/igep/uav_dev_svn/trunk/media/nskinbl.jpg"));
-    Material.NormalizeNormals = true;
-    Material.Wireframe = false;
-    Material.Lighting = false;
-
-    parent->pimpl_->objects.push_back(this);
+  parent->pimpl_->objects.push_back(this);
 }
 
-GenericObject::~GenericObject()
-{
+GenericObject::~GenericObject() {}
 
+void GenericObject::setScale(float value) {
+  ISceneNode::setScale(vector3df(value, value, value));
 }
 
-void GenericObject::setScale(float value)
-{
-    ISceneNode::setScale(vector3df(value,value,value));
+void GenericObject::setScale(vector3df scale) { ISceneNode::setScale(scale); }
+
+ITriangleSelector *GenericObject::TriangleSelector(void) { return selector; }
+
+void GenericObject::OnRegisterSceneNode(void) {
+  if (IsVisible)
+    SceneManager->registerNodeForRendering(this);
+
+  ISceneNode::OnRegisterSceneNode();
 }
 
-void GenericObject::setScale(vector3df scale)
-{
-    ISceneNode::setScale(scale);
+void GenericObject::render(void) {
+  IVideoDriver *driver = SceneManager->getVideoDriver();
+
+  driver->setMaterial(Material);
+
+  driver->setTransform(ETS_WORLD, AbsoluteTransformation);
+  driver->drawMeshBuffer(mesh->getMeshBuffer(0));
 }
 
-ITriangleSelector* GenericObject::TriangleSelector(void)
-{
-    return selector;
+void GenericObject::setMesh(IMesh *mesh) {
+  this->mesh = mesh;
+  box = mesh->getBoundingBox();
+
+  selector = getSceneManager()->createTriangleSelector(mesh, this);
+  setTriangleSelector(selector);
 }
 
-void GenericObject::OnRegisterSceneNode(void)
-{
-    if (IsVisible)
-        SceneManager->registerNodeForRendering(this);
+IMesh *GenericObject::getMesh(void) { return mesh; }
 
-    ISceneNode::OnRegisterSceneNode();
+void GenericObject::setPosition(irr::core::vector3df pos) {
+  ISceneNode::setPosition(ToIrrlichtCoordinates(pos));
 }
 
-void GenericObject::render(void)
-{
-    IVideoDriver* driver = SceneManager->getVideoDriver();
+void GenericObject::setRotation(irr::core::vector3df rotation) {
+  Euler eulerA(rotation.X, rotation.Y, rotation.Z);
+  Euler eulerB;
+  Quaternion quatA, quatB;
+  eulerA.ToQuaternion(quatA);
+  quatB = ToIrrlichtOrientation(quatA);
+  quatB.ToEuler(eulerB);
 
-    driver->setMaterial(Material);
-
-    driver->setTransform(ETS_WORLD, AbsoluteTransformation);
-    driver->drawMeshBuffer(mesh->getMeshBuffer(0));
-}
-
-void GenericObject::setMesh(IMesh* mesh)
-{
-    this->mesh=mesh;
-    box=mesh->getBoundingBox();
-
-    selector = getSceneManager()->createTriangleSelector(mesh,this);
-    setTriangleSelector(selector);
-}
-
-IMesh* GenericObject::getMesh(void)
-{
-    return mesh;
-}
-
-void GenericObject::setPosition(irr::core::vector3df pos)
-{
-    ISceneNode::setPosition(ToIrrlichtCoordinates(pos));
-}
-
-void GenericObject::setRotation(irr::core::vector3df rotation)
-{
-    Euler eulerA(rotation.X,rotation.Y,rotation.Z);
-    Euler eulerB;
-    Quaternion quatA,quatB;
-    eulerA.ToQuaternion(quatA);
-    quatB=ToIrrlichtOrientation(quatA);
-    quatB.ToEuler(eulerB);
-
-    ISceneNode::setRotation(Euler::ToDegree(1)*vector3df(eulerB.roll,eulerB.pitch,eulerB.yaw));
+  ISceneNode::setRotation(Euler::ToDegree(1) *
+                          vector3df(eulerB.roll, eulerB.pitch, eulerB.yaw));
 }
 
Index: trunk/lib/FlairSimulator/src/Gui.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/Gui.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/Gui.cpp	(revision 15)
@@ -40,140 +40,134 @@
 
 namespace {
-    flair::simulator::Gui* gui_=NULL;
-    std::vector <std::string> extensions;
-    bool getGlInfo();
+flair::simulator::Gui *gui_ = NULL;
+std::vector<std::string> extensions;
+bool getGlInfo();
 }
 
-namespace flair { namespace simulator {
+namespace flair {
+namespace simulator {
 
-Gui* getGui(void) {
-    return gui_;
+Gui *getGui(void) { return gui_; }
+
+bool noGui(void) {
+  if (gui_ == NULL) {
+    return true;
+  } else {
+    return false;
+  }
 }
 
-bool noGui(void) {
-    if(gui_==NULL) {
-        return true;
-    } else {
-        return false;
+// getGlinfo, code from Song Ho Ahn (song.ahn@gmail.com)
+bool getGlInfo() {
+  char *str = 0;
+  char *tok = 0;
+
+  // get all extensions as a string
+  str = (char *)glGetString(GL_EXTENSIONS);
+
+  // split extensions
+  if (str) {
+    tok = strtok((char *)str, " ");
+    while (tok) {
+      extensions.push_back(tok); // put a extension into struct
+      tok = strtok(0, " ");      // next token
     }
+  } else {
+    printf("cannot get gl extensions\n");
+  }
+
+  // sort extension by alphabetical order
+  std::sort(extensions.begin(), extensions.end());
 }
 
-//getGlinfo, code from Song Ho Ahn (song.ahn@gmail.com)
-bool getGlInfo() {
-    char* str = 0;
-    char* tok = 0;
+// isGlExtensionSupported, code from Song Ho Ahn (song.ahn@gmail.com)
+bool isGlExtensionSupported(const std::string &ext) {
+  if (extensions.size() == 0)
+    getGlInfo();
 
-    // get all extensions as a string
-    str = (char*)glGetString(GL_EXTENSIONS);
+  // search corresponding extension
+  std::vector<std::string>::const_iterator iter = extensions.begin();
+  std::vector<std::string>::const_iterator endIter = extensions.end();
 
-    // split extensions
-    if(str) {
-        tok = strtok((char*)str, " ");
-        while(tok) {
-            extensions.push_back(tok);    // put a extension into struct
-            tok = strtok(0, " ");               // next token
-        }
-    } else {
-        printf("cannot get gl extensions\n");
-    }
-
-    // sort extension by alphabetical order
-    std::sort(extensions.begin(), extensions.end());
+  while (iter != endIter) {
+    if (ext == *iter)
+      return true;
+    else
+      ++iter;
+  }
+  return false;
 }
 
-//isGlExtensionSupported, code from Song Ho Ahn (song.ahn@gmail.com)
-bool isGlExtensionSupported(const std::string& ext) {
-    if(extensions.size()==0) getGlInfo();
+float ToIrrlichtScale(float value) { return value * 100.; }
 
-    // search corresponding extension
-    std::vector<std::string>::const_iterator iter = extensions.begin();
-    std::vector<std::string>::const_iterator endIter = extensions.end();
-
-    while(iter != endIter) {
-        if(ext == *iter)
-            return true;
-        else
-            ++iter;
-    }
-    return false;
-}
-
-float ToIrrlichtScale(float value) {
-    return value*100.;
-}
-
-float ToSimulatorScale(float value) {
-    return value/100.;
-}
+float ToSimulatorScale(float value) { return value / 100.; }
 
 vector3df ToIrrlichtCoordinates(vector3df vect) {
-    return ToIrrlichtScale(1)*vector3df(vect.X,vect.Y,-vect.Z);
+  return ToIrrlichtScale(1) * vector3df(vect.X, vect.Y, -vect.Z);
 }
 
 vector3df ToIrrlichtCoordinates(Vector3D vect) {
-    return ToIrrlichtScale(1)*vector3df(vect.x,vect.y,-vect.z);
+  return ToIrrlichtScale(1) * vector3df(vect.x, vect.y, -vect.z);
 }
 
 Vector3D ToSimulatorCoordinates(vector3df vect) {
-    return ToSimulatorScale(1)*Vector3D(vect.X,vect.Y,-vect.Z);
+  return ToSimulatorScale(1) * Vector3D(vect.X, vect.Y, -vect.Z);
 }
 
 Quaternion ToIrrlichtOrientation(Quaternion quat) {
-    /* original code
-    Euler euler;
-    quat.ToEuler(euler);
-    matrix4 m;
-    m.setRotationRadians(vector3df(0, 0, euler.yaw));
-    matrix4 n;
-    n.setRotationRadians(vector3df(0, -euler.pitch,0));
-    m *= n;
-    n.setRotationRadians(vector3df(-euler.roll, 0, 0));
-    m *= n;
-    */
-    //seems to be equivalent to:
-    return Quaternion(quat.q0,-quat.q1,-quat.q2,quat.q3);
+  /* original code
+  Euler euler;
+  quat.ToEuler(euler);
+  matrix4 m;
+  m.setRotationRadians(vector3df(0, 0, euler.yaw));
+  matrix4 n;
+  n.setRotationRadians(vector3df(0, -euler.pitch,0));
+  m *= n;
+  n.setRotationRadians(vector3df(-euler.roll, 0, 0));
+  m *= n;
+  */
+  // seems to be equivalent to:
+  return Quaternion(quat.q0, -quat.q1, -quat.q2, quat.q3);
 }
 
-Gui::Gui(const Simulator* parent,std::string name,int app_width, int app_height,int scene_width, int scene_height,std::string media_path,E_DRIVER_TYPE driver_type): Object(parent,name,"Gui") {
-    if(gui_!=NULL) Err("Gui should be instanced only one time\n");
-    pimpl_=new Gui_impl(this,app_width,app_height,scene_width,scene_height,media_path,driver_type);
-    gui_=this;
+Gui::Gui(const Simulator *parent, std::string name, int app_width,
+         int app_height, int scene_width, int scene_height,
+         std::string media_path, E_DRIVER_TYPE driver_type)
+    : Object(parent, name, "Gui") {
+  if (gui_ != NULL)
+    Err("Gui should be instanced only one time\n");
+  pimpl_ = new Gui_impl(this, app_width, app_height, scene_width, scene_height,
+                        media_path, driver_type);
+  gui_ = this;
 }
 
-Gui::~Gui() {
-    delete pimpl_;
+Gui::~Gui() { delete pimpl_; }
+
+float Gui::getAspectRatio(void) const {
+  return (float)pimpl_->scene_width / (float)pimpl_->scene_height;
 }
 
-float Gui::getAspectRatio(void) const {
-    return (float)pimpl_->scene_width/(float)pimpl_->scene_height;
+ISceneManager *Gui::getSceneManager(void) const { return pimpl_->smgr; }
+
+void Gui::setMesh(std::string file, vector3df position, vector3df rotation,
+                  vector3df scale) {
+  pimpl_->setMesh(file, position, rotation, scale);
 }
 
-ISceneManager* Gui::getSceneManager(void) const {
-    return pimpl_->smgr;
+vector3df Gui::getRotation(void) const { return pimpl_->node->getRotation(); }
+
+IrrlichtDevice *Gui::getDevice(void) const { return pimpl_->device; }
+
+ITexture *Gui::getTexture(std::string filename) const {
+  filename = pimpl_->media_path + "/" + filename;
+  return pimpl_->driver->getTexture(filename.c_str());
 }
 
-void Gui::setMesh(std::string file,vector3df position,vector3df rotation,vector3df scale) {
-    pimpl_->setMesh(file,position,rotation,scale);
-}
-
-vector3df Gui::getRotation(void) const {
-    return pimpl_->node->getRotation();
-}
-
-IrrlichtDevice *Gui::getDevice(void) const {
-    return pimpl_->device;
-}
-
-ITexture* Gui::getTexture(std::string filename) const {
-    filename=pimpl_->media_path+ "/" +filename;
-    return pimpl_->driver->getTexture(filename.c_str());
-}
-
-IAnimatedMesh* Gui::getMesh(std::string filename) const {
-    filename=pimpl_->media_path+ "/" +filename;
-    return pimpl_->smgr->getMesh(filename.c_str());
+IAnimatedMesh *Gui::getMesh(std::string filename) const {
+  filename = pimpl_->media_path + "/" + filename;
+  return pimpl_->smgr->getMesh(filename.c_str());
 }
 
 } // end namespace simulator
 } // end namespace flair
-#endif //GL
+#endif // GL
Index: trunk/lib/FlairSimulator/src/Gui.h
===================================================================
--- trunk/lib/FlairSimulator/src/Gui.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/Gui.h	(revision 15)
@@ -22,27 +22,22 @@
 #include <vector3d.h>
 
-namespace irr
-{
-    class IrrlichtDevice;
-    namespace video
-    {
-        class ITexture;
-    }
-    namespace scene
-    {
-        class IAnimatedMesh;
-        class ISceneManager;
-    }
+namespace irr {
+class IrrlichtDevice;
+namespace video {
+class ITexture;
+}
+namespace scene {
+class IAnimatedMesh;
+class ISceneManager;
+}
 }
 
-namespace flair
-{
-    namespace core
-    {
-       class Object;
-       class Vector3D;
-       class Euler;
-       class Quaternion;
-    }
+namespace flair {
+namespace core {
+class Object;
+class Vector3D;
+class Euler;
+class Quaternion;
+}
 }
 
@@ -51,103 +46,106 @@
 class Model_impl;
 
-namespace flair
-{
-namespace simulator
-{
-    class Simulator;
+namespace flair {
+namespace simulator {
+class Simulator;
 
-    class Gui: public core::Object
-    {
-        friend class ::Simulator_impl;
+class Gui : public core::Object {
+  friend class ::Simulator_impl;
 
-        public:
-            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);
-            ~Gui();
-            irr::core::vector3df getRotation(void) const;
-            irr::video::ITexture* getTexture(std::string filename) const;
-            irr::scene::IAnimatedMesh* getMesh(std::string filename) const;
-            irr::scene::ISceneManager* getSceneManager(void) const;
-            float getAspectRatio(void) const;
+public:
+  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);
+  ~Gui();
+  irr::core::vector3df getRotation(void) const;
+  irr::video::ITexture *getTexture(std::string filename) const;
+  irr::scene::IAnimatedMesh *getMesh(std::string filename) const;
+  irr::scene::ISceneManager *getSceneManager(void) const;
+  float getAspectRatio(void) const;
 
-        protected:
-            irr::IrrlichtDevice *getDevice(void) const;
-            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));
+protected:
+  irr::IrrlichtDevice *getDevice(void) const;
+  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));
 
-        private:
-            Gui_impl *pimpl_;
-    };
+private:
+  Gui_impl *pimpl_;
+};
 
-    /*!
-    * \brief get Gui
-    *
-    * \return the Gui
-    */
-    Gui* getGui(void);
+/*!
+* \brief get Gui
+*
+* \return the Gui
+*/
+Gui *getGui(void);
 
-    bool noGui(void);
+bool noGui(void);
 
-    bool isGlExtensionSupported(const std::string& ext); // check if a extension is supported
+bool isGlExtensionSupported(
+    const std::string &ext); // check if a extension is supported
 
-    /*!
-    * \brief Convert to irrlicht scale
-    *
-    * \param value value in simulator scale
-    *
-    * \return value in irrlicht scale
-    */
-    float ToIrrlichtScale(float value);
+/*!
+* \brief Convert to irrlicht scale
+*
+* \param value value in simulator scale
+*
+* \return value in irrlicht scale
+*/
+float ToIrrlichtScale(float value);
 
-    /*!
-    * \brief Convert to simulator scale
-    *
-    * \param value value in irrlicht scale
-    *
-    * \return value in simulator scale
-    */
-    float ToSimulatorScale(float value);
+/*!
+* \brief Convert to simulator scale
+*
+* \param value value in irrlicht scale
+*
+* \return value in simulator scale
+*/
+float ToSimulatorScale(float value);
 
-    /*!
-    * \brief Convert to irrlicht coordinates
-    *
-    * irrlicht is left handed and as a different scale
-    *
-    * \param vect vector in simulator coordinates
-    *
-    * \return vector in irrlicht coordinates
-    */
-    irr::core::vector3df ToIrrlichtCoordinates(irr::core::vector3df vect);
+/*!
+* \brief Convert to irrlicht coordinates
+*
+* irrlicht is left handed and as a different scale
+*
+* \param vect vector in simulator coordinates
+*
+* \return vector in irrlicht coordinates
+*/
+irr::core::vector3df ToIrrlichtCoordinates(irr::core::vector3df vect);
 
-    /*!
-    * \brief Convert to irrlicht coordinates
-    *
-    * irrlicht is left handed and as a different scale
-    *
-    * \param vect vector in simulator coordinates
-    *
-    * \return vector in irrlicht coordinates
-    */
-    irr::core::vector3df ToIrrlichtCoordinates(core::Vector3D vect);
+/*!
+* \brief Convert to irrlicht coordinates
+*
+* irrlicht is left handed and as a different scale
+*
+* \param vect vector in simulator coordinates
+*
+* \return vector in irrlicht coordinates
+*/
+irr::core::vector3df ToIrrlichtCoordinates(core::Vector3D vect);
 
-    /*!
-    * \brief Convert to simulator coordinates
-    *
-    * irrlicht is left handed and as a different scale
-    *
-    * \param vect vector in irrlicht coordinates
-    *
-    * \return vector in simulator coordinates
-    */
-    core::Vector3D ToSimulatorCoordinates(irr::core::vector3df vect);
+/*!
+* \brief Convert to simulator coordinates
+*
+* irrlicht is left handed and as a different scale
+*
+* \param vect vector in irrlicht coordinates
+*
+* \return vector in simulator coordinates
+*/
+core::Vector3D ToSimulatorCoordinates(irr::core::vector3df vect);
 
-    /*!
-    * \brief Convert to irrlicht orientation
-    *
-    * irrlicht is left handed
-    *
-    * \param quat quaternion in simulator frame
-    *
-    * \return quaternion in irrlicht frame
-    */
-    core::Quaternion ToIrrlichtOrientation(core::Quaternion quat);
+/*!
+* \brief Convert to irrlicht orientation
+*
+* irrlicht is left handed
+*
+* \param quat quaternion in simulator frame
+*
+* \return quaternion in irrlicht frame
+*/
+core::Quaternion ToIrrlichtOrientation(core::Quaternion quat);
 
 } // end namespace simulator
Index: trunk/lib/FlairSimulator/src/Gui_impl.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/Gui_impl.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/Gui_impl.cpp	(revision 15)
@@ -37,394 +37,362 @@
 using namespace flair::simulator;
 
-class MyEventReceiver : public IEventReceiver
-{
+class MyEventReceiver : public IEventReceiver {
 public:
-	// This is the one method that we have to implement
-	virtual bool OnEvent(const SEvent& event)
-	{
-		// Remember whether each key is down or up
-		if (event.EventType == EET_KEY_INPUT_EVENT )
-			KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
-
-		//Send all other events to camera
-		if (event.EventType == EET_MOUSE_INPUT_EVENT && camera)
-			//return camera->OnEvent(event);
-			return camera->MouseMoved(event,cursorControl->getRelativePosition());
-
-		if(model)
-			return model->OnEvent(event);
-
-		return false;
-	}
-
-	// This is used to check whether a key is being held down
-	virtual bool IsKeyDown(EKEY_CODE keyCode)
-	{
-		if(KeyIsDown[keyCode]==true)
-		{
-			KeyIsDown[keyCode]=false;
-			return true;
-		}
-		else
-		{
-			return false;
-		}
-	}
-
-	MyEventReceiver(ICursorControl* cursorControl)
-	{
-		this->cursorControl=cursorControl;
-		camera=NULL;
-		model=NULL;
-		for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
-			KeyIsDown[i] = false;
-	}
-	void SetCamera(AnimPoursuite* camera)
-	{
-		this->camera=camera;
-	}
-	void SetModel(Model* model)
-	{
-		this->model=model;
-	}
+  // This is the one method that we have to implement
+  virtual bool OnEvent(const SEvent &event) {
+    // Remember whether each key is down or up
+    if (event.EventType == EET_KEY_INPUT_EVENT)
+      KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
+
+    // Send all other events to camera
+    if (event.EventType == EET_MOUSE_INPUT_EVENT && camera)
+      // return camera->OnEvent(event);
+      return camera->MouseMoved(event, cursorControl->getRelativePosition());
+
+    if (model)
+      return model->OnEvent(event);
+
+    return false;
+  }
+
+  // This is used to check whether a key is being held down
+  virtual bool IsKeyDown(EKEY_CODE keyCode) {
+    if (KeyIsDown[keyCode] == true) {
+      KeyIsDown[keyCode] = false;
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  MyEventReceiver(ICursorControl *cursorControl) {
+    this->cursorControl = cursorControl;
+    camera = NULL;
+    model = NULL;
+    for (u32 i = 0; i < KEY_KEY_CODES_COUNT; ++i)
+      KeyIsDown[i] = false;
+  }
+  void SetCamera(AnimPoursuite *camera) { this->camera = camera; }
+  void SetModel(Model *model) { this->model = model; }
 
 private:
-	// We use this array to store the current state of each key
-	bool KeyIsDown[KEY_KEY_CODES_COUNT];
-	AnimPoursuite* camera;
-	Model* model;
-	ICursorControl* cursorControl;
+  // We use this array to store the current state of each key
+  bool KeyIsDown[KEY_KEY_CODES_COUNT];
+  AnimPoursuite *camera;
+  Model *model;
+  ICursorControl *cursorControl;
 };
 
-Gui_impl::Gui_impl(Gui* self,int app_width, int app_height,int scene_width, int scene_height,std::string media_path,E_DRIVER_TYPE driver_type)
-{
-	this->self=self;
-	dbtFile_w=NULL;
-	dbtFile_r=NULL;
-	this->media_path=media_path;
-	this->scene_width=scene_width;
-	this->scene_height=scene_height;
-
-	device =createDevice(driver_type, dimension2d<u32>(app_width, app_height),16, false, false, false);
-	receiver=new MyEventReceiver(device->getCursorControl());
-	device->setEventReceiver(receiver);
-	device->getLogger()->setLogLevel(ELL_NONE);
-
-	device->getCursorControl()->setVisible(false);
-	device->setResizable(false);
-
-	//font = device->getGUIEnvironment()->getBuiltInFont();
-	driver = device->getVideoDriver();
-	smgr = device->getSceneManager();
-
-	smgr->setAmbientLight(video::SColorf(1,1,1));
-
-
-	/*
-    env = device->getGUIEnvironment();
+Gui_impl::Gui_impl(Gui *self, int app_width, int app_height, int scene_width,
+                   int scene_height, std::string media_path,
+                   E_DRIVER_TYPE driver_type) {
+  this->self = self;
+  dbtFile_w = NULL;
+  dbtFile_r = NULL;
+  this->media_path = media_path;
+  this->scene_width = scene_width;
+  this->scene_height = scene_height;
+
+  device = createDevice(driver_type, dimension2d<u32>(app_width, app_height),
+                        16, false, false, false);
+  receiver = new MyEventReceiver(device->getCursorControl());
+  device->setEventReceiver(receiver);
+  device->getLogger()->setLogLevel(ELL_NONE);
+
+  device->getCursorControl()->setVisible(false);
+  device->setResizable(false);
+
+  // font = device->getGUIEnvironment()->getBuiltInFont();
+  driver = device->getVideoDriver();
+  smgr = device->getSceneManager();
+
+  smgr->setAmbientLight(video::SColorf(1, 1, 1));
+
+  /*
+env = device->getGUIEnvironment();
 IGUISkin* skin = env->getSkin();
-	font = env->getFont("./fonthaettenschweiler.bmp");
-
-	if (font)
-		skin->setFont(font);
-
-	// create menu
-
-	IGUIContextMenu* menu = env->addMenu();
-	menu->setMinSize(core::dimension2du(640,20));
-	menu->addItem(L"File", -1, true, true);
-	menu->addItem(L"View", -1, true, true);
-	menu->addItem(L"Camera", -1, true, true);
-	menu->addItem(L"Help", -1, true, true);
-
-	// disable alpha
-
-	for (s32 i=0; i<gui::EGDC_COUNT ; ++i)
-	{
-		video::SColor col = env->getSkin()->getColor((gui::EGUI_DEFAULT_COLOR)i);
-		col.setAlpha(255);
-		env->getSkin()->setColor((gui::EGUI_DEFAULT_COLOR)i, col);
-	}
-	 */
-}
-
-Gui_impl::~Gui_impl()
-{
-	//printf("del Gui_impl\n");
-	device->drop();
-
-	delete receiver;
-	// printf("del Gui_impl ok\n");
-}
-
-void Gui_impl::setMesh(std::string file,vector3df position,vector3df rotation,vector3df scale)
-{
-	IAnimatedMesh* mesh = smgr->getMesh(file.c_str());
-
-	if (!mesh) 	{
-		// model could not be loaded
-        self->Err("Model %s could not be loaded\n",file.c_str());
-        return;
-	}
-
-
-	node = smgr->addOctreeSceneNode(mesh->getMesh(0), 0, -1, 1024);
-	node->setPosition(position);
-	rotation+=irr::core::vector3df(90,0,Euler::ToDegree(getSimulator()->Yaw()));
-	node->setRotation(rotation);
-	for(int i=0; i<node->getMaterialCount();i++){
-		node->getMaterial(i).TextureLayer->TextureWrapU = video::ETC_REPEAT;
-		node->getMaterial(i).TextureLayer->TextureWrapV = video::ETC_REPEAT;
-	}
-	//Ceillig
-	//node->getMaterial(0).getTextureMatrix(0).setTextureScale(scale.X/2.0,scale.Z/2.0);
-	//Walls
-	node->getMaterial(1).getTextureMatrix(0).setTextureScale(1/(scale.Y/2.5),1/(scale.Z/2.5));
-	//Floor
-	node->getMaterial(2).getTextureMatrix(0).setTextureScale(1/(scale.X/20.0),1/(scale.Z/20.0));
-
-	node->setScale(scale);
-	//selector
-	selector = smgr->createOctreeTriangleSelector(node->getMesh(), node, 128);
-	node->setTriangleSelector(selector);
-}
-
-void Gui_impl::RunGui(std::vector<Model*> models,std::vector<GenericObject*> objects)
-{
-	int lastFPS = -1;
-	int cam_id=0;
-
-	receiver->SetCamera(models.at(cam_id)->pimpl_->animator);
-	receiver->SetModel(models.at(cam_id));
-
-	for(size_t i=0;i<models.size();i++)
-	{
-		models.at(i)->Draw();
-	}
-
-	for(size_t i=0;i<models.size();i++)
-	{
-		models.at(i)->pimpl_->MetaTriangleSelector()->addTriangleSelector(selector);
-		for(size_t j=0;j<objects.size();j++)
-		{
-			models.at(i)->pimpl_->MetaTriangleSelector()->addTriangleSelector(objects.at(j)->TriangleSelector());
-		}
-		for(size_t j=0;j<models.size();j++)
-		{
-			if(i==j) continue;
-			models.at(i)->pimpl_->MetaTriangleSelector()->addTriangleSelector(models.at(j)->pimpl_->TriangleSelector());
-		}
-	}
-
-	selector->drop(); // As soon as we're done with the selector, drop it.*/
-
-	//wait all models to be started
-	for(size_t i=0;i<models.size();i++)
-	{
-		models.at(i)->pimpl_->SynchronizationPoint();
-	}
-
-	setWindowCaption(models.at(0),0);
-
-	while(device->run())
-	{
-		if(dbtFile_r!=NULL)//rejeu
-		{
-			takeScreenshot();//on enregistre l'image precedente
-			road_time_t time;
-			road_timerange_t tr = 0;
-			if(read_hdfile(dbtFile_r,(void*)dbtbuf,&time,&tr)!=0)
-			{
-				vector3df vect;
-				char *buf=dbtbuf;
-				for(size_t i=0;i<models.size();i++)
-				{
-					models.at(i)->ReaddbtBuf(buf);
-					buf+=models.at(i)->dbtSize();
-				}
-			}
-			else
-			{
-				//Printf("fin play\n");
-				close_hdfile(dbtFile_r);
-				dbtFile_r=NULL;
-				free(dbtbuf);
-				for(size_t i=0;i<models.size();i++)
-				{
-					models.at(i)->pimpl_->Resume();
-				}
-			}
-		}
-		else//mode normal
-		{
-			for(size_t i=0;i<models.size();i++)
-			{
-				models.at(i)->pimpl_->UpdatePos();
-			}
-		}
-
-		driver->beginScene(true, true, video::SColor(255,200,200,200));
-
-		//vue poursuite
-		smgr->setActiveCamera(models.at(cam_id)->pimpl_->camera);
-		driver->setViewPort(core::rect<s32>(0,0,scene_width,scene_height));
-		smgr->drawAll();//commente voir plus bas
-		/*
-        env->drawAll();
-if (font)
-{
-				font->draw(L"This demo shows that Irrlicht is also capable of drawing 2D graphics.",
-					core::rect<s32>(130,10,300,50),
-					video::SColor(255,255,255,255));
-}
-else
-{
-    printf("err\n");
-}
-device->setWindowCaption(L"toto");*/
-
-		if(dbtFile_r==NULL)//mode normal
-		{
-			for(size_t i=0;i<models.size();i++)
-			{
-				models.at(i)->pimpl_->CheckCollision();
-			}
-		}
-
-		for(size_t i=0;i<models.size();i++)
-		{
-			models.at(i)->ProcessUpdate(NULL);
-		}
-
-		//on fait ca ici, devrait etre un peu plus haut
-		//mais a priori souci avec models.at(i)->pimpl_->CheckCollision(); (setelipsoid?)
-		smgr->setActiveCamera(models.at(cam_id)->pimpl_->camera);
-		driver->setViewPort(core::rect<s32>(0,0,scene_width,scene_height));
-		smgr->drawAll();
-
-		driver->endScene();
-
-		int fps =driver->getFPS();
-		//printf("fps %i\n",fps);
-		if (lastFPS != fps)
-		{
-			setWindowCaption(models.at(cam_id),fps);
-			lastFPS = fps;
-		}
-
-		if(receiver->IsKeyDown(KEY_PRIOR))
-		{
-			cam_id++;
-			if(cam_id>=(int)models.size()) cam_id=0;
-			receiver->SetCamera(models.at(cam_id)->pimpl_->animator);
-			receiver->SetModel(models.at(cam_id));
-			setWindowCaption(models.at(cam_id),fps);
-		}
-		if(receiver->IsKeyDown(KEY_NEXT))
-		{
-			cam_id--;
-			if(cam_id<0) cam_id=models.size()-1;
-			receiver->SetCamera(models.at(cam_id)->pimpl_->animator);
-			receiver->SetModel(models.at(cam_id));
-			setWindowCaption(models.at(cam_id),fps);
-		}
-
-		//enregistrement DBT
-		if(receiver->IsKeyDown(KEY_KEY_R) && dbtFile_w==NULL)
-		{
-			dbtFile_w = inithdFile((char*)"./record.dbt",UAV,dbtSize(models));
-			dbtbuf=(char*)malloc(dbtSize(models));
-		}
-		if(receiver->IsKeyDown(KEY_KEY_S) && dbtFile_w!=NULL)
-		{
-			close_hdfile(dbtFile_w);
-			dbtFile_w=NULL;
-			free(dbtbuf);
-			//rt_printf("stop rec\n");
-		}
-		if(dbtFile_w!=NULL)
-		{
-			Time time=GetTime();
-			vector3df vect;
-			char *buf=dbtbuf;
-
-			for(size_t i=0;i<models.size();i++)
-			{
-				models.at(i)->WritedbtBuf(buf);
-				buf+=models.at(i)->dbtSize();
-			}
-
-			write_hdfile(dbtFile_w,dbtbuf,(road_time_t)(time/1000),(road_timerange_t)(time%1000),dbtSize(models));
-		}
-
-		//lecture dbt
-		if(receiver->IsKeyDown(KEY_KEY_P) && dbtFile_r==NULL)
-		{
-			dbtFile_r = open_hdfile((char*)"./record.dbt",READ_MODE);
-			dbtbuf=(char*)malloc(dbtSize(models));
-			//on suspend les models pour ne pas interferer
-			for(size_t i=0;i<models.size();i++)
-			{
-				models.at(i)->pimpl_->Suspend();
-			}
-		}
-		if(receiver->IsKeyDown(KEY_KEY_S) && dbtFile_r!=NULL)
-		{
-			//rt_printf("stop play\n");
-			close_hdfile(dbtFile_r);
-			dbtFile_r=NULL;
-			free(dbtbuf);
-			//on resume les models
-			for(size_t i=0;i<models.size();i++)
-			{
-				models.at(i)->pimpl_->Resume();
-			}
-		}
-
-	}
-
-	receiver->SetCamera(NULL);
-	receiver->SetModel(NULL);
-
-}
-
-void Gui_impl::setWindowCaption(Object* object, int fps)
-{
-	std::ostringstream text;
-	text << "Cam: " << object->ObjectName().c_str() << ", Kbd: " << object->ObjectName().c_str() << ", FPS: " << fps;
-
-	device->setWindowCaption(stringw(text.str().c_str()).c_str());
-}
-
-void Gui_impl::takeScreenshot(void)
-{
-	static int cpt=0;
-	//get image from the last rendered frame
-	IImage* const image = driver->createScreenShot();
-	if (image) //should always be true, but you never know. ;)
-	{
-		//construct a filename, consisting of local time and file extension
-		c8 filename[64];
-		//snprintf(filename, 64, "screenshot_%u.png", device->getTimer()->getRealTime());
-		snprintf(filename, 64, "screenshot_%u.png", cpt);
-		cpt++;
-		//write screenshot to file
-		if (!driver->writeImageToFile(image, filename))
-			device->getLogger()->log(L"Failed to take screenshot.", ELL_WARNING);
-
-		//Don't forget to drop image since we don't need it anymore.
-		image->drop();
-	}
-}
-
-size_t Gui_impl::dbtSize(std::vector<Model*> models)
-{
-	size_t size=0;
-	for(size_t i=0;i<models.size();i++)
-	{
-		size+=models.at(i)->dbtSize();
-	}
-
-	return size;
-}
-#endif //GL
+  font = env->getFont("./fonthaettenschweiler.bmp");
+
+  if (font)
+          skin->setFont(font);
+
+  // create menu
+
+  IGUIContextMenu* menu = env->addMenu();
+  menu->setMinSize(core::dimension2du(640,20));
+  menu->addItem(L"File", -1, true, true);
+  menu->addItem(L"View", -1, true, true);
+  menu->addItem(L"Camera", -1, true, true);
+  menu->addItem(L"Help", -1, true, true);
+
+  // disable alpha
+
+  for (s32 i=0; i<gui::EGDC_COUNT ; ++i)
+  {
+          video::SColor col =
+env->getSkin()->getColor((gui::EGUI_DEFAULT_COLOR)i);
+          col.setAlpha(255);
+          env->getSkin()->setColor((gui::EGUI_DEFAULT_COLOR)i, col);
+  }
+   */
+}
+
+Gui_impl::~Gui_impl() {
+  // printf("del Gui_impl\n");
+  device->drop();
+
+  delete receiver;
+  // printf("del Gui_impl ok\n");
+}
+
+void Gui_impl::setMesh(std::string file, vector3df position, vector3df rotation,
+                       vector3df scale) {
+  IAnimatedMesh *mesh = smgr->getMesh(file.c_str());
+
+  if (!mesh) {
+    // model could not be loaded
+    self->Err("Model %s could not be loaded\n", file.c_str());
+    return;
+  }
+
+  node = smgr->addOctreeSceneNode(mesh->getMesh(0), 0, -1, 1024);
+  node->setPosition(position);
+  rotation +=
+      irr::core::vector3df(90, 0, Euler::ToDegree(getSimulator()->Yaw()));
+  node->setRotation(rotation);
+  for (int i = 0; i < node->getMaterialCount(); i++) {
+    node->getMaterial(i).TextureLayer->TextureWrapU = video::ETC_REPEAT;
+    node->getMaterial(i).TextureLayer->TextureWrapV = video::ETC_REPEAT;
+  }
+  // Ceillig
+  // node->getMaterial(0).getTextureMatrix(0).setTextureScale(scale.X/2.0,scale.Z/2.0);
+  // Walls
+  node->getMaterial(1).getTextureMatrix(0).setTextureScale(1 / (scale.Y / 2.5),
+                                                           1 / (scale.Z / 2.5));
+  // Floor
+  node->getMaterial(2).getTextureMatrix(0).setTextureScale(
+      1 / (scale.X / 20.0), 1 / (scale.Z / 20.0));
+
+  node->setScale(scale);
+  // selector
+  selector = smgr->createOctreeTriangleSelector(node->getMesh(), node, 128);
+  node->setTriangleSelector(selector);
+}
+
+void Gui_impl::RunGui(std::vector<Model *> models,
+                      std::vector<GenericObject *> objects) {
+  int lastFPS = -1;
+  int cam_id = 0;
+
+  receiver->SetCamera(models.at(cam_id)->pimpl_->animator);
+  receiver->SetModel(models.at(cam_id));
+
+  for (size_t i = 0; i < models.size(); i++) {
+    models.at(i)->Draw();
+  }
+
+  for (size_t i = 0; i < models.size(); i++) {
+    models.at(i)->pimpl_->MetaTriangleSelector()->addTriangleSelector(selector);
+    for (size_t j = 0; j < objects.size(); j++) {
+      models.at(i)->pimpl_->MetaTriangleSelector()->addTriangleSelector(
+          objects.at(j)->TriangleSelector());
+    }
+    for (size_t j = 0; j < models.size(); j++) {
+      if (i == j)
+        continue;
+      models.at(i)->pimpl_->MetaTriangleSelector()->addTriangleSelector(
+          models.at(j)->pimpl_->TriangleSelector());
+    }
+  }
+
+  selector->drop(); // As soon as we're done with the selector, drop it.*/
+
+  // wait all models to be started
+  for (size_t i = 0; i < models.size(); i++) {
+    models.at(i)->pimpl_->SynchronizationPoint();
+  }
+
+  setWindowCaption(models.at(0), 0);
+
+  while (device->run()) {
+    if (dbtFile_r != NULL) // rejeu
+    {
+      takeScreenshot(); // on enregistre l'image precedente
+      road_time_t time;
+      road_timerange_t tr = 0;
+      if (read_hdfile(dbtFile_r, (void *)dbtbuf, &time, &tr) != 0) {
+        vector3df vect;
+        char *buf = dbtbuf;
+        for (size_t i = 0; i < models.size(); i++) {
+          models.at(i)->ReaddbtBuf(buf);
+          buf += models.at(i)->dbtSize();
+        }
+      } else {
+        // Printf("fin play\n");
+        close_hdfile(dbtFile_r);
+        dbtFile_r = NULL;
+        free(dbtbuf);
+        for (size_t i = 0; i < models.size(); i++) {
+          models.at(i)->pimpl_->Resume();
+        }
+      }
+    } else // mode normal
+    {
+      for (size_t i = 0; i < models.size(); i++) {
+        models.at(i)->pimpl_->UpdatePos();
+      }
+    }
+
+    driver->beginScene(true, true, video::SColor(255, 200, 200, 200));
+
+    // vue poursuite
+    smgr->setActiveCamera(models.at(cam_id)->pimpl_->camera);
+    driver->setViewPort(core::rect<s32>(0, 0, scene_width, scene_height));
+    smgr->drawAll(); // commente voir plus bas
+                     /*
+                 env->drawAll();
+                 if (font)
+                 {
+                                     font->draw(L"This demo shows that Irrlicht is also capable
+                 of drawing 2D graphics.",
+                                             core::rect<s32>(130,10,300,50),
+                                             video::SColor(255,255,255,255));
+                 }
+                 else
+                 {
+                 printf("err\n");
+                 }
+                 device->setWindowCaption(L"toto");*/
+
+    if (dbtFile_r == NULL) // mode normal
+    {
+      for (size_t i = 0; i < models.size(); i++) {
+        models.at(i)->pimpl_->CheckCollision();
+      }
+    }
+
+    for (size_t i = 0; i < models.size(); i++) {
+      models.at(i)->ProcessUpdate(NULL);
+    }
+
+    // on fait ca ici, devrait etre un peu plus haut
+    // mais a priori souci avec models.at(i)->pimpl_->CheckCollision();
+    // (setelipsoid?)
+    smgr->setActiveCamera(models.at(cam_id)->pimpl_->camera);
+    driver->setViewPort(core::rect<s32>(0, 0, scene_width, scene_height));
+    smgr->drawAll();
+
+    driver->endScene();
+
+    int fps = driver->getFPS();
+    // printf("fps %i\n",fps);
+    if (lastFPS != fps) {
+      setWindowCaption(models.at(cam_id), fps);
+      lastFPS = fps;
+    }
+
+    if (receiver->IsKeyDown(KEY_PRIOR)) {
+      cam_id++;
+      if (cam_id >= (int)models.size())
+        cam_id = 0;
+      receiver->SetCamera(models.at(cam_id)->pimpl_->animator);
+      receiver->SetModel(models.at(cam_id));
+      setWindowCaption(models.at(cam_id), fps);
+    }
+    if (receiver->IsKeyDown(KEY_NEXT)) {
+      cam_id--;
+      if (cam_id < 0)
+        cam_id = models.size() - 1;
+      receiver->SetCamera(models.at(cam_id)->pimpl_->animator);
+      receiver->SetModel(models.at(cam_id));
+      setWindowCaption(models.at(cam_id), fps);
+    }
+
+    // enregistrement DBT
+    if (receiver->IsKeyDown(KEY_KEY_R) && dbtFile_w == NULL) {
+      dbtFile_w = inithdFile((char *)"./record.dbt", UAV, dbtSize(models));
+      dbtbuf = (char *)malloc(dbtSize(models));
+    }
+    if (receiver->IsKeyDown(KEY_KEY_S) && dbtFile_w != NULL) {
+      close_hdfile(dbtFile_w);
+      dbtFile_w = NULL;
+      free(dbtbuf);
+      // rt_printf("stop rec\n");
+    }
+    if (dbtFile_w != NULL) {
+      Time time = GetTime();
+      vector3df vect;
+      char *buf = dbtbuf;
+
+      for (size_t i = 0; i < models.size(); i++) {
+        models.at(i)->WritedbtBuf(buf);
+        buf += models.at(i)->dbtSize();
+      }
+
+      write_hdfile(dbtFile_w, dbtbuf, (road_time_t)(time / 1000),
+                   (road_timerange_t)(time % 1000), dbtSize(models));
+    }
+
+    // lecture dbt
+    if (receiver->IsKeyDown(KEY_KEY_P) && dbtFile_r == NULL) {
+      dbtFile_r = open_hdfile((char *)"./record.dbt", READ_MODE);
+      dbtbuf = (char *)malloc(dbtSize(models));
+      // on suspend les models pour ne pas interferer
+      for (size_t i = 0; i < models.size(); i++) {
+        models.at(i)->pimpl_->Suspend();
+      }
+    }
+    if (receiver->IsKeyDown(KEY_KEY_S) && dbtFile_r != NULL) {
+      // rt_printf("stop play\n");
+      close_hdfile(dbtFile_r);
+      dbtFile_r = NULL;
+      free(dbtbuf);
+      // on resume les models
+      for (size_t i = 0; i < models.size(); i++) {
+        models.at(i)->pimpl_->Resume();
+      }
+    }
+  }
+
+  receiver->SetCamera(NULL);
+  receiver->SetModel(NULL);
+}
+
+void Gui_impl::setWindowCaption(Object *object, int fps) {
+  std::ostringstream text;
+  text << "Cam: " << object->ObjectName().c_str()
+       << ", Kbd: " << object->ObjectName().c_str() << ", FPS: " << fps;
+
+  device->setWindowCaption(stringw(text.str().c_str()).c_str());
+}
+
+void Gui_impl::takeScreenshot(void) {
+  static int cpt = 0;
+  // get image from the last rendered frame
+  IImage *const image = driver->createScreenShot();
+  if (image) // should always be true, but you never know. ;)
+  {
+    // construct a filename, consisting of local time and file extension
+    c8 filename[64];
+    // snprintf(filename, 64, "screenshot_%u.png",
+    // device->getTimer()->getRealTime());
+    snprintf(filename, 64, "screenshot_%u.png", cpt);
+    cpt++;
+    // write screenshot to file
+    if (!driver->writeImageToFile(image, filename))
+      device->getLogger()->log(L"Failed to take screenshot.", ELL_WARNING);
+
+    // Don't forget to drop image since we don't need it anymore.
+    image->drop();
+  }
+}
+
+size_t Gui_impl::dbtSize(std::vector<Model *> models) {
+  size_t size = 0;
+  for (size_t i = 0; i < models.size(); i++) {
+    size += models.at(i)->dbtSize();
+  }
+
+  return size;
+}
+#endif // GL
Index: trunk/lib/FlairSimulator/src/Man.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/Man.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/Man.cpp	(revision 15)
@@ -34,136 +34,123 @@
 using namespace flair::gui;
 
-namespace flair
-{
-namespace simulator
-{
+namespace flair {
+namespace simulator {
 
-Man::Man(const Simulator* parent,std::string name): Model(parent,name)
-{
-    node = getGui()->getSceneManager()->addAnimatedMeshSceneNode(getGui()->getMesh("ninja.b3d"),getSceneNode(),-1,
-                                                                 vector3df(0,0,0),vector3df(90,0,90),vector3df(10,10,10));
+Man::Man(const Simulator *parent, std::string name) : Model(parent, name) {
+  node = getGui()->getSceneManager()->addAnimatedMeshSceneNode(
+      getGui()->getMesh("ninja.b3d"), getSceneNode(), -1, vector3df(0, 0, 0),
+      vector3df(90, 0, 90), vector3df(10, 10, 10));
 
-	node->setFrameLoop(0, 13);
-	node->setAnimationSpeed(0);
-	node->getMaterial(0).NormalizeNormals = true;
-	node->getMaterial(0).Lighting = false;
+  node->setFrameLoop(0, 13);
+  node->setAnimationSpeed(0);
+  node->getMaterial(0).NormalizeNormals = true;
+  node->getMaterial(0).Lighting = false;
 
-	getCamera()->setPositionOffset(vector3df(0,0,100));
-    getCamera()->setTargetOffset(vector3df(0,0,100));
+  getCamera()->setPositionOffset(vector3df(0, 0, 100));
+  getCamera()->setTargetOffset(vector3df(0, 0, 100));
 
-    setTriangleSelector(getGui()->getSceneManager()->createTriangleSelector(node));
-    Box()->addInternalBox(node->getTransformedBoundingBox());
+  setTriangleSelector(
+      getGui()->getSceneManager()->createTriangleSelector(node));
+  Box()->addInternalBox(node->getTransformedBoundingBox());
 
-    Tab *setup_tab=new Tab(GetTabWidget(),"model");
-        t_speed=new DoubleSpinBox(setup_tab->NewRow(),"translational speed (m/s):",0,5,0.1);
-        r_speed=new DoubleSpinBox(setup_tab->NewRow(),"rotational speed (deg/s):",0,180,10);
+  Tab *setup_tab = new Tab(GetTabWidget(), "model");
+  t_speed = new DoubleSpinBox(setup_tab->NewRow(), "translational speed (m/s):",
+                              0, 5, 0.1);
+  r_speed = new DoubleSpinBox(setup_tab->NewRow(), "rotational speed (deg/s):",
+                              0, 180, 10);
 }
 
-Man::~Man()
-{
+Man::~Man() {}
 
+void Man::CalcModel(void) {
+  // compute quaternion from W
+  // Quaternion derivative: dQ = 0.5*(Q*Qw)
+  Quaternion dQ = state[-1].Quat.GetDerivative(state[0].W);
+
+  // Quaternion integration
+  state[0].Quat = state[-1].Quat + dQ * dT();
+  state[0].Quat.Normalize();
+
+  Vector3D dir = state[0].Vel;
+  dir.Rotate(state[0].Quat);
+  state[0].Pos = state[-1].Pos + dT() * dir;
 }
 
-void Man::CalcModel(void)
-{
-    // compute quaternion from W
-    // Quaternion derivative: dQ = 0.5*(Q*Qw)
-    Quaternion dQ=state[-1].Quat.GetDerivative(state[0].W);
+bool Man::OnEvent(const SEvent &event) {
+  if (event.EventType != EET_KEY_INPUT_EVENT)
+    return false;
 
-    // Quaternion integration
-    state[0].Quat = state[-1].Quat +dQ*dT();
-    state[0].Quat.Normalize();
+  if (event.KeyInput.PressedDown == false) {
+    state[0].Vel.x = 0;
+    state[0].W.z = 0;
+    node->setAnimationSpeed(0);
+  } else {
+    switch (event.KeyInput.Key) {
+    case KEY_UP:
+      state[0].Vel.x = t_speed->Value();
+      node->setAnimationSpeed(t_speed->Value() * 10.f);
+      break;
+    case KEY_DOWN:
+      state[0].Vel.x = -t_speed->Value();
+      node->setAnimationSpeed(-t_speed->Value() * 10.f);
+      break;
+    case KEY_LEFT:
+      state[0].W.z = -Euler::ToRadian(r_speed->Value());
+      node->setAnimationSpeed(r_speed->Value() * .15f);
+      break;
+    case KEY_RIGHT:
+      state[0].W.z = Euler::ToRadian(r_speed->Value());
+      node->setAnimationSpeed(-r_speed->Value() * .15f);
+      break;
+    default:
+      return false;
+      break;
+    }
+  }
 
-    Vector3D dir=state[0].Vel;
-    dir.Rotate(state[0].Quat);
-    state[0].Pos=state[-1].Pos+dT()*dir;
+  return true;
 }
 
-bool Man::OnEvent(const SEvent& event)
-{
-    if (event.EventType != EET_KEY_INPUT_EVENT)
-        return false;
+size_t Man::dbtSize(void) const { return 6 * sizeof(float); }
 
-    if(event.KeyInput.PressedDown==false)
-    {
-        state[0].Vel.x=0;
-        state[0].W.z=0;
-        node->setAnimationSpeed(0);
-    }
-    else
-    {
-        switch(event.KeyInput.Key)
-        {
-        case KEY_UP:
-            state[0].Vel.x=t_speed->Value();
-            node->setAnimationSpeed(t_speed->Value()*10.f);
-            break;
-        case KEY_DOWN:
-            state[0].Vel.x=-t_speed->Value();
-            node->setAnimationSpeed(-t_speed->Value()*10.f);
-            break;
-        case KEY_LEFT:
-            state[0].W.z=-Euler::ToRadian(r_speed->Value());
-            node->setAnimationSpeed(r_speed->Value()*.15f);
-            break;
-        case KEY_RIGHT:
-            state[0].W.z=Euler::ToRadian(r_speed->Value());
-            node->setAnimationSpeed(-r_speed->Value()*.15f);
-            break;
-        default:
-            return false;
-            break;
-        }
-    }
-
-    return true;
+void Man::WritedbtBuf(char *dbtbuf) { /*
+                                         float *buf=(float*)dbtbuf;
+                                         vector3df vect=node->getPosition();
+                                         memcpy(buf,&vect.X,sizeof(float));
+                                         buf++;
+                                         memcpy(buf,&vect.Y,sizeof(float));
+                                         buf++;
+                                         memcpy(buf,&vect.Z,sizeof(float));
+                                         buf++;
+                                         vect=node->getRotation();
+                                         memcpy(buf,&vect.X,sizeof(float));
+                                         buf++;
+                                         memcpy(buf,&vect.Y,sizeof(float));
+                                         buf++;
+                                         memcpy(buf,&vect.Z,sizeof(float));
+                                         buf++;*/
 }
 
-size_t Man::dbtSize(void) const
-{
-    return 6*sizeof(float);
-}
-
-void Man::WritedbtBuf(char* dbtbuf)
-{/*
-    float *buf=(float*)dbtbuf;
-    vector3df vect=node->getPosition();
-    memcpy(buf,&vect.X,sizeof(float));
-    buf++;
-    memcpy(buf,&vect.Y,sizeof(float));
-    buf++;
-    memcpy(buf,&vect.Z,sizeof(float));
-    buf++;
-    vect=node->getRotation();
-    memcpy(buf,&vect.X,sizeof(float));
-    buf++;
-    memcpy(buf,&vect.Y,sizeof(float));
-    buf++;
-    memcpy(buf,&vect.Z,sizeof(float));
-    buf++;*/
-}
-
-void Man::ReaddbtBuf(char* dbtbuf)
-{/*
-    float *buf=(float*)dbtbuf;
-    vector3df vect;
-    memcpy(&vect.X,buf,sizeof(float));
-    buf++;
-    memcpy(&vect.Y,buf,sizeof(float));
-    buf++;
-    memcpy(&vect.Z,buf,sizeof(float));
-    buf++;
-    node->setPosition(vect);
-    memcpy(&vect.X,buf,sizeof(float));
-    buf++;
-    memcpy(&vect.Y,buf,sizeof(float));
-    buf++;
-    memcpy(&vect.Z,buf,sizeof(float));
-    buf++;
-    node->setRotation(vect);
-    node->setAnimationSpeed(2.f);*/
+void Man::ReaddbtBuf(char *dbtbuf) { /*
+                                        float *buf=(float*)dbtbuf;
+                                        vector3df vect;
+                                        memcpy(&vect.X,buf,sizeof(float));
+                                        buf++;
+                                        memcpy(&vect.Y,buf,sizeof(float));
+                                        buf++;
+                                        memcpy(&vect.Z,buf,sizeof(float));
+                                        buf++;
+                                        node->setPosition(vect);
+                                        memcpy(&vect.X,buf,sizeof(float));
+                                        buf++;
+                                        memcpy(&vect.Y,buf,sizeof(float));
+                                        buf++;
+                                        memcpy(&vect.Z,buf,sizeof(float));
+                                        buf++;
+                                        node->setRotation(vect);
+                                        node->setAnimationSpeed(2.f);*/
 }
 
 } // end namespace simulator
 } // end namespace flair
-#endif //GL
+#endif // GL
Index: trunk/lib/FlairSimulator/src/Man.h
===================================================================
--- trunk/lib/FlairSimulator/src/Man.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/Man.h	(revision 15)
@@ -20,43 +20,36 @@
 #include <Model.h>
 
-namespace irr
-{
-    namespace scene
-    {
-        class IAnimatedMeshSceneNode;
-    }
+namespace irr {
+namespace scene {
+class IAnimatedMeshSceneNode;
+}
 }
 
-namespace flair
-{
-    namespace gui
-    {
-        class DoubleSpinBox;
-    }
+namespace flair {
+namespace gui {
+class DoubleSpinBox;
+}
 }
 
-namespace flair
-{
-namespace simulator
-{
-    class Simulator;
+namespace flair {
+namespace simulator {
+class Simulator;
 
-    class Man: private Model
-    {
-        public:
-            Man(const Simulator* parent,std::string name);
-            ~Man();
+class Man : private Model {
+public:
+  Man(const Simulator *parent, std::string name);
+  ~Man();
 
-        private:
-            size_t dbtSize(void) const;
-            void WritedbtBuf(char* dbtbuf);
-            void ReaddbtBuf(char* dbtbuf);
-            void CalcModel(void);
-            void AnimateModel(void){};
-            bool OnEvent(const irr::SEvent& event);
+private:
+  size_t dbtSize(void) const;
+  void WritedbtBuf(char *dbtbuf);
+  void ReaddbtBuf(char *dbtbuf);
+  void CalcModel(void);
+  void AnimateModel(void){};
+  bool OnEvent(const irr::SEvent &event);
 
-            irr::scene::IAnimatedMeshSceneNode* node;
-            gui::DoubleSpinBox *t_speed,*r_speed;
-    };
+  irr::scene::IAnimatedMeshSceneNode *node;
+  gui::DoubleSpinBox *t_speed, *r_speed;
+};
 } // end namespace simulator
 } // end namespace flair
Index: trunk/lib/FlairSimulator/src/MeshSceneNode.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/MeshSceneNode.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/MeshSceneNode.cpp	(revision 15)
@@ -28,69 +28,52 @@
 using namespace flair::core;
 
-namespace flair
-{
-namespace simulator
-{
+namespace flair {
+namespace simulator {
 
-MeshSceneNode::MeshSceneNode(Model* parent,IMesh* mesh,
-			const vector3df& position ,const vector3df& rotation,
-			ITexture* texture, s32 id ): IMeshSceneNode(parent->getSceneNode(), getGui()->getSceneManager(), id,position,rotation)
-{
-    Material.Wireframe = false;
-    Material.Lighting = false;
+MeshSceneNode::MeshSceneNode(Model *parent, IMesh *mesh,
+                             const vector3df &position,
+                             const vector3df &rotation, ITexture *texture,
+                             s32 id)
+    : IMeshSceneNode(parent->getSceneNode(), getGui()->getSceneManager(), id,
+                     position, rotation) {
+  Material.Wireframe = false;
+  Material.Lighting = false;
 
-    setMesh(mesh);
+  setMesh(mesh);
 
-    if(texture!=NULL)
-    {
-        setMaterialTexture(0,texture);
-    }
+  if (texture != NULL) {
+    setMaterialTexture(0, texture);
+  }
 
-    parent->Box()->addInternalBox(getTransformedBoundingBox());
+  parent->Box()->addInternalBox(getTransformedBoundingBox());
 }
 
+void MeshSceneNode::OnRegisterSceneNode(void) {
+  if (IsVisible)
+    SceneManager->registerNodeForRendering(this);
 
-void MeshSceneNode::OnRegisterSceneNode(void)
-{
-    if (IsVisible)
-        SceneManager->registerNodeForRendering(this);
-
-    ISceneNode::OnRegisterSceneNode();
+  ISceneNode::OnRegisterSceneNode();
 }
 
-void MeshSceneNode::render(void)
-{
-    IVideoDriver* driver = SceneManager->getVideoDriver();
+void MeshSceneNode::render(void) {
+  IVideoDriver *driver = SceneManager->getVideoDriver();
 
-    driver->setMaterial(Material);
-    driver->setTransform(ETS_WORLD, AbsoluteTransformation);
-    driver->drawMeshBuffer(mesh->getMeshBuffer(0));
+  driver->setMaterial(Material);
+  driver->setTransform(ETS_WORLD, AbsoluteTransformation);
+  driver->drawMeshBuffer(mesh->getMeshBuffer(0));
 }
 
+SMaterial &MeshSceneNode::getMaterial(u32 i) { return Material; }
 
-SMaterial& MeshSceneNode::getMaterial(u32 i)
-{
-    return Material;
+void MeshSceneNode::setMesh(IMesh *ptr) {
+  mesh = ptr;
+  Box = mesh->getBoundingBox();
 }
 
-void MeshSceneNode::setMesh(IMesh* ptr)
-{
-    mesh=ptr;
-    Box=mesh->getBoundingBox();
-}
+IMesh *MeshSceneNode::getMesh(void) { return mesh; }
 
-
-IMesh* MeshSceneNode::getMesh(void)
-{
-    return mesh;
-}
-
-
-void MeshSceneNode::setReadOnlyMaterials(bool readonly)
-{
-
-}
+void MeshSceneNode::setReadOnlyMaterials(bool readonly) {}
 
 } // end namespace simulator
 } // end namespace flair
-#endif //GL
+#endif // GL
Index: trunk/lib/FlairSimulator/src/MeshSceneNode.h
===================================================================
--- trunk/lib/FlairSimulator/src/MeshSceneNode.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/MeshSceneNode.h	(revision 15)
@@ -20,47 +20,39 @@
 #include <IMeshSceneNode.h>
 
-namespace flair
-{
-namespace simulator
-{
-    class Model;
+namespace flair {
+namespace simulator {
+class Model;
 
-    class MeshSceneNode : public irr::scene::IMeshSceneNode
-    {
-        public:
-            MeshSceneNode(Model* parent,irr::scene::IMesh* mesh,
-                const irr::core::vector3df& position = irr::core::vector3df(0,0,0),
-                const irr::core::vector3df& rotation = irr::core::vector3df(0,0,0),
-                irr::video::ITexture* texture=NULL, irr::s32 id=-1);
+class MeshSceneNode : public irr::scene::IMeshSceneNode {
+public:
+  MeshSceneNode(
+      Model *parent, irr::scene::IMesh *mesh,
+      const irr::core::vector3df &position = irr::core::vector3df(0, 0, 0),
+      const irr::core::vector3df &rotation = irr::core::vector3df(0, 0, 0),
+      irr::video::ITexture *texture = NULL, irr::s32 id = -1);
 
-            virtual void OnRegisterSceneNode(void);
-            virtual void render(void);
-            virtual const irr::core::aabbox3d<irr::f32>& getBoundingBox() const
-            {
-                return Box;
-            }
-            virtual irr::u32 getMaterialCount(void) const
-            {
-                return 1;
-            }
-            virtual irr::video::SMaterial& getMaterial(irr::u32 i);
-            virtual void setMesh( irr::scene::IMesh* ptr);
-            virtual  irr::scene::IMesh* getMesh(void);
-            virtual void setReadOnlyMaterials(bool readonly);
-            virtual bool isReadOnlyMaterials(void) const
-            {
-                return false;
-            }
-            virtual irr::scene::IShadowVolumeSceneNode* addShadowVolumeSceneNode(const irr::scene::IMesh* shadowMesh=0,
-            irr::s32 id=-1, bool zfailmethod=true, irr::f32 infinity=1000.0f)
-            {
-                return NULL;
-            }
+  virtual void OnRegisterSceneNode(void);
+  virtual void render(void);
+  virtual const irr::core::aabbox3d<irr::f32> &getBoundingBox() const {
+    return Box;
+  }
+  virtual irr::u32 getMaterialCount(void) const { return 1; }
+  virtual irr::video::SMaterial &getMaterial(irr::u32 i);
+  virtual void setMesh(irr::scene::IMesh *ptr);
+  virtual irr::scene::IMesh *getMesh(void);
+  virtual void setReadOnlyMaterials(bool readonly);
+  virtual bool isReadOnlyMaterials(void) const { return false; }
+  virtual irr::scene::IShadowVolumeSceneNode *
+  addShadowVolumeSceneNode(const irr::scene::IMesh *shadowMesh = 0,
+                           irr::s32 id = -1, bool zfailmethod = true,
+                           irr::f32 infinity = 1000.0f) {
+    return NULL;
+  }
 
-        private:
-            irr::scene::IMesh *mesh;
-            irr::core::aabbox3d<irr::f32> Box;
-            irr::video::SMaterial Material;
-    };
+private:
+  irr::scene::IMesh *mesh;
+  irr::core::aabbox3d<irr::f32> Box;
+  irr::video::SMaterial Material;
+};
 } // end namespace simulator
 } // end namespace flair
Index: trunk/lib/FlairSimulator/src/Model.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/Model.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/Model.cpp	(revision 15)
@@ -32,28 +32,21 @@
 using namespace flair::gui;
 
-namespace flair
-{
-namespace simulator
-{
+namespace flair {
+namespace simulator {
 
-Model::Model(const Simulator* parent,std::string name) : IODevice(parent,name)
-{
+Model::Model(const Simulator *parent, std::string name)
+    : IODevice(parent, name) {
 #ifdef GL
-    pimpl_=new Model_impl(this,name,getGui()->getSceneManager(),parent->pimpl_);
+  pimpl_ =
+      new Model_impl(this, name, getGui()->getSceneManager(), parent->pimpl_);
 #else
-    pimpl_=new Model_impl(this,name,parent->pimpl_);
+  pimpl_ = new Model_impl(this, name, parent->pimpl_);
 #endif
-    parent->pimpl_->models.push_back(this);
+  parent->pimpl_->models.push_back(this);
 }
 
-Model::~Model()
-{
-    delete pimpl_;
-}
+Model::~Model() { delete pimpl_; }
 #ifdef GL
-ISceneNode* Model::getSceneNode() const
-{
-    return pimpl_;
-}
+ISceneNode *Model::getSceneNode() const { return pimpl_; }
 /*
 only used by dbt, to rewrite using conversion functions (irrlicht <-> simulator)
@@ -64,39 +57,24 @@
 }
 */
-void Model::setScale(float value)
-{
-    pimpl_->setScale(vector3df(value,value,value));
+void Model::setScale(float value) {
+  pimpl_->setScale(vector3df(value, value, value));
 }
 
-aabbox3d<f32> *Model::Box() const
-{
-    return &(pimpl_->box);
+aabbox3d<f32> *Model::Box() const { return &(pimpl_->box); }
+
+AnimPoursuite *Model::getCamera(void) const { return pimpl_->animator; }
+
+void Model::setTriangleSelector(ITriangleSelector *selector) {
+
+  pimpl_->selector = selector;
+  pimpl_->setTriangleSelector(selector);
 }
 
-AnimPoursuite* Model::getCamera(void) const
-{
-    return pimpl_->animator;
-}
-
-void Model::setTriangleSelector(ITriangleSelector* selector) {
-
-    pimpl_->selector=selector;
-    pimpl_->setTriangleSelector(selector);
-}
-
-void Model::setCameraFarValue(float zf) {
-    pimpl_->camera->setFarValue(zf);
-}
+void Model::setCameraFarValue(float zf) { pimpl_->camera->setFarValue(zf); }
 #endif
 
-TabWidget* Model::GetTabWidget(void) const
-{
-    return pimpl_->tabwidget;
-}
+TabWidget *Model::GetTabWidget(void) const { return pimpl_->tabwidget; }
 
-float Model::dT(void) const
-{
-    return pimpl_->dT->Value();
-}
+float Model::dT(void) const { return pimpl_->dT->Value(); }
 
 } // end namespace simulator
Index: trunk/lib/FlairSimulator/src/Model.h
===================================================================
--- trunk/lib/FlairSimulator/src/Model.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/Model.h	(revision 15)
@@ -25,26 +25,21 @@
 #ifdef GL
 #include <aabbox3d.h>
-namespace irr
-{
-    class SEvent;
-    namespace scene
-    {
-        class ISceneManager;
-        class ISceneNode;
-        class ITriangleSelector;
-    }
+namespace irr {
+class SEvent;
+namespace scene {
+class ISceneManager;
+class ISceneNode;
+class ITriangleSelector;
+}
 }
 #endif
 
-namespace flair
-{
-    namespace gui
-    {
-        class TabWidget;
-    }
-    namespace sensor
-    {
-        class SensorGL;
-    }
+namespace flair {
+namespace gui {
+class TabWidget;
+}
+namespace sensor {
+class SensorGL;
+}
 }
 
@@ -53,64 +48,60 @@
 class Model_impl;
 
-namespace flair
-{
-namespace simulator
-{
-    class Simulator;
-    class AnimPoursuite;
+namespace flair {
+namespace simulator {
+class Simulator;
+class AnimPoursuite;
 
-    class Model : public core::IODevice
-    {
-        friend class ::Gui_impl;
-        friend class ::Simulator_impl;
-        friend class ::Model_impl;
-        friend class AnimPoursuite;
-        friend class sensor::SensorGL;
+class Model : public core::IODevice {
+  friend class ::Gui_impl;
+  friend class ::Simulator_impl;
+  friend class ::Model_impl;
+  friend class AnimPoursuite;
+  friend class sensor::SensorGL;
 
-        public:
-            Model(const Simulator* parent,std::string name);
-            virtual ~Model();
+public:
+  Model(const Simulator *parent, std::string name);
+  virtual ~Model();
 
+  typedef struct simu_state {
+    core::Quaternion Quat;
+    core::Vector3D W;
+    core::Vector3D Pos;
+    core::Vector3D Vel;
+  } simu_state_t;
 
-            typedef struct simu_state {
-                core::Quaternion Quat;
-                core::Vector3D W;
-                core::Vector3D Pos;
-                core::Vector3D Vel;
-            } simu_state_t;
+#ifdef GL
+  irr::scene::ISceneNode *getSceneNode() const;
+  irr::core::aabbox3d<irr::f32> *Box() const;
 
-    #ifdef GL
-            irr::scene::ISceneNode* getSceneNode() const;
-            irr::core::aabbox3d<irr::f32>* Box() const;
+  virtual size_t dbtSize(void) const = 0;
+  virtual void Draw(void){};
+  virtual void ExtraDraw(void){};
+  virtual void WritedbtBuf(char *dbtbuf) = 0;
+  virtual void ReaddbtBuf(char *dbtbuf) = 0;
+  virtual bool OnEvent(const irr::SEvent &event) = 0;
 
-            virtual size_t dbtSize(void) const =0;
-            virtual void Draw(void){};
-            virtual void ExtraDraw(void){};
-            virtual void WritedbtBuf(char* dbtbuf)=0;
-            virtual void ReaddbtBuf(char* dbtbuf)=0;
-            virtual bool OnEvent(const irr::SEvent& event)=0;
+  //! Sets the value of the camera's far clipping plane (default: 2000.0f)
+  /** \param zf: New z far value. */
+  void setCameraFarValue(float zf);
+#endif
+  gui::TabWidget *GetTabWidget(void) const;
 
-            //! Sets the value of the camera's far clipping plane (default: 2000.0f)
-            /** \param zf: New z far value. */
-            void setCameraFarValue(float zf);
-    #endif
-            gui::TabWidget* GetTabWidget(void) const;
+protected:
+  DiscreteTimeVariable<simu_state_t, 3> state;
+  float dT(void) const;
+  virtual void CalcModel(void) = 0;
+#ifdef GL
+  AnimPoursuite *getCamera(void) const;
+  virtual void AnimateModel(void) = 0;
+  // void setPosition(core::Vector3D pos);
+  void setScale(float value);
+  void setTriangleSelector(irr::scene::ITriangleSelector *selector);
+#endif
 
-        protected:
-            DiscreteTimeVariable<simu_state_t,3> state;
-            float dT(void) const;
-            virtual void CalcModel(void)=0;
-    #ifdef GL
-            AnimPoursuite* getCamera(void) const;
-            virtual void AnimateModel(void)=0;
-            //void setPosition(core::Vector3D pos);
-            void setScale(float value);
-            void setTriangleSelector(irr::scene::ITriangleSelector* selector);
-    #endif
-
-        private:
-            void UpdateFrom(const core::io_data *data){};
-            class Model_impl* pimpl_;
-    };
+private:
+  void UpdateFrom(const core::io_data *data){};
+  class Model_impl *pimpl_;
+};
 } // end namespace simulator
 } // end namespace flair
Index: trunk/lib/FlairSimulator/src/Model_impl.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/Model_impl.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/Model_impl.cpp	(revision 15)
@@ -50,306 +50,293 @@
 
 #ifdef GL
-Model_impl::Model_impl(Model* self,std::string name,ISceneManager* scenemanager,vrpn_Connection_IP* vrpn)
-    :  ISceneNode(scenemanager->getRootSceneNode(), scenemanager, -1),Thread(self,name,50),vrpn_Tracker( name.c_str(), vrpn )
+Model_impl::Model_impl(Model *self, std::string name,
+                       ISceneManager *scenemanager, vrpn_Connection_IP *vrpn)
+    : ISceneNode(scenemanager->getRootSceneNode(), scenemanager, -1),
+      Thread(self, name, 50), vrpn_Tracker(name.c_str(), vrpn)
 
 #else
-Model_impl::Model_impl(Model* self,std::string name,vrpn_Connection_IP* vrpn)
-    : Thread(self,name,50),vrpn_Tracker( name.c_str(), vrpn )
+Model_impl::Model_impl(Model *self, std::string name, vrpn_Connection_IP *vrpn)
+    : Thread(self, name, 50), vrpn_Tracker(name.c_str(), vrpn)
 #endif
 {
-    this->self=self;
-
-#ifdef GL
-    //for sync with gui
-    cond=new ConditionVariable(this,name);
-    sync_count=0;
-
-    //collisions
-    collision_mutex=new Mutex(this);
-    collision_occured=false;
-
-    //selector for collisions
-    selector = getSceneManager()->createTriangleSelectorFromBoundingBox(this);
-    setTriangleSelector(selector);
-    meta_selector = getSceneManager()->createMetaTriangleSelector();
-
-    anim = getSceneManager()->createCollisionResponseAnimator(meta_selector, this,vector3df(1,1,1),vector3df(0,0,0), vector3df(0,0,0));
-    addAnimator(anim);
-
-    //camera
-	camera =getSceneManager()->addCameraSceneNode();
-    camera->setAspectRatio(getGui()->getAspectRatio());//on force a cause du view port
-    camera->setUpVector(vector3df(0,0,1));
-
-    animator=new AnimPoursuite(this);
-    camera->addAnimator(animator);
-    camera->setFarValue(8000);
-
-    position_init=false;
-#endif
-
-    //init user interface
-    Tab* tab=new Tab(getSimulator()->GetTabWidget(),ObjectName());
-    tabwidget=new TabWidget(tab->NewRow(),"tabs");
-    Tab* sampl=new Tab(tabwidget,"sampling");
-    dT=new DoubleSpinBox(sampl->NewRow(),"Tech (s):",0.001,1,0.001,3);
-    Tab* layout=new Tab(tabwidget,"optitrack");
-    enable_opti=new CheckBox(layout->NewRow(),"enabled");
-    Tab* init=new Tab(tabwidget,"init");
-    pos_init=new Vector3DSpinBox(init->NewRow(),"position",-50,50,1);
-    yaw_init=new SpinBox(init->NewRow(),"yaw (deg):",-180,180,10);
-
-    //modele
-    states_mutex=new Mutex(this);
-	self->state[0].Pos=pos_init->Value();
-	self->state[0].Vel.x=0;
-    self->state[0].Vel.y=0;
-    self->state[0].Vel.z=0;
-	self->state[0].Quat=ComputeInitRotation(Quaternion(1,0,0,0));
-    self->state[0].W.x=0;
-    self->state[0].W.y=0;
-    self->state[0].W.z=0;
-
-    self->state[-1]=self->state[0];
-    self->state[-2]=self->state[0];
-
-    cvmatrix_descriptor* desc=new cvmatrix_descriptor(13,1);
-	desc->SetElementName(0,0,"q0");
-	desc->SetElementName(1,0,"q1");
-	desc->SetElementName(2,0,"q2");
-	desc->SetElementName(3,0,"q3");
-	desc->SetElementName(4,0,"x");
-	desc->SetElementName(5,0,"y");
-	desc->SetElementName(6,0,"z");
-	desc->SetElementName(7,0,"wx");
-	desc->SetElementName(8,0,"wy");
-	desc->SetElementName(9,0,"wz");
-	desc->SetElementName(10,0,"vx");
-	desc->SetElementName(11,0,"vy");
-	desc->SetElementName(12,0,"vz");
-    output=new cvmatrix(this,desc,floatType,"state");
-
-    self->AddDataToLog(output);
-}
-
-Model_impl::~Model_impl()
-{
-    SafeStop();
-    Join();
-#ifdef GL
-    remove();//remove ISceneNode
+  this->self = self;
+
+#ifdef GL
+  // for sync with gui
+  cond = new ConditionVariable(this, name);
+  sync_count = 0;
+
+  // collisions
+  collision_mutex = new Mutex(this);
+  collision_occured = false;
+
+  // selector for collisions
+  selector = getSceneManager()->createTriangleSelectorFromBoundingBox(this);
+  setTriangleSelector(selector);
+  meta_selector = getSceneManager()->createMetaTriangleSelector();
+
+  anim = getSceneManager()->createCollisionResponseAnimator(
+      meta_selector, this, vector3df(1, 1, 1), vector3df(0, 0, 0),
+      vector3df(0, 0, 0));
+  addAnimator(anim);
+
+  // camera
+  camera = getSceneManager()->addCameraSceneNode();
+  camera->setAspectRatio(
+      getGui()->getAspectRatio()); // on force a cause du view port
+  camera->setUpVector(vector3df(0, 0, 1));
+
+  animator = new AnimPoursuite(this);
+  camera->addAnimator(animator);
+  camera->setFarValue(8000);
+
+  position_init = false;
+#endif
+
+  // init user interface
+  Tab *tab = new Tab(getSimulator()->GetTabWidget(), ObjectName());
+  tabwidget = new TabWidget(tab->NewRow(), "tabs");
+  Tab *sampl = new Tab(tabwidget, "sampling");
+  dT = new DoubleSpinBox(sampl->NewRow(), "Tech (s):", 0.001, 1, 0.001, 3);
+  Tab *layout = new Tab(tabwidget, "optitrack");
+  enable_opti = new CheckBox(layout->NewRow(), "enabled");
+  Tab *init = new Tab(tabwidget, "init");
+  pos_init = new Vector3DSpinBox(init->NewRow(), "position", -50, 50, 1);
+  yaw_init = new SpinBox(init->NewRow(), "yaw (deg):", -180, 180, 10);
+
+  // modele
+  states_mutex = new Mutex(this);
+  self->state[0].Pos = pos_init->Value();
+  self->state[0].Vel.x = 0;
+  self->state[0].Vel.y = 0;
+  self->state[0].Vel.z = 0;
+  self->state[0].Quat = ComputeInitRotation(Quaternion(1, 0, 0, 0));
+  self->state[0].W.x = 0;
+  self->state[0].W.y = 0;
+  self->state[0].W.z = 0;
+
+  self->state[-1] = self->state[0];
+  self->state[-2] = self->state[0];
+
+  cvmatrix_descriptor *desc = new cvmatrix_descriptor(13, 1);
+  desc->SetElementName(0, 0, "q0");
+  desc->SetElementName(1, 0, "q1");
+  desc->SetElementName(2, 0, "q2");
+  desc->SetElementName(3, 0, "q3");
+  desc->SetElementName(4, 0, "x");
+  desc->SetElementName(5, 0, "y");
+  desc->SetElementName(6, 0, "z");
+  desc->SetElementName(7, 0, "wx");
+  desc->SetElementName(8, 0, "wy");
+  desc->SetElementName(9, 0, "wz");
+  desc->SetElementName(10, 0, "vx");
+  desc->SetElementName(11, 0, "vy");
+  desc->SetElementName(12, 0, "vz");
+  output = new cvmatrix(this, desc, floatType, "state");
+
+  self->AddDataToLog(output);
+}
+
+Model_impl::~Model_impl() {
+  SafeStop();
+  Join();
+#ifdef GL
+  remove(); // remove ISceneNode
 #endif
 }
 
 Quaternion Model_impl::ComputeInitRotation(Quaternion quat_in) {
-    Quaternion yaw_rot_quat;
-    Euler yaw_rot_euler(0,0,Euler::ToRadian(yaw_init->Value()));
-    yaw_rot_euler.ToQuaternion(yaw_rot_quat);
-    return yaw_rot_quat*quat_in;
-}
-
-void Model_impl::mainloop(void)
-{
-    if(enable_opti->Value()==false) return;
-    vrpn_gettimeofday(&_timestamp, NULL);
-    vrpn_Tracker::timestamp = _timestamp;
-
-    //change to vrpn reference
+  Quaternion yaw_rot_quat;
+  Euler yaw_rot_euler(0, 0, Euler::ToRadian(yaw_init->Value()));
+  yaw_rot_euler.ToQuaternion(yaw_rot_quat);
+  return yaw_rot_quat * quat_in;
+}
+
+void Model_impl::mainloop(void) {
+  if (enable_opti->Value() == false)
+    return;
+  vrpn_gettimeofday(&_timestamp, NULL);
+  vrpn_Tracker::timestamp = _timestamp;
+
+  // change to vrpn reference
+  states_mutex->GetMutex();
+  Quaternion quat = getSimulator()->ToVRPNReference(self->state[0].Quat);
+  Vector3D position = getSimulator()->ToVRPNReference(self->state[0].Pos);
+  states_mutex->ReleaseMutex();
+
+  pos[0] = position.x;
+  pos[1] = position.y;
+  pos[2] = position.z;
+  // warning: d_quat is defined as (qx,qy,qz,qw), which is different from
+  // flair::core::Quaternion
+  d_quat[0] = quat.q1;
+  d_quat[1] = quat.q2;
+  d_quat[2] = quat.q3;
+  d_quat[3] = quat.q0;
+
+  char msgbuf[1000];
+
+  d_sensor = 0;
+
+  int len = vrpn_Tracker::encode_to(msgbuf);
+
+  if (d_connection->pack_message(len, _timestamp, position_m_id, d_sender_id,
+                                 msgbuf, vrpn_CONNECTION_LOW_LATENCY)) {
+    fprintf(stderr, "can't write message: tossing\n");
+  }
+
+  server_mainloop();
+}
+
+#ifdef GL
+ITriangleSelector *Model_impl::TriangleSelector(void) { return selector; }
+
+IMetaTriangleSelector *Model_impl::MetaTriangleSelector(void) {
+  return meta_selector;
+}
+
+void Model_impl::UpdatePos(void) {
+  vector3df nodePosition;
+  Quaternion nodeOrientation;
+  Euler euler;
+
+  states_mutex->GetMutex();
+  nodePosition = ToIrrlichtCoordinates(self->state[0].Pos);
+  nodeOrientation = ToIrrlichtOrientation(self->state[0].Quat);
+  states_mutex->ReleaseMutex();
+
+  setPosition(nodePosition);
+
+  nodeOrientation.ToEuler(euler);
+  ISceneNode::setRotation(Euler::ToDegree(1) *
+                          vector3df(euler.roll, euler.pitch, euler.yaw));
+
+  if (position_init == false) {
+    anim->setTargetNode(this); // a faire pour se teleporter sans les collisions
+    position_init = true;
+  }
+
+  self->AnimateModel();
+}
+
+void Model_impl::CheckCollision(void) {
+  // TODO: setEllipsoidRadius should be called in Model::setScale
+  // but we need to call recalculateBoundingBox
+  anim->setEllipsoidRadius(getTransformedBoundingBox().getExtent());
+
+  if (anim->collisionOccurred() == true) {
+    vector3df pos;
+    vector3df pos_rel;
+    vector3df nodePosition;
+    pos = anim->getCollisionPoint();
+    nodePosition = getPosition();
+    pos_rel = pos - nodePosition;
+    // printf("collision %f %f %f\n",pos.X,pos.Y,pos.Z);
+    // printf("drone %f %f %f\n",nodePosition.X,nodePosition.Y,nodePosition.Z);
+    // printf("rel %f %f %f\n",pos_rel.X,pos_rel.Z,pos_rel.Y);
+
+    collision_mutex->GetMutex();
+    collision_occured = true;
+    collision_point = ToSimulatorCoordinates(nodePosition);
+    collision_mutex->ReleaseMutex();
+  }
+}
+
+void Model_impl::CollisionHandler(void) {
+  collision_mutex->GetMutex();
+  if (collision_occured == true) {
+    collision_occured = false;
     states_mutex->GetMutex();
-    Quaternion quat=getSimulator()->ToVRPNReference(self->state[0].Quat);
-    Vector3D position=getSimulator()->ToVRPNReference(self->state[0].Pos);
+    self->state[0].Pos = collision_point;
+    self->state[-1].Pos = self->state[0].Pos;
+    self->state[-2].Pos = self->state[0].Pos;
     states_mutex->ReleaseMutex();
-
-    pos[0]=position.x;
-    pos[1]=position.y;
-    pos[2]=position.z;
-    //warning: d_quat is defined as (qx,qy,qz,qw), which is different from flair::core::Quaternion
-    d_quat[0] = quat.q1;
-    d_quat[1] = quat.q2;
-    d_quat[2] = quat.q3;
-    d_quat[3] = quat.q0;
-
-    char msgbuf[1000];
-
-    d_sensor = 0;
-
-    int  len = vrpn_Tracker::encode_to(msgbuf);
-
-    if (d_connection->pack_message(len, _timestamp, position_m_id, d_sender_id, msgbuf, vrpn_CONNECTION_LOW_LATENCY))
-    {
-        fprintf(stderr,"can't write message: tossing\n");
+  }
+  collision_mutex->ReleaseMutex();
+}
+
+void Model_impl::OnRegisterSceneNode(void) {
+  if (IsVisible)
+    SceneManager->registerNodeForRendering(this);
+
+  ISceneNode::OnRegisterSceneNode();
+}
+
+void Model_impl::render(void) {
+  IVideoDriver *driver = SceneManager->getVideoDriver();
+  driver->setTransform(ETS_WORLD, AbsoluteTransformation);
+}
+
+// le premier arrive attend l'autre
+void Model_impl::SynchronizationPoint() {
+  cond->GetMutex();
+  sync_count++;
+
+  if (sync_count < 2) {
+    cond->CondWait();
+  } else {
+    cond->CondSignal();
+  }
+
+  cond->ReleaseMutex();
+}
+#endif // GL
+
+void Model_impl::Run(void) {
+  // Ask Xenomai to warn us upon switches to secondary mode.
+  WarnUponSwitches(true);
+
+#ifdef GL
+  // synchronize with gui
+  SynchronizationPoint();
+#endif
+
+  SetPeriodMS(dT->Value() * 1000.);
+
+  while (!ToBeStopped()) {
+    if (dT->ValueChanged())
+      SetPeriodMS(dT->Value() * 1000.);
+    WaitPeriod();
+
+#ifdef GL
+    CollisionHandler();
+#endif
+    states_mutex->GetMutex();
+    self->CalcModel();
+
+    output->GetMutex();
+    output->SetValueNoMutex(0, 0, self->state[0].Quat.q0);
+    output->SetValueNoMutex(1, 0, self->state[0].Quat.q1);
+    output->SetValueNoMutex(2, 0, self->state[0].Quat.q2);
+    output->SetValueNoMutex(3, 0, self->state[0].Quat.q3);
+    output->SetValueNoMutex(4, 0, self->state[0].Pos.x);
+    output->SetValueNoMutex(5, 0, self->state[0].Pos.y);
+    output->SetValueNoMutex(6, 0, self->state[0].Pos.z);
+    output->SetValueNoMutex(7, 0, self->state[0].W.x);
+    output->SetValueNoMutex(8, 0, self->state[0].W.y);
+    output->SetValueNoMutex(9, 0, self->state[0].W.z);
+    output->SetValueNoMutex(10, 0, self->state[0].Vel.x);
+    output->SetValueNoMutex(11, 0, self->state[0].Vel.y);
+    output->SetValueNoMutex(12, 0, self->state[0].Vel.z);
+    output->ReleaseMutex();
+    output->SetDataTime(GetTime());
+
+    self->state.Update();
+
+    if (pos_init->ValueChanged() || yaw_init->ValueChanged()) {
+      self->state[-1].Quat = ComputeInitRotation(Quaternion(1, 0, 0, 0));
+      self->state[-2].Quat = ComputeInitRotation(Quaternion(1, 0, 0, 0));
+      self->state[-1].Pos = pos_init->Value();
+      self->state[-2].Pos = self->state[-1].Pos;
+#ifdef GL
+      position_init = false;
+#endif
     }
 
-    server_mainloop();
-}
-
-#ifdef GL
-ITriangleSelector* Model_impl::TriangleSelector(void)
-{
-    return selector;
-}
-
-IMetaTriangleSelector* Model_impl::MetaTriangleSelector(void)
-{
-    return meta_selector;
-}
-
-void Model_impl::UpdatePos(void)
-{
-    vector3df nodePosition;
-    Quaternion nodeOrientation;
-    Euler euler;
-
-    states_mutex->GetMutex();
-    nodePosition=ToIrrlichtCoordinates(self->state[0].Pos);
-    nodeOrientation=ToIrrlichtOrientation(self->state[0].Quat);
     states_mutex->ReleaseMutex();
 
-    setPosition(nodePosition);
-
-    nodeOrientation.ToEuler(euler);
-    ISceneNode::setRotation(Euler::ToDegree(1)*vector3df(euler.roll,euler.pitch,euler.yaw));
-
-    if(position_init==false)
-    {
-        anim->setTargetNode(this); // a faire pour se teleporter sans les collisions
-        position_init=true;
-    }
-
-    self->AnimateModel();
-}
-
-void Model_impl::CheckCollision(void)
-{
-    //TODO: setEllipsoidRadius should be called in Model::setScale
-    //but we need to call recalculateBoundingBox
-    anim->setEllipsoidRadius(getTransformedBoundingBox().getExtent());
-
-    if(anim->collisionOccurred()==true)
-    {
-        vector3df pos;
-        vector3df pos_rel;
-        vector3df nodePosition;
-        pos= anim->getCollisionPoint();
-        nodePosition=getPosition();
-        pos_rel=pos-nodePosition;
-        //printf("collision %f %f %f\n",pos.X,pos.Y,pos.Z);
-        //printf("drone %f %f %f\n",nodePosition.X,nodePosition.Y,nodePosition.Z);
-        //printf("rel %f %f %f\n",pos_rel.X,pos_rel.Z,pos_rel.Y);
-
-        collision_mutex->GetMutex();
-        collision_occured=true;
-        collision_point=ToSimulatorCoordinates(nodePosition);
-        collision_mutex->ReleaseMutex();
-    }
-}
-
-void Model_impl::CollisionHandler(void)
-{
-    collision_mutex->GetMutex();
-    if(collision_occured==true)
-    {
-        collision_occured=false;
-        states_mutex->GetMutex();
-        self->state[0].Pos=collision_point;
-        self->state[-1].Pos=self->state[0].Pos;
-        self->state[-2].Pos=self->state[0].Pos;
-        states_mutex->ReleaseMutex();
-    }
-    collision_mutex->ReleaseMutex();
-}
-
-void Model_impl::OnRegisterSceneNode(void)
-{
-    if (IsVisible)
-        SceneManager->registerNodeForRendering(this);
-
-    ISceneNode::OnRegisterSceneNode();
-}
-
-void Model_impl::render(void)
-{
-    IVideoDriver* driver = SceneManager->getVideoDriver();
-    driver->setTransform(ETS_WORLD, AbsoluteTransformation);
-}
-
-//le premier arrive attend l'autre
-void Model_impl::SynchronizationPoint()
-{
-    cond->GetMutex();
-    sync_count++;
-
-    if (sync_count < 2)
-    {
-         cond->CondWait();
-    }
-    else
-    {
-        cond->CondSignal();
-    }
-
-    cond->ReleaseMutex();
-}
-#endif //GL
-
-void Model_impl::Run(void)
-{
-    // Ask Xenomai to warn us upon switches to secondary mode.
-    WarnUponSwitches(true);
-
-#ifdef GL
-    //synchronize with gui
-    SynchronizationPoint();
-#endif
-
-    SetPeriodMS(dT->Value()*1000.);
-
-    while(!ToBeStopped())
-    {
-        if(dT->ValueChanged()) SetPeriodMS(dT->Value()*1000.);
-        WaitPeriod();
-
-#ifdef GL
-        CollisionHandler();
-#endif
-        states_mutex->GetMutex();
-        self->CalcModel();
-
-        output->GetMutex();
-        output->SetValueNoMutex(0,0,self->state[0].Quat.q0);
-        output->SetValueNoMutex(1,0,self->state[0].Quat.q1);
-        output->SetValueNoMutex(2,0,self->state[0].Quat.q2);
-        output->SetValueNoMutex(3,0,self->state[0].Quat.q3);
-        output->SetValueNoMutex(4,0,self->state[0].Pos.x);
-        output->SetValueNoMutex(5,0,self->state[0].Pos.y);
-        output->SetValueNoMutex(6,0,self->state[0].Pos.z);
-        output->SetValueNoMutex(7,0,self->state[0].W.x);
-        output->SetValueNoMutex(8,0,self->state[0].W.y);
-        output->SetValueNoMutex(9,0,self->state[0].W.z);
-        output->SetValueNoMutex(10,0,self->state[0].Vel.x);
-        output->SetValueNoMutex(11,0,self->state[0].Vel.y);
-        output->SetValueNoMutex(12,0,self->state[0].Vel.z);
-        output->ReleaseMutex();
-        output->SetDataTime(GetTime());
-
-        self->state.Update();
-
-        if(pos_init->ValueChanged() || yaw_init->ValueChanged())
-        {
-            self->state[-1].Quat=ComputeInitRotation(Quaternion(1,0,0,0));
-            self->state[-2].Quat=ComputeInitRotation(Quaternion(1,0,0,0));
-            self->state[-1].Pos=pos_init->Value();
-            self->state[-2].Pos=self->state[-1].Pos;
-#ifdef GL
-            position_init=false;
-#endif
-        }
-
-        states_mutex->ReleaseMutex();
-
-        self->ProcessUpdate(output);
-
-    }
-
-    WarnUponSwitches(false);
-}
+    self->ProcessUpdate(output);
+  }
+
+  WarnUponSwitches(false);
+}
Index: trunk/lib/FlairSimulator/src/Parser.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/Parser.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/Parser.cpp	(revision 15)
@@ -23,5 +23,4 @@
 #include "GenericObject.h"
 
-
 using namespace irr;
 using namespace irr::core;
@@ -31,194 +30,198 @@
 using namespace flair::simulator;
 
-//todo: getMeshVect doit plutot donner point3D et euler
-//adaptr le xml et la dtd
-
-namespace flair
-{
-namespace simulator
-{
-Parser::Parser(Simulator* parent,int app_width, int app_height,int scene_width, int scene_height,std::string media_path, std::string xmlFile): Gui(parent,"Parser",app_width,app_height,scene_width,scene_height, media_path)
-{
-	this->media_path = media_path;
-	this->parent = parent;
-	xmlNode        *root_element = NULL;
-	doc = xmlReadFile(xmlFile.c_str(), NULL, 0);
-	xmlDtdPtr dtd = NULL;
-	dtd = xmlParseDTD(NULL,  (const xmlChar *)(media_path.append("/scene.dtd").c_str()));
-
-	if (dtd == NULL)
-	{
-		//xmlGenericError(xmlGenericErrorContext,
-		Err("Could not parse DTD scene.dtd\n");
-	}
-	else
-	{
-		xmlValidCtxt cvp;
-		cvp.userData = (void *) stderr;
-		cvp.error    = (xmlValidityErrorFunc) fprintf;
-		cvp.warning  = (xmlValidityWarningFunc) fprintf;
-		if (!xmlValidateDtd(&cvp, doc, dtd))
-		{
-			//xmlGenericError(xmlGenericErrorContext,
-			Err("Document does not validate against scene.dtd\n");
-		}
-	}
-
-	if (doc == NULL)
-	{
-		Err("error: could not parse file %s\n", xmlFile.c_str());
-	}
-	else
-	{
-		/*
-		 * Get the root element node
-		 */
-		root_element = xmlDocGetRootElement(doc);
-		processElements(root_element);
-    }
-
-}
-
-Parser::~Parser()
-{
-	if(doc!=NULL)
-	{
-		/*
-		 * free the document
-		 */
-		xmlFreeDoc(doc);;
-	}
-	/*
-	 *Free the global variables that may
-	 *have been allocated by the parser.
-	 */
-	xmlCleanupParser();
+// todo: getMeshVect doit plutot donner point3D et euler
+// adaptr le xml et la dtd
+
+namespace flair {
+namespace simulator {
+Parser::Parser(Simulator *parent, int app_width, int app_height,
+               int scene_width, int scene_height, std::string media_path,
+               std::string xmlFile)
+    : Gui(parent, "Parser", app_width, app_height, scene_width, scene_height,
+          media_path) {
+  this->media_path = media_path;
+  this->parent = parent;
+  xmlNode *root_element = NULL;
+  doc = xmlReadFile(xmlFile.c_str(), NULL, 0);
+  xmlDtdPtr dtd = NULL;
+  dtd = xmlParseDTD(NULL,
+                    (const xmlChar *)(media_path.append("/scene.dtd").c_str()));
+
+  if (dtd == NULL) {
+    // xmlGenericError(xmlGenericErrorContext,
+    Err("Could not parse DTD scene.dtd\n");
+  } else {
+    xmlValidCtxt cvp;
+    cvp.userData = (void *)stderr;
+    cvp.error = (xmlValidityErrorFunc)fprintf;
+    cvp.warning = (xmlValidityWarningFunc)fprintf;
+    if (!xmlValidateDtd(&cvp, doc, dtd)) {
+      // xmlGenericError(xmlGenericErrorContext,
+      Err("Document does not validate against scene.dtd\n");
+    }
+  }
+
+  if (doc == NULL) {
+    Err("error: could not parse file %s\n", xmlFile.c_str());
+  } else {
+    /*
+     * Get the root element node
+     */
+    root_element = xmlDocGetRootElement(doc);
+    processElements(root_element);
+  }
+}
+
+Parser::~Parser() {
+  if (doc != NULL) {
+    /*
+     * free the document
+     */
+    xmlFreeDoc(doc);
+    ;
+  }
+  /*
+   *Free the global variables that may
+   *have been allocated by the parser.
+   */
+  xmlCleanupParser();
 }
 
 /* Recursive function that prints the XML structure */
-void Parser::processElements(xmlNode * a_node)
-{
-	xmlNode *cur_node = NULL;
-	for (cur_node = a_node; cur_node; cur_node = cur_node->next)
-	{
-		if(cur_node->type == XML_ELEMENT_NODE)
-		{
-			if(xmlStrEqual(cur_node->name, (xmlChar*) "params"))
-			{
-				processParams(cur_node->children);
-			}
-			else if(xmlStrEqual(cur_node->name, (xmlChar*) "objects"))
-			{
-				processObjects(cur_node->children);
-			}
-			else
-			{
-				processElements(cur_node->children);
-			}
-		}
-	}
-}
-
-void Parser::processObjects(xmlNode * a_node)
-{
-	FILE* fp;
-	std::string fileName;
-	xmlNode *cur_node = NULL;
-
-	const IGeometryCreator *geo;
-
-    geo=getGui()->getSceneManager()->getGeometryCreator();
-
-	for (cur_node = a_node; cur_node; cur_node = cur_node->next)
-	{
-		if(xmlStrEqual(cur_node->name, (xmlChar*) "mesh"))
-		{
-			fileName=this->media_path;
-			fp = NULL;
-			fp = fopen( fileName.append((char*)xmlGetProp(cur_node,(xmlChar*)"model")).c_str(), "rb" );
-			if(fp!=NULL){
-				GenericObject* object = new GenericObject(parent,"Object", getSceneManager());
-				object->setMesh(getGui()->getMesh((char*)xmlGetProp(cur_node,(xmlChar*)"model")));
-				object->setPosition(getMeshVect(cur_node->children,(xmlChar*)"position"));
-				object->setRotation(getMeshVect(cur_node->children,(xmlChar*)"rotation"));
-				object->setScale(getMeshVect(cur_node->children,(xmlChar*)"scale"));
-				object->render();
-			}else{
-				Err("FATAL ERROR : File %s doesn't exist !\r\n",(char*)xmlGetProp(cur_node,(xmlChar*)"model"));
-			}
-		}else if(xmlStrEqual(cur_node->name, (xmlChar*) "cylinder")){
-            GenericObject* object = new GenericObject(parent,"Object", getSceneManager());
-            object->setMesh(geo->createCylinderMesh(ToIrrlichtScale(atof((char*)xmlGetProp(cur_node,(xmlChar*)"radius"))),
-                                                    ToIrrlichtScale(atof((char*)xmlGetProp(cur_node,(xmlChar*)"length"))),
-                                                    atof((char*)xmlGetProp(cur_node,(xmlChar*)"tesselation")),
-                                                    SColor(100, 255, 100, 100)));
-            object->setPosition(getMeshVect(cur_node->children,(xmlChar*)"position"));
-            object->setRotation(getMeshVect(cur_node->children,(xmlChar*)"rotation"));
-            object->setScale(getMeshVect(cur_node->children,(xmlChar*)"scale"));
-            //object->setMaterialTexture(0,getTexture("/home/apeiron/igep/uav_dev_svn/trunk/media/nskinbl.jpg"));
-		    object->setMaterialType( video::EMT_SOLID );
-		    object->render();
-		}else if(xmlStrEqual(cur_node->name, (xmlChar*) "eight")){
-            GenericObject* object = new GenericObject(parent,"Object", getSceneManager());
-            object->setMesh(geo->createCubeMesh(vector3df(atof((char*)xmlGetProp(cur_node,(xmlChar*)"length")),atof((char*)xmlGetProp(cur_node,(xmlChar*)"width")),atof((char*)xmlGetProp(cur_node,(xmlChar*)"eight")))));
-            object->setPosition(getMeshVect(cur_node->children,(xmlChar*)"position"));
-            object->setRotation(getMeshVect(cur_node->children,(xmlChar*)"rotation"));
-            object->setScale(getMeshVect(cur_node->children,(xmlChar*)"scale"));
-		    object->setMaterialType( video::EMT_TRANSPARENT_ALPHA_CHANNEL );
-		    //object->getMaterial(0).Textures[0] = getTexture("/home/apeiron/igep/uav_dev_svn/trunk/media/nskinbl.jpg");
-		    object->setMaterialFlag(EMF_LIGHTING, false);
-		    object->render();
-	}
-	}
-}
-
-void Parser::processParams(xmlNode * a_node)
-{
-
-	xmlNode *cur_node = NULL;
-	for (cur_node = a_node; cur_node; cur_node = cur_node->next)
-	{
-		if(xmlStrEqual(cur_node->name, (xmlChar*) "archive"))
-		{
-			std::string file=media_path + "/" + (char*)xmlGetProp(cur_node,(xmlChar*)"path");
-			getDevice()->getFileSystem()->addFileArchive(file.c_str());
-		}
-		else if(xmlStrEqual(cur_node->name, (xmlChar*) "mesh"))
-		{
-			setMesh((char*)xmlGetProp(cur_node,(xmlChar*)"model"),getSceneVect(cur_node->children,(xmlChar*)"position"),getSceneVect(cur_node->children,(xmlChar*)"rotation"),getSceneVect(cur_node->children,(xmlChar*)"scale",true));
-
-		}
-	}
-}
-//todo rendre un vector3D framework
-//retirer irr::core::vector3df ToIrrlichtCoordinates(irr::core::vector3df vect);
-vector3df Parser::getMeshVect(xmlNode * mesh_node, xmlChar * param)
-{
-	xmlNode *cur_node = NULL;
-	for (cur_node = mesh_node; cur_node; cur_node = cur_node->next)
-	{
-		if(xmlStrEqual(cur_node->name, param)){
-			return vector3df(atof((char*)xmlGetProp(cur_node,(xmlChar*)"x")),atof((char*)xmlGetProp(cur_node,(xmlChar*)"y")),atof((char*)xmlGetProp(cur_node,(xmlChar*)"z")));
-		}
-	}
-	return vector3df(0,0,0);
-}
-
-vector3df Parser::getSceneVect(xmlNode * mesh_node, xmlChar * param, bool isScale)
-{
-	xmlNode *cur_node = NULL;
-	for (cur_node = mesh_node; cur_node; cur_node = cur_node->next)
-	{
-		if(xmlStrEqual(cur_node->name, param)){
-			if(isScale){
-				return vector3df(atof((char*)xmlGetProp(cur_node,(xmlChar*)"x")),atof((char*)xmlGetProp(cur_node,(xmlChar*)"z")),atof((char*)xmlGetProp(cur_node,(xmlChar*)"y")));
-			}
-			return vector3df(atof((char*)xmlGetProp(cur_node,(xmlChar*)"x")),-atof((char*)xmlGetProp(cur_node,(xmlChar*)"z")),atof((char*)xmlGetProp(cur_node,(xmlChar*)"y")));
-		}
-	}
-	return vector3df(0,0,0);
+void Parser::processElements(xmlNode *a_node) {
+  xmlNode *cur_node = NULL;
+  for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
+    if (cur_node->type == XML_ELEMENT_NODE) {
+      if (xmlStrEqual(cur_node->name, (xmlChar *)"params")) {
+        processParams(cur_node->children);
+      } else if (xmlStrEqual(cur_node->name, (xmlChar *)"objects")) {
+        processObjects(cur_node->children);
+      } else {
+        processElements(cur_node->children);
+      }
+    }
+  }
+}
+
+void Parser::processObjects(xmlNode *a_node) {
+  FILE *fp;
+  std::string fileName;
+  xmlNode *cur_node = NULL;
+
+  const IGeometryCreator *geo;
+
+  geo = getGui()->getSceneManager()->getGeometryCreator();
+
+  for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
+    if (xmlStrEqual(cur_node->name, (xmlChar *)"mesh")) {
+      fileName = this->media_path;
+      fp = NULL;
+      fp = fopen(fileName.append((char *)xmlGetProp(
+                                     cur_node, (xmlChar *)"model")).c_str(),
+                 "rb");
+      if (fp != NULL) {
+        GenericObject *object =
+            new GenericObject(parent, "Object", getSceneManager());
+        object->setMesh(getGui()->getMesh(
+            (char *)xmlGetProp(cur_node, (xmlChar *)"model")));
+        object->setPosition(
+            getMeshVect(cur_node->children, (xmlChar *)"position"));
+        object->setRotation(
+            getMeshVect(cur_node->children, (xmlChar *)"rotation"));
+        object->setScale(getMeshVect(cur_node->children, (xmlChar *)"scale"));
+        object->render();
+      } else {
+        Err("FATAL ERROR : File %s doesn't exist !\r\n",
+            (char *)xmlGetProp(cur_node, (xmlChar *)"model"));
+      }
+    } else if (xmlStrEqual(cur_node->name, (xmlChar *)"cylinder")) {
+      GenericObject *object =
+          new GenericObject(parent, "Object", getSceneManager());
+      object->setMesh(geo->createCylinderMesh(
+          ToIrrlichtScale(
+              atof((char *)xmlGetProp(cur_node, (xmlChar *)"radius"))),
+          ToIrrlichtScale(
+              atof((char *)xmlGetProp(cur_node, (xmlChar *)"length"))),
+          atof((char *)xmlGetProp(cur_node, (xmlChar *)"tesselation")),
+          SColor(100, 255, 100, 100)));
+      object->setPosition(
+          getMeshVect(cur_node->children, (xmlChar *)"position"));
+      object->setRotation(
+          getMeshVect(cur_node->children, (xmlChar *)"rotation"));
+      object->setScale(getMeshVect(cur_node->children, (xmlChar *)"scale"));
+      // object->setMaterialTexture(0,getTexture("/home/apeiron/igep/uav_dev_svn/trunk/media/nskinbl.jpg"));
+      object->setMaterialType(video::EMT_SOLID);
+      object->render();
+    } else if (xmlStrEqual(cur_node->name, (xmlChar *)"eight")) {
+      GenericObject *object =
+          new GenericObject(parent, "Object", getSceneManager());
+      object->setMesh(geo->createCubeMesh(
+          vector3df(atof((char *)xmlGetProp(cur_node, (xmlChar *)"length")),
+                    atof((char *)xmlGetProp(cur_node, (xmlChar *)"width")),
+                    atof((char *)xmlGetProp(cur_node, (xmlChar *)"eight")))));
+      object->setPosition(
+          getMeshVect(cur_node->children, (xmlChar *)"position"));
+      object->setRotation(
+          getMeshVect(cur_node->children, (xmlChar *)"rotation"));
+      object->setScale(getMeshVect(cur_node->children, (xmlChar *)"scale"));
+      object->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
+      // object->getMaterial(0).Textures[0] =
+      // getTexture("/home/apeiron/igep/uav_dev_svn/trunk/media/nskinbl.jpg");
+      object->setMaterialFlag(EMF_LIGHTING, false);
+      object->render();
+    }
+  }
+}
+
+void Parser::processParams(xmlNode *a_node) {
+
+  xmlNode *cur_node = NULL;
+  for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
+    if (xmlStrEqual(cur_node->name, (xmlChar *)"archive")) {
+      std::string file =
+          media_path + "/" + (char *)xmlGetProp(cur_node, (xmlChar *)"path");
+      getDevice()->getFileSystem()->addFileArchive(file.c_str());
+    } else if (xmlStrEqual(cur_node->name, (xmlChar *)"mesh")) {
+      setMesh((char *)xmlGetProp(cur_node, (xmlChar *)"model"),
+              getSceneVect(cur_node->children, (xmlChar *)"position"),
+              getSceneVect(cur_node->children, (xmlChar *)"rotation"),
+              getSceneVect(cur_node->children, (xmlChar *)"scale", true));
+    }
+  }
+}
+// todo rendre un vector3D framework
+// retirer irr::core::vector3df ToIrrlichtCoordinates(irr::core::vector3df
+// vect);
+vector3df Parser::getMeshVect(xmlNode *mesh_node, xmlChar *param) {
+  xmlNode *cur_node = NULL;
+  for (cur_node = mesh_node; cur_node; cur_node = cur_node->next) {
+    if (xmlStrEqual(cur_node->name, param)) {
+      return vector3df(atof((char *)xmlGetProp(cur_node, (xmlChar *)"x")),
+                       atof((char *)xmlGetProp(cur_node, (xmlChar *)"y")),
+                       atof((char *)xmlGetProp(cur_node, (xmlChar *)"z")));
+    }
+  }
+  return vector3df(0, 0, 0);
+}
+
+vector3df Parser::getSceneVect(xmlNode *mesh_node, xmlChar *param,
+                               bool isScale) {
+  xmlNode *cur_node = NULL;
+  for (cur_node = mesh_node; cur_node; cur_node = cur_node->next) {
+    if (xmlStrEqual(cur_node->name, param)) {
+      if (isScale) {
+        return vector3df(atof((char *)xmlGetProp(cur_node, (xmlChar *)"x")),
+                         atof((char *)xmlGetProp(cur_node, (xmlChar *)"z")),
+                         atof((char *)xmlGetProp(cur_node, (xmlChar *)"y")));
+      }
+      return vector3df(atof((char *)xmlGetProp(cur_node, (xmlChar *)"x")),
+                       -atof((char *)xmlGetProp(cur_node, (xmlChar *)"z")),
+                       atof((char *)xmlGetProp(cur_node, (xmlChar *)"y")));
+    }
+  }
+  return vector3df(0, 0, 0);
 }
 
 } // end namespace simulator
 } // end namespace flair
-#endif //GL
+#endif // GL
Index: trunk/lib/FlairSimulator/src/Parser.h
===================================================================
--- trunk/lib/FlairSimulator/src/Parser.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/Parser.h	(revision 15)
@@ -22,29 +22,27 @@
 #include <libxml/tree.h>
 
-namespace flair
-{
-namespace simulator
-{
-class Parser:public Gui
-{
+namespace flair {
+namespace simulator {
+class Parser : public Gui {
 
-/*can create:
-- cylinders: in y axis
+  /*can create:
+  - cylinders: in y axis
 
-*/
-    public:
-        Parser(Simulator* parent,int app_width, int app_height,int scene_width, int scene_height,std::string media_path, std::string xmlFile);
-        ~Parser();
+  */
+public:
+  Parser(Simulator *parent, int app_width, int app_height, int scene_width,
+         int scene_height, std::string media_path, std::string xmlFile);
+  ~Parser();
 
-
-    private:
-        xmlDoc *doc;
-        std::string media_path;
-        Simulator* parent;
-        void processElements(xmlNode * a_node);
-        void processObjects(xmlNode * a_node);
-        void processParams(xmlNode * a_node);
-        irr::core::vector3df getMeshVect(xmlNode * mesh_node, xmlChar * param);
-        irr::core::vector3df getSceneVect(xmlNode * mesh_node, xmlChar * param, bool isScale=false);
+private:
+  xmlDoc *doc;
+  std::string media_path;
+  Simulator *parent;
+  void processElements(xmlNode *a_node);
+  void processObjects(xmlNode *a_node);
+  void processParams(xmlNode *a_node);
+  irr::core::vector3df getMeshVect(xmlNode *mesh_node, xmlChar *param);
+  irr::core::vector3df getSceneVect(xmlNode *mesh_node, xmlChar *param,
+                                    bool isScale = false);
 };
 }
Index: trunk/lib/FlairSimulator/src/SensorGL.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/SensorGL.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/SensorGL.cpp	(revision 15)
@@ -25,28 +25,17 @@
 using namespace flair::simulator;
 
-namespace flair
-{
-namespace sensor
-{
+namespace flair {
+namespace sensor {
 
-SensorGL::SensorGL(const Model *parent)
-{
-    collMan =getGui()->getSceneManager()->getSceneCollisionManager();
-    node=parent->Model::pimpl_;
+SensorGL::SensorGL(const Model *parent) {
+  collMan = getGui()->getSceneManager()->getSceneCollisionManager();
+  node = parent->Model::pimpl_;
 }
 
-SensorGL::~SensorGL()
-{
-}
+SensorGL::~SensorGL() {}
 
-ISceneCollisionManager* SensorGL::CollMan(void) const
-{
-    return collMan;
-}
+ISceneCollisionManager *SensorGL::CollMan(void) const { return collMan; }
 
-ISceneNode* SensorGL::Node(void) const
-{
-    return node;
-}
+ISceneNode *SensorGL::Node(void) const { return node; }
 
 } // end namespace simulator
Index: trunk/lib/FlairSimulator/src/SensorGL.h
===================================================================
--- trunk/lib/FlairSimulator/src/SensorGL.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/SensorGL.h	(revision 15)
@@ -18,42 +18,35 @@
 #define SENSORGL_H
 
-namespace irr
-{
-    namespace scene
-    {
-        class ISceneNode;
-        class ISceneCollisionManager;
-    }
+namespace irr {
+namespace scene {
+class ISceneNode;
+class ISceneCollisionManager;
+}
 }
 
-namespace flair
-{
-    namespace simulator
-    {
-        class Model;
-    }
+namespace flair {
+namespace simulator {
+class Model;
+}
 }
 
-namespace flair
-{
-namespace sensor
-{
-    class SensorGL
-    {
-        public:
-            SensorGL(const simulator::Model *parent);
-            virtual ~SensorGL()=0;
+namespace flair {
+namespace sensor {
+class SensorGL {
+public:
+  SensorGL(const simulator::Model *parent);
+  virtual ~SensorGL() = 0;
 
-        protected:
-    #ifdef GL
-            irr::scene::ISceneCollisionManager* CollMan(void) const;
-            irr::scene::ISceneNode* Node(void) const;
-    #endif
-        private:
-    #ifdef GL
-            irr::scene::ISceneCollisionManager* collMan;
-            irr::scene::ISceneNode* node;
-    #endif
-    };
+protected:
+#ifdef GL
+  irr::scene::ISceneCollisionManager *CollMan(void) const;
+  irr::scene::ISceneNode *Node(void) const;
+#endif
+private:
+#ifdef GL
+  irr::scene::ISceneCollisionManager *collMan;
+  irr::scene::ISceneNode *node;
+#endif
+};
 } // end namespace sensor
 } // end namespace flair
Index: trunk/lib/FlairSimulator/src/SimuCameraGL.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/SimuCameraGL.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/SimuCameraGL.cpp	(revision 15)
@@ -41,201 +41,190 @@
 using namespace flair::simulator;
 
-namespace flair
-{
-namespace sensor
-{
-
-SimuCameraGL::SimuCameraGL(const Model* parent,std::string name,int width,int height,int x,int y,int dev_id) :SimuCamera(parent,name,width,height,3,dev_id),SensorGL(parent)
-{
-    smgr=getGui()->getSceneManager();
-    camera=smgr->addCameraSceneNode();
-    camera->addAnimator(this);
-    camera->setAspectRatio(4.0f/3.0f);//on force a cause du view port
-
-    this->width=width;
-    this->height=height;
-    this->x=x;
-    this->y=y;
-
-    index = 0;
-
-    buffer=(char*)malloc(width*height*3);
-
-    //user interface
-    Tab* setup_tab=new Tab(parent->GetTabWidget(),name);
-        position=new Vector3DSpinBox(setup_tab->NewRow(),"position",-2,2,.01);
-        direction=new Vector3DSpinBox(setup_tab->NewRow(),"direction",-2,2,.01);
-        up=new Vector3DSpinBox(setup_tab->NewRow(),"up",-2,2,.01);
-        fov=new DoubleSpinBox(setup_tab->NewRow(),"fov:",0,180,5);
-
-    if(strcmp((char*)glGetString(GL_VENDOR),"Intel Open Source Technology Center")==0) {
-        Thread::Warn("disabling cameras output for Intel card (bug with PBO)\n");
-        disable_output=true;
-    } else {
-        disable_output=false;
+namespace flair {
+namespace sensor {
+
+SimuCameraGL::SimuCameraGL(const Model *parent, std::string name, int width,
+                           int height, int x, int y, int dev_id)
+    : SimuCamera(parent, name, width, height, 3, dev_id), SensorGL(parent) {
+  smgr = getGui()->getSceneManager();
+  camera = smgr->addCameraSceneNode();
+  camera->addAnimator(this);
+  camera->setAspectRatio(4.0f / 3.0f); // on force a cause du view port
+
+  this->width = width;
+  this->height = height;
+  this->x = x;
+  this->y = y;
+
+  index = 0;
+
+  buffer = (char *)malloc(width * height * 3);
+
+  // user interface
+  Tab *setup_tab = new Tab(parent->GetTabWidget(), name);
+  position = new Vector3DSpinBox(setup_tab->NewRow(), "position", -2, 2, .01);
+  direction = new Vector3DSpinBox(setup_tab->NewRow(), "direction", -2, 2, .01);
+  up = new Vector3DSpinBox(setup_tab->NewRow(), "up", -2, 2, .01);
+  fov = new DoubleSpinBox(setup_tab->NewRow(), "fov:", 0, 180, 5);
+
+  if (strcmp((char *)glGetString(GL_VENDOR),
+             "Intel Open Source Technology Center") == 0) {
+    Thread::Warn("disabling cameras output for Intel card (bug with PBO)\n");
+    disable_output = true;
+  } else {
+    disable_output = false;
+  }
+
+  if (isGlExtensionSupported("GL_ARB_pixel_buffer_object")) {
+    use_pbo = true;
+    // create 2 pixel buffer objects, you need to delete them when program
+    // exits.
+    // glBufferDataARB with NULL pointer reserves only memory space.
+    pboIds = (GLuint *)malloc(PBO_COUNT * sizeof(GLuint));
+    glGenBuffersARB(PBO_COUNT, pboIds);
+    glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[0]);
+    glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, width * height * 3, 0,
+                    GL_STREAM_READ_ARB);
+    glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[1]);
+    glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, width * height * 3, 0,
+                    GL_STREAM_READ_ARB);
+
+    glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
+  } else {
+    use_pbo = false;
+    Thread::Warn("GL_ARB_pixel_buffer_object is not suppoorted\n");
+  }
+  if (isGlExtensionSupported("GL_PACK_INVERT_MESA")) {
+    invert_pixel = false;
+    Thread::Warn("GL_PACK_INVERT_MESA is suppoorted\n");
+  } else {
+    invert_pixel = true;
+  }
+}
+
+SimuCameraGL::~SimuCameraGL() {
+  free(buffer);
+
+  if (use_pbo) {
+    glDeleteBuffersARB(PBO_COUNT, pboIds);
+    free(pboIds);
+  }
+}
+
+void SimuCameraGL::setNearValue(float zn) { camera->setNearValue(zn); }
+
+void SimuCameraGL::setFarValue(float zf) { camera->setFarValue(zf); }
+
+void SimuCameraGL::UpdateFrom(const io_data *data) {
+  if (noGui() == false && data == NULL) {
+    smgr->setActiveCamera(camera);
+    smgr->getVideoDriver()->setViewPort(rect<s32>(x, y, x + width, y + height));
+    smgr->drawAll();
+    // use_pbo=false;
+    getImage();
+  }
+}
+
+void SimuCameraGL::getImage(void) {
+  if (disable_output)
+    return;
+  // convert from irrlicht top left origin to gl bottom left origin
+  int y = smgr->getVideoDriver()->getScreenSize().Height - height - this->y;
+
+  // We want to read the front buffer to get the latest render finished.
+  Time a = GetTime();
+  glReadBuffer(GL_FRONT);
+  if (use_pbo) // with PBO
+  {
+    // increment current index first then get the next index
+    // "index" is used to read pixels from a framebuffer to a PBO
+    // "nextIndex" is used to process pixels in the other PBO
+    index = (index + 1) % PBO_COUNT;
+    int nextIndex = (index + 1) % PBO_COUNT;
+
+    // copy pixels from framebuffer to PBO
+    // Use offset instead of pointer.
+    // OpenGL should perform asynch DMA transfer, so glReadPixels() will return
+    // immediately.
+    glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[index]);
+    glReadPixels(x, y, width, height, GL_BGR, GL_UNSIGNED_BYTE, 0);
+
+    // map the PBO that contain framebuffer pixels before processing it
+    glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[nextIndex]);
+    GLubyte *src = (GLubyte *)glMapBufferARB(
+        GL_PIXEL_PACK_BUFFER_ARB, GL_READ_WRITE_ARB); // GL_READ_ONLY_ARB);
+    if (src) {
+      putImage((char *)src);
+      glUnmapBufferARB(
+          GL_PIXEL_PACK_BUFFER_ARB); // release pointer to the mapped buffer
     }
-
-    if(isGlExtensionSupported("GL_ARB_pixel_buffer_object"))
-    {
-        use_pbo=true;
-         // create 2 pixel buffer objects, you need to delete them when program exits.
-        // glBufferDataARB with NULL pointer reserves only memory space.
-        pboIds=(GLuint*)malloc(PBO_COUNT*sizeof(GLuint));
-        glGenBuffersARB(PBO_COUNT, pboIds);
-        glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[0]);
-        glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, width*height*3, 0, GL_STREAM_READ_ARB);
-        glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[1]);
-        glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, width*height*3, 0, GL_STREAM_READ_ARB);
-
-        glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
+    glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
+  } else {
+    glReadPixels(x, y, width, height, GL_BGR, GL_UNSIGNED_BYTE, buffer);
+    putImage(buffer);
+  }
+
+  glReadBuffer(GL_BACK);
+  Time b = GetTime();
+  Time c = b - a;
+  // printf("%s %f\n",Thread::ObjectName().c_str(),(float)(c/1000000.));
+}
+
+void SimuCameraGL::putImage(char *buf) {
+  if (invert_pixel == true) {
+    // opengl images are horizontally flipped, so we have to fix that here.
+    const s32 pitch = width * 3;
+    char *pixels = buf;
+    char *p2 = pixels + (height - 1) * pitch;
+    char *tmpBuffer = new char[pitch];
+    for (int i = 0; i < height; i += 2) {
+      memcpy(tmpBuffer, pixels, pitch);
+      memcpy(pixels, p2, pitch);
+      memcpy(p2, tmpBuffer, pitch);
+      pixels += pitch;
+      p2 -= pitch;
     }
-    else
-    {
-        use_pbo=false;
-        Thread::Warn("GL_ARB_pixel_buffer_object is not suppoorted\n");
-    }
-    if(isGlExtensionSupported("GL_PACK_INVERT_MESA"))
-    {
-        invert_pixel=false;
-        Thread::Warn("GL_PACK_INVERT_MESA is suppoorted\n");
-    }
-    else
-    {
-        invert_pixel=true;
-    }
-}
-
-SimuCameraGL::~SimuCameraGL()
-{
-    free(buffer);
-
-    if(use_pbo)
-    {
-        glDeleteBuffersARB(PBO_COUNT, pboIds);
-        free(pboIds);
-    }
-}
-
-void SimuCameraGL::setNearValue(float zn) {
-    camera->setNearValue(zn);
-}
-
-
-void SimuCameraGL::setFarValue(float zf) {
-    camera->setFarValue(zf);
-}
-
-
-void SimuCameraGL::UpdateFrom(const io_data *data)
-{
-    if(noGui()==false && data==NULL)
-    {
-        smgr->setActiveCamera(camera);
-        smgr->getVideoDriver()->setViewPort(rect<s32>(x,y,x+width,y+height));
-        smgr->drawAll();
-        //use_pbo=false;
-        getImage();
-    }
-}
-
-void SimuCameraGL::getImage(void)
-{
-    if(disable_output) return;
-    //convert from irrlicht top left origin to gl bottom left origin
-    int y=smgr->getVideoDriver()->getScreenSize().Height-height-this->y;
-
-	// We want to read the front buffer to get the latest render finished.
-	Time a=GetTime();
-	glReadBuffer(GL_FRONT);
-	if(use_pbo) // with PBO
-    {
-        // increment current index first then get the next index
-        // "index" is used to read pixels from a framebuffer to a PBO
-        // "nextIndex" is used to process pixels in the other PBO
-        index = (index + 1) % PBO_COUNT;
-        int nextIndex = (index + 1) % PBO_COUNT;
-
-        // copy pixels from framebuffer to PBO
-        // Use offset instead of pointer.
-        // OpenGL should perform asynch DMA transfer, so glReadPixels() will return immediately.
-        glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[index]);
-        glReadPixels(x,y,width,height, GL_BGR, GL_UNSIGNED_BYTE, 0);
-
-        // map the PBO that contain framebuffer pixels before processing it
-        glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[nextIndex]);
-        GLubyte* src = (GLubyte*)glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB,GL_READ_WRITE_ARB);//GL_READ_ONLY_ARB);
-        if(src)
-        {
-            putImage((char*)src);
-            glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);     // release pointer to the mapped buffer
-        }
-        glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
-    }
-    else
-    {
-        glReadPixels(x,y,width,height, GL_BGR, GL_UNSIGNED_BYTE, buffer);
-        putImage(buffer);
-    }
-
-	glReadBuffer(GL_BACK);
-	Time b=GetTime();
-	Time c=b-a;
-	//printf("%s %f\n",Thread::ObjectName().c_str(),(float)(c/1000000.));
-}
-
-void SimuCameraGL::putImage(char* buf)
-{
-    if(invert_pixel==true)
-    {
-        // opengl images are horizontally flipped, so we have to fix that here.
-        const s32 pitch=width*3;
-        char* pixels = buf;
-        char* p2 = pixels + (height - 1) * pitch;
-        char* tmpBuffer = new char[pitch];
-        for (int i=0; i < height; i += 2)
-        {
-            memcpy(tmpBuffer, pixels, pitch);
-            memcpy(pixels, p2, pitch);
-            memcpy(p2, tmpBuffer, pitch);
-            pixels += pitch;
-            p2 -= pitch;
-        }
-        delete [] tmpBuffer;
-    }
-
-    shmem->Write(buf,width*height*3);
-}
-
-void SimuCameraGL::animateNode(ISceneNode* node, u32 timeMs)
-{
-    ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node);
-
-    matrix4 m;
-    m.setRotationDegrees(Node()->getRotation());
-
-    // transform forward vector of camera
-    vector3df frv =ToIrrlichtCoordinates(direction->Value());
-    m.transformVect(frv);
-
-    // transform upvector of camera
-    vector3df upv =ToIrrlichtCoordinates(up->Value());
-    m.transformVect(upv);
-
-    // transform camera offset (thanks to Zeuss for finding it was missing)
-    vector3df offset = ToIrrlichtCoordinates(position->Value());
-    m.transformVect(offset);
-
-    // set camera
-    camera->setPosition(Node()->getPosition() + offset); //position camera in front of the ship
-    camera->setUpVector(upv); //set up vector of camera >> Zeuss - tested with +node->getPostion() and it didnt work, but this works fine.
-    camera->setTarget(Node()->getPosition() + offset+frv); //set target of camera (look at point) >> Zeuss - Dont forget to add the node positiob
-
-    camera->setFOV(Euler::ToRadian(fov->Value()));
-}
-
-ISceneNodeAnimator* SimuCameraGL::createClone(ISceneNode* node,
-            ISceneManager* newManager)
-{
-    return NULL;
+    delete[] tmpBuffer;
+  }
+
+  shmem->Write(buf, width * height * 3);
+}
+
+void SimuCameraGL::animateNode(ISceneNode *node, u32 timeMs) {
+  ICameraSceneNode *camera = static_cast<ICameraSceneNode *>(node);
+
+  matrix4 m;
+  m.setRotationDegrees(Node()->getRotation());
+
+  // transform forward vector of camera
+  vector3df frv = ToIrrlichtCoordinates(direction->Value());
+  m.transformVect(frv);
+
+  // transform upvector of camera
+  vector3df upv = ToIrrlichtCoordinates(up->Value());
+  m.transformVect(upv);
+
+  // transform camera offset (thanks to Zeuss for finding it was missing)
+  vector3df offset = ToIrrlichtCoordinates(position->Value());
+  m.transformVect(offset);
+
+  // set camera
+  camera->setPosition(Node()->getPosition() +
+                      offset); // position camera in front of the ship
+  camera->setUpVector(upv);    // set up vector of camera >> Zeuss - tested with
+  // +node->getPostion() and it didnt work, but this
+  // works fine.
+  camera->setTarget(Node()->getPosition() + offset + frv); // set target of
+                                                           // camera (look at
+                                                           // point) >> Zeuss -
+                                                           // Dont forget to add
+                                                           // the node positiob
+
+  camera->setFOV(Euler::ToRadian(fov->Value()));
+}
+
+ISceneNodeAnimator *SimuCameraGL::createClone(ISceneNode *node,
+                                              ISceneManager *newManager) {
+  return NULL;
 }
 
Index: trunk/lib/FlairSimulator/src/SimuCameraGL.h
===================================================================
--- trunk/lib/FlairSimulator/src/SimuCameraGL.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/SimuCameraGL.h	(revision 15)
@@ -18,67 +18,64 @@
 #include <ISceneNodeAnimator.h>
 
-// in order to get function prototypes from glext.h, define GL_GLEXT_PROTOTYPES before including glext.h
+// in order to get function prototypes from glext.h, define GL_GLEXT_PROTOTYPES
+// before including glext.h
 #define GL_GLEXT_PROTOTYPES
 #include <GL/gl.h>
 
-namespace irr
-{
-    namespace scene
-    {
-        class ICameraSceneNode;
-    }
+namespace irr {
+namespace scene {
+class ICameraSceneNode;
+}
 }
 
-namespace flair
-{
-    namespace gui
-    {
-        class DoubleSpinBox;
-        class Vector3DSpinBox;
-    }
-    namespace simulator
-    {
-        class Model;
-    }
+namespace flair {
+namespace gui {
+class DoubleSpinBox;
+class Vector3DSpinBox;
+}
+namespace simulator {
+class Model;
+}
 }
 
-namespace flair
-{
-namespace sensor
-{
-    /*! \class SimuCameraGL
-    * \brief Class for a simulation camera
-    *
-    */
-    class SimuCameraGL : public SimuCamera, public SensorGL, public irr::scene::ISceneNodeAnimator
-    {
-        public:
-            //top left origin
-            SimuCameraGL(const simulator::Model* parent,std::string name,int width,int height,int x,int y,int dev_id);
-            ~SimuCameraGL();
-            //! Sets the value of the near clipping plane. (default: 1.0f)
-            /** \param zn: New z near value. */
-            void setNearValue(float zn);
+namespace flair {
+namespace sensor {
+/*! \class SimuCameraGL
+* \brief Class for a simulation camera
+*
+*/
+class SimuCameraGL : public SimuCamera,
+                     public SensorGL,
+                     public irr::scene::ISceneNodeAnimator {
+public:
+  // top left origin
+  SimuCameraGL(const simulator::Model *parent, std::string name, int width,
+               int height, int x, int y, int dev_id);
+  ~SimuCameraGL();
+  //! Sets the value of the near clipping plane. (default: 1.0f)
+  /** \param zn: New z near value. */
+  void setNearValue(float zn);
 
-            //! Sets the value of the far clipping plane (default: 2000.0f)
-            /** \param zf: New z far value. */
-            void setFarValue(float zf);
+  //! Sets the value of the far clipping plane (default: 2000.0f)
+  /** \param zf: New z far value. */
+  void setFarValue(float zf);
 
-        private:
-            void UpdateFrom(const core::io_data *data);
-            void animateNode(irr::scene::ISceneNode* node, irr::u32 timeMs);
-            ISceneNodeAnimator* createClone(irr::scene::ISceneNode* node,irr::scene::ISceneManager* newManager=0);
-            void getImage(void);
-            void putImage(char* pixels);
-            irr::scene::ICameraSceneNode* camera;
-            irr::scene::ISceneManager* smgr;
-            gui::Vector3DSpinBox *position,*direction,*up;
-            gui::DoubleSpinBox *fov;
-            int width,height,x,y;
-            char* buffer;
-            bool use_pbo,invert_pixel,disable_output;
-            GLuint *pboIds;
-            int index ;
-    };
+private:
+  void UpdateFrom(const core::io_data *data);
+  void animateNode(irr::scene::ISceneNode *node, irr::u32 timeMs);
+  ISceneNodeAnimator *createClone(irr::scene::ISceneNode *node,
+                                  irr::scene::ISceneManager *newManager = 0);
+  void getImage(void);
+  void putImage(char *pixels);
+  irr::scene::ICameraSceneNode *camera;
+  irr::scene::ISceneManager *smgr;
+  gui::Vector3DSpinBox *position, *direction, *up;
+  gui::DoubleSpinBox *fov;
+  int width, height, x, y;
+  char *buffer;
+  bool use_pbo, invert_pixel, disable_output;
+  GLuint *pboIds;
+  int index;
+};
 } // end namespace simulator
 } // end namespace flair
Index: trunk/lib/FlairSimulator/src/SimuLaserGL.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/SimuLaserGL.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/SimuLaserGL.cpp	(revision 15)
@@ -36,69 +36,60 @@
 using namespace flair::simulator;
 
-namespace flair
-{
-namespace sensor
-{
-SimuLaserGL::SimuLaserGL(const Model* parent,std::string name,int dev_id) :SimuLaser(parent,name,dev_id),SensorGL(parent)
-{
-    Tab* setup_tab=new Tab(parent->GetTabWidget(),name);
-            position=new Vector3DSpinBox(setup_tab->NewRow(),"position",-2,2,.01);
-            direction=new Vector3DSpinBox(setup_tab->NewRow(),"direction",-2,2,.01);
-            range=new DoubleSpinBox(setup_tab->NewRow(),"range:",0,30,1);
+namespace flair {
+namespace sensor {
+SimuLaserGL::SimuLaserGL(const Model *parent, std::string name, int dev_id)
+    : SimuLaser(parent, name, dev_id), SensorGL(parent) {
+  Tab *setup_tab = new Tab(parent->GetTabWidget(), name);
+  position = new Vector3DSpinBox(setup_tab->NewRow(), "position", -2, 2, .01);
+  direction = new Vector3DSpinBox(setup_tab->NewRow(), "direction", -2, 2, .01);
+  range = new DoubleSpinBox(setup_tab->NewRow(), "range:", 0, 30, 1);
 }
 
-SimuLaserGL::~SimuLaserGL()
-{
+SimuLaserGL::~SimuLaserGL() {}
 
-}
+void SimuLaserGL::UpdateFrom(const io_data *data) {
+  float value[360];
 
-void SimuLaserGL::UpdateFrom(const io_data *data)
-{
-    float value[360];
+  if (noGui() == false && data == NULL) {
+    for (int i = 0; i < 360; i++) {
+      line3d<f32> ray_laser;         // rayon provenant de l'ultra son
+      vector3df intersection_laser;  // point intersection us avec le sol
+      triangle3df hitTriangle_laser; // triangle intersection us avec le sol
 
-    if(noGui()==false && data==NULL)
-    {
-        for (int i=0; i<360; i++)
-        {
-            line3d<f32> ray_laser;//rayon provenant de l'ultra son
-            vector3df intersection_laser;//point intersection us avec le sol
-            triangle3df hitTriangle_laser;//triangle intersection us avec le sol
+      // get rotation matrix of node - Zeuss must be getRotation not
+      // getRelativeTransformation
+      matrix4 m;
+      matrix4 M;
+      m.setRotationDegrees(Node()->getRotation());
 
-             //get rotation matrix of node - Zeuss must be getRotation not getRelativeTransformation
-            matrix4 m;
-            matrix4 M;
-            m.setRotationDegrees(Node()->getRotation());
+      // Matrice de rotation pour balayage du laser, angle i
+      M.setRotationDegrees(vector3df(0, 0, i));
+      // transform forward vector of us
+      vector3df frv = ToIrrlichtCoordinates(direction->Value());
+      M.transformVect(frv);
+      m.transformVect(frv);
+      frv.normalize();
 
-            //Matrice de rotation pour balayage du laser, angle i
-            M.setRotationDegrees(vector3df(0,0,i));
-            // transform forward vector of us
-            vector3df frv =ToIrrlichtCoordinates(direction->Value());
-            M.transformVect(frv);
-            m.transformVect(frv);
-            frv.normalize();
+      // transform pos vector of us
+      vector3df pos = ToIrrlichtCoordinates(position->Value());
+      m.transformVect(pos);
 
+      ray_laser.start = Node()->getPosition() + pos;
+      ray_laser.end = ray_laser.start + ToIrrlichtScale(range->Value()) * frv;
 
-             // transform pos vector of us
-            vector3df pos =ToIrrlichtCoordinates(position->Value());
-            m.transformVect(pos);
-
-            ray_laser.start =Node()->getPosition() + pos;
-            ray_laser.end = ray_laser.start + ToIrrlichtScale(range->Value())*frv;
-
-            scene::ISceneNode * selectedSceneNode =
-                CollMan()->getSceneNodeAndCollisionPointFromRay(ray_laser,intersection_laser,hitTriangle_laser);
-    // //////////////////////////////////////////
-            if(selectedSceneNode) //
-            {
-                value[i]=ToSimulatorScale(ray_laser.start.getDistanceFrom(intersection_laser));
-            }
-            else
-            {
-                value[i]=-1;
-            }
-
-        }
-        shmem->Write((char*)value,360*sizeof(float));
+      scene::ISceneNode *selectedSceneNode =
+          CollMan()->getSceneNodeAndCollisionPointFromRay(
+              ray_laser, intersection_laser, hitTriangle_laser);
+      // //////////////////////////////////////////
+      if (selectedSceneNode) //
+      {
+        value[i] = ToSimulatorScale(
+            ray_laser.start.getDistanceFrom(intersection_laser));
+      } else {
+        value[i] = -1;
+      }
     }
+    shmem->Write((char *)value, 360 * sizeof(float));
+  }
 }
 
Index: trunk/lib/FlairSimulator/src/SimuLaserGL.h
===================================================================
--- trunk/lib/FlairSimulator/src/SimuLaserGL.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/SimuLaserGL.h	(revision 15)
@@ -17,40 +17,33 @@
 #include <SensorGL.h>
 
-namespace flair
-{
-    namespace gui
-    {
-        class DoubleSpinBox;
-        class Vector3DSpinBox;
-    }
+namespace flair {
+namespace gui {
+class DoubleSpinBox;
+class Vector3DSpinBox;
+}
 }
 
-namespace flair
-{
-    namespace simulator
-    {
-        class Model;
-    }
+namespace flair {
+namespace simulator {
+class Model;
+}
 }
 
-namespace flair
-{
-namespace sensor
-{
-    /*! \class SimuUsGL
-    * \brief Class for a simulation us
-    *
-    */
-    class SimuLaserGL : public SimuLaser, public SensorGL
-    {
-        public:
-            SimuLaserGL(const simulator::Model* parent,std::string name,int dev_id);
-            ~SimuLaserGL();
+namespace flair {
+namespace sensor {
+/*! \class SimuUsGL
+* \brief Class for a simulation us
+*
+*/
+class SimuLaserGL : public SimuLaser, public SensorGL {
+public:
+  SimuLaserGL(const simulator::Model *parent, std::string name, int dev_id);
+  ~SimuLaserGL();
 
-        private:
-            void UpdateFrom(const core::io_data *data);
-            gui::DoubleSpinBox *range;
-            gui::Vector3DSpinBox *position,*direction;
-    };
+private:
+  void UpdateFrom(const core::io_data *data);
+  gui::DoubleSpinBox *range;
+  gui::Vector3DSpinBox *position, *direction;
+};
 } // end namespace sensor
 } // end namespace flair
Index: trunk/lib/FlairSimulator/src/SimuUsGL.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/SimuUsGL.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/SimuUsGL.cpp	(revision 15)
@@ -36,66 +36,60 @@
 using namespace flair::simulator;
 
-namespace flair
-{
-namespace sensor
-{
-SimuUsGL::SimuUsGL(const Model* parent,std::string name,int dev_id) :SimuUs(parent,name,dev_id),SensorGL(parent)
-{
-    Tab* setup_tab=new Tab(parent->GetTabWidget(),name);
-            position=new Vector3DSpinBox(setup_tab->NewRow(),"position",-2,2,.01);
-            direction=new Vector3DSpinBox(setup_tab->NewRow(),"direction",-2,2,.01);
-            range=new DoubleSpinBox(setup_tab->NewRow(),"range:",0,6,1);
+namespace flair {
+namespace sensor {
+SimuUsGL::SimuUsGL(const Model *parent, std::string name, int dev_id)
+    : SimuUs(parent, name, dev_id), SensorGL(parent) {
+  Tab *setup_tab = new Tab(parent->GetTabWidget(), name);
+  position = new Vector3DSpinBox(setup_tab->NewRow(), "position", -2, 2, .01);
+  direction = new Vector3DSpinBox(setup_tab->NewRow(), "direction", -2, 2, .01);
+  range = new DoubleSpinBox(setup_tab->NewRow(), "range:", 0, 6, 1);
 }
 
-SimuUsGL::~SimuUsGL()
-{
+SimuUsGL::~SimuUsGL() {}
 
-}
+void SimuUsGL::UpdateFrom(const io_data *data) {
+  float value;
+#ifdef GL
+  if (noGui() == true) {
+#endif
+    // todo: utiliser le placement de l'us dans le drone et sa portée
+    cvmatrix *input = (cvmatrix *)data;
+    value = input->Value(9, 0);
+    shmem->Write((char *)&value, sizeof(float));
+#ifdef GL
+  }
 
-void SimuUsGL::UpdateFrom(const io_data *data)
-{
-    float value;
-#ifdef GL
-    if(noGui()==true)
-    {
-#endif
-        //todo: utiliser le placement de l'us dans le drone et sa portée
-        cvmatrix *input=(cvmatrix*)data;
-        value=input->Value(9,0);
-        shmem->Write((char*)&value,sizeof(float));
-#ifdef GL
+  if (noGui() == false && data == NULL) {
+    line3d<f32> ray_us;         // rayon provenant de l'ultra son
+    vector3df intersection_us;  // point intersection us avec le sol
+    triangle3df hitTriangle_us; // triangle intersection us avec le sol
+
+    // get rotation matrix of node - Zeuss must be getRotation not
+    // getRelativeTransformation
+    matrix4 m;
+    m.setRotationDegrees(Node()->getRotation());
+
+    // transform forward vector of us
+    vector3df frv = ToIrrlichtCoordinates(direction->Value());
+    m.transformVect(frv);
+    frv.normalize();
+
+    // transform pos vector of us
+    vector3df pos = ToIrrlichtCoordinates(position->Value());
+    m.transformVect(pos);
+
+    ray_us.start = Node()->getPosition() + pos;
+    ray_us.end = ray_us.start + ToIrrlichtScale(range->Value()) * frv;
+
+    scene::ISceneNode *selectedSceneNode =
+        CollMan()->getSceneNodeAndCollisionPointFromRay(ray_us, intersection_us,
+                                                        hitTriangle_us);
+
+    if (selectedSceneNode) {
+      float value =
+          ToSimulatorScale(ray_us.start.getDistanceFrom(intersection_us));
+      shmem->Write((char *)&value, sizeof(float));
     }
-
-    if(noGui()==false && data==NULL)
-    {
-        line3d<f32> ray_us;//rayon provenant de l'ultra son
-        vector3df intersection_us;//point intersection us avec le sol
-        triangle3df hitTriangle_us;//triangle intersection us avec le sol
-
-         //get rotation matrix of node - Zeuss must be getRotation not getRelativeTransformation
-        matrix4 m;
-        m.setRotationDegrees(Node()->getRotation());
-
-        // transform forward vector of us
-        vector3df frv =ToIrrlichtCoordinates(direction->Value());
-        m.transformVect(frv);
-        frv.normalize();
-
-         // transform pos vector of us
-        vector3df pos =ToIrrlichtCoordinates(position->Value());
-        m.transformVect(pos);
-
-        ray_us.start =Node()->getPosition() +pos;
-        ray_us.end = ray_us.start + ToIrrlichtScale(range->Value())*frv;
-
-        scene::ISceneNode * selectedSceneNode =
-            CollMan()->getSceneNodeAndCollisionPointFromRay(ray_us,intersection_us,hitTriangle_us);
-
-        if(selectedSceneNode)
-        {
-            float value=ToSimulatorScale(ray_us.start.getDistanceFrom(intersection_us));
-            shmem->Write((char*)&value,sizeof(float));
-        }
-    }
+  }
 #endif
 }
Index: trunk/lib/FlairSimulator/src/SimuUsGL.h
===================================================================
--- trunk/lib/FlairSimulator/src/SimuUsGL.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/SimuUsGL.h	(revision 15)
@@ -17,40 +17,33 @@
 #include <SensorGL.h>
 
-namespace flair
-{
-    namespace gui
-    {
-        class DoubleSpinBox;
-        class Vector3DSpinBox;
-    }
+namespace flair {
+namespace gui {
+class DoubleSpinBox;
+class Vector3DSpinBox;
+}
 }
 
-namespace flair
-{
-    namespace simulator
-    {
-        class Model;
-    }
+namespace flair {
+namespace simulator {
+class Model;
+}
 }
 
-namespace flair
-{
-namespace sensor
-{
-    /*! \class SimuUsGL
-    * \brief Class for a simulation us
-    *
-    */
-    class SimuUsGL : public SimuUs, public SensorGL
-    {
-        public:
-            SimuUsGL(const simulator::Model* parent,std::string name,int dev_id);
-            ~SimuUsGL();
+namespace flair {
+namespace sensor {
+/*! \class SimuUsGL
+* \brief Class for a simulation us
+*
+*/
+class SimuUsGL : public SimuUs, public SensorGL {
+public:
+  SimuUsGL(const simulator::Model *parent, std::string name, int dev_id);
+  ~SimuUsGL();
 
-        private:
-            void UpdateFrom(const core::io_data *data);
-            gui::DoubleSpinBox *range;
-            gui::Vector3DSpinBox *position,*direction;
-    };
+private:
+  void UpdateFrom(const core::io_data *data);
+  gui::DoubleSpinBox *range;
+  gui::Vector3DSpinBox *position, *direction;
+};
 } // end namespace sensor
 } // end namespace flair
Index: trunk/lib/FlairSimulator/src/Simulator.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/Simulator.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/Simulator.cpp	(revision 15)
@@ -27,57 +27,46 @@
 using namespace flair::core;
 
-namespace
-{
-    flair::simulator::Simulator* simu=NULL;
+namespace {
+flair::simulator::Simulator *simu = NULL;
 }
 
-namespace flair
-{
-namespace simulator
-{
+namespace flair {
+namespace simulator {
 
-Simulator* getSimulator(void) {
-    return simu;
+Simulator *getSimulator(void) { return simu; }
+
+Simulator::Simulator(string name, int optitrack_mstime, float yaw_deg)
+    : FrameworkManager(name) {
+  if (simu != NULL)
+    Err("Simulator should be instanced only one time\n");
+
+  pimpl_ = new Simulator_impl(this, optitrack_mstime, yaw_deg);
+  simu = this;
 }
 
-Simulator::Simulator(string name,int optitrack_mstime,float yaw_deg): FrameworkManager(name)
-{
-    if(simu!=NULL) Err("Simulator should be instanced only one time\n");
-
-    pimpl_=new Simulator_impl(this,optitrack_mstime,yaw_deg);
-    simu=this;
-}
-
-Simulator::~Simulator()
-{
-    delete pimpl_;
-}
+Simulator::~Simulator() { delete pimpl_; }
 
 Quaternion Simulator::ToVRPNReference(Quaternion quat_in) {
-    Quaternion yaw_rot_quat;
-    Euler yaw_rot_euler(0,0,-pimpl_->yaw_rad);//yaw_rad is vrpn rotation in earth reference
-    yaw_rot_euler.ToQuaternion(yaw_rot_quat);
+  Quaternion yaw_rot_quat;
+  Euler yaw_rot_euler(
+      0, 0, -pimpl_->yaw_rad); // yaw_rad is vrpn rotation in earth reference
+  yaw_rot_euler.ToQuaternion(yaw_rot_quat);
 
-    return yaw_rot_quat*quat_in;
+  return yaw_rot_quat * quat_in;
 }
 
 Vector3D Simulator::ToVRPNReference(Vector3D point_in) {
-    Quaternion yaw_rot_quat;
-    Euler yaw_rot_euler(0,0,-pimpl_->yaw_rad);//yaw_rad is vrpn rotation in earth reference
-    yaw_rot_euler.ToQuaternion(yaw_rot_quat);
-    point_in.Rotate(yaw_rot_quat);
+  Quaternion yaw_rot_quat;
+  Euler yaw_rot_euler(
+      0, 0, -pimpl_->yaw_rad); // yaw_rad is vrpn rotation in earth reference
+  yaw_rot_euler.ToQuaternion(yaw_rot_quat);
+  point_in.Rotate(yaw_rot_quat);
 
-    return point_in;
+  return point_in;
 }
 
-float Simulator::Yaw(void) const
-{
-    return pimpl_->yaw_rad;
-}
+float Simulator::Yaw(void) const { return pimpl_->yaw_rad; }
 
-void Simulator::RunSimu(void)
-{
-    pimpl_->RunSimu();
-}
+void Simulator::RunSimu(void) { pimpl_->RunSimu(); }
 
 } // end namespace simulator
Index: trunk/lib/FlairSimulator/src/Simulator.h
===================================================================
--- trunk/lib/FlairSimulator/src/Simulator.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/Simulator.h	(revision 15)
@@ -24,44 +24,44 @@
 
 namespace flair {
-    namespace core {
-        class Quaternion;
-        class Vector3D;
-    }
+namespace core {
+class Quaternion;
+class Vector3D;
+}
 }
 
-namespace flair
-{
-namespace simulator
-{
-    class Model;
-    class Gui;
+namespace flair {
+namespace simulator {
+class Model;
+class Gui;
 
-    class Simulator: public core::FrameworkManager
-    {
-        friend class Model;
-        friend class Gui;
-        friend class GenericObject;
+class Simulator : public core::FrameworkManager {
+  friend class Model;
+  friend class Gui;
+  friend class GenericObject;
 
-        public:
-            //yaw_deg: rotation of the vrpn coordinate with respect to the earth coordinate, around z axis
-            Simulator(std::string name,int optitrack_mstime=10,float yaw_deg=30);
-            ~Simulator();
-            void RunSimu(void);
-            //get rotation of the vrpn coordinate with respect to the earth coordinate, around z axis; in radians
-            float Yaw(void) const;
-            //compute rotation of the vrpn coordinate with respect to the earth coordinate, around z axis
-            core::Quaternion ToVRPNReference(core::Quaternion quat_in);
-            core::Vector3D ToVRPNReference(core::Vector3D point_in);
+public:
+  // yaw_deg: rotation of the vrpn coordinate with respect to the earth
+  // coordinate, around z axis
+  Simulator(std::string name, int optitrack_mstime = 10, float yaw_deg = 30);
+  ~Simulator();
+  void RunSimu(void);
+  // get rotation of the vrpn coordinate with respect to the earth coordinate,
+  // around z axis; in radians
+  float Yaw(void) const;
+  // compute rotation of the vrpn coordinate with respect to the earth
+  // coordinate, around z axis
+  core::Quaternion ToVRPNReference(core::Quaternion quat_in);
+  core::Vector3D ToVRPNReference(core::Vector3D point_in);
 
-        private:
-            Simulator_impl* pimpl_;
-    };
+private:
+  Simulator_impl *pimpl_;
+};
 
-    /*!
-    * \brief get Simulator
-    *
-    * \return the Simulator
-    */
-    Simulator* getSimulator(void);
+/*!
+* \brief get Simulator
+*
+* \return the Simulator
+*/
+Simulator *getSimulator(void);
 
 } // end namespace simulator
Index: trunk/lib/FlairSimulator/src/Simulator_impl.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/Simulator_impl.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/Simulator_impl.cpp	(revision 15)
@@ -29,76 +29,67 @@
 using namespace flair::simulator;
 
-Simulator_impl::Simulator_impl(Simulator* self,int optitrack_mstime,float yaw_deg): vrpn_Connection_IP(), Thread(self,"simulator",1)
-{
-    this->self=self;
-    this->optitrack_mstime=optitrack_mstime;
-    yaw_rad=Euler::ToRadian(yaw_deg);
+Simulator_impl::Simulator_impl(Simulator *self, int optitrack_mstime,
+                               float yaw_deg)
+    : vrpn_Connection_IP(), Thread(self, "simulator", 1) {
+  this->self = self;
+  this->optitrack_mstime = optitrack_mstime;
+  yaw_rad = Euler::ToRadian(yaw_deg);
 }
 
-Simulator_impl::~Simulator_impl()
-{
-    //printf("del Simulator_impl\n");
+Simulator_impl::~Simulator_impl() {
+  // printf("del Simulator_impl\n");
 
-    SafeStop();
-    Join();
+  SafeStop();
+  Join();
 
-    for(size_t i=0;i<models.size();i++)
-    {
-        models.at(i)->pimpl_->SafeStop();
-        models.at(i)->pimpl_->Join();
-        delete models.at(i);
-    }
+  for (size_t i = 0; i < models.size(); i++) {
+    models.at(i)->pimpl_->SafeStop();
+    models.at(i)->pimpl_->Join();
+    delete models.at(i);
+  }
 
 #ifdef GL
-    if(getGui()!=NULL) delete getGui();
+  if (getGui() != NULL)
+    delete getGui();
 #endif
 
-     //printf("del Simulator_impl ok\n");
+  // printf("del Simulator_impl ok\n");
 }
 
-void Simulator_impl::Run(void)
-{
-    SetPeriodMS(optitrack_mstime);
+void Simulator_impl::Run(void) {
+  SetPeriodMS(optitrack_mstime);
 
-    while(ToBeStopped()==false)
-	{
-	    WaitPeriod();
-//printf("%lld\n",GetTime());
-        mainloop();
-        for(size_t i=0;i<models.size();i++)
-        {
-            models.at(i)->pimpl_->mainloop();
-        }
-	}
+  while (ToBeStopped() == false) {
+    WaitPeriod();
+    // printf("%lld\n",GetTime());
+    mainloop();
+    for (size_t i = 0; i < models.size(); i++) {
+      models.at(i)->pimpl_->mainloop();
+    }
+  }
 }
 
+void Simulator_impl::RunSimu(void) {
+  if (models.size() == 0) {
+    self->Err("No model to run\n");
+    return;
+  }
 
-void Simulator_impl::RunSimu(void)
-{
-    if(models.size()==0)
-    {
-        self->Err("No model to run\n");
-        return;
-    }
+  for (size_t i = 0; i < models.size(); i++) {
+    models.at(i)->pimpl_->Start();
+  }
 
-    for(size_t i=0;i<models.size();i++)
-    {
-        models.at(i)->pimpl_->Start();
-    }
-
-    Start();
+  Start();
 
 #ifdef GL
-    if(getGui()!=NULL)
-    {
-        getGui()->pimpl_->RunGui(models,objects);
-    }
-    else
+  if (getGui() != NULL) {
+    getGui()->pimpl_->RunGui(models, objects);
+  } else
 #endif
-    {
-        models.at(0)->pimpl_->Join();
-    }
+  {
+    models.at(0)->pimpl_->Join();
+  }
 
-    SafeStop();
-    Join();
+  SafeStop();
+  Join();
 }
Index: trunk/lib/FlairSimulator/src/X4.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/X4.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/X4.cpp	(revision 15)
@@ -31,6 +31,6 @@
 #endif
 
-#define K_MOT 0.4f //blade animation
-#define G (float)9.81 //gravity ( N/(m/s²) )
+#define K_MOT 0.4f    // blade animation
+#define G (float)9.81 // gravity ( N/(m/s²) )
 
 #ifdef GL
@@ -43,240 +43,289 @@
 using namespace flair::actuator;
 
-namespace flair
-{
-namespace simulator
-{
-
-X4::X4(const Simulator* parent,std::string name, int dev_id): Model(parent,name)
-{
-    Tab *setup_tab=new Tab(GetTabWidget(),"model");
-        m=new DoubleSpinBox(setup_tab->NewRow(),"mass (kg):",0,20,0.1);
-        arm_length=new DoubleSpinBox(setup_tab->LastRowLastCol(),"arm length (m):",0,2,0.1);
-        //l_cg=new DoubleSpinBox(setup_tab,"position G (m):",0,2,-0.5,0.5,0.02);//position du centre de gravité/centre de poussé
-        k_mot=new DoubleSpinBox(setup_tab->NewRow(),"k_mot:",0,1,0.001,3);// vitesse rotation² (unité arbitraire) -> force (N)
-        c_mot=new DoubleSpinBox(setup_tab->LastRowLastCol(),"c_mot:",0,1,0.001,3);// vitesse rotation moteur -> couple (N.m/unité arbitraire)
-        f_air_vert=new DoubleSpinBox(setup_tab->NewRow(),"f_air_vert:",0,10,1);//frottements air depl. vertical, aussi utilisé pour les rotations ( N/(m/s) ) (du aux helices en rotation)
-        f_air_lat=new DoubleSpinBox(setup_tab->LastRowLastCol(),"f_air_lat:",0,10,1);//frottements air deplacements lateraux ( N/(m/s) )
-        j_roll=new DoubleSpinBox(setup_tab->NewRow(),"j_roll:",0,1,0.001,5); //moment d'inertie d'un axe (N.m.s²/rad)
-        j_pitch=new DoubleSpinBox(setup_tab->LastRowLastCol(),"j_pitch:",0,1,0.001,5); //moment d'inertie d'un axe (N.m.s²/rad)
-        j_yaw=new DoubleSpinBox(setup_tab->LastRowLastCol(),"j_yaw:",0,1,0.001,5); //moment d'inertie d'un axe (N.m.s²/rad)
-
-    motors=new SimuBldc(this,name,4,dev_id);
-}
-
-X4::~X4()
-{
-    //les objets irrlicht seront automatiquement detruits (moteurs, helices, pales) par parenté
-}
-
-
-#ifdef GL
-
-void X4::Draw(void)
-{
-    //create unite (1m=100cm) UAV; scale will be adapted according to arm_length parameter
-    //note that the frame used is irrlicht one:
-    //left handed, North East Up
-    const IGeometryCreator *geo;
-    geo=getGui()->getSceneManager()->getGeometryCreator();
-
-    //cylinders are aligned with y axis
-    red_arm=geo->createCylinderMesh(2.5,100,16,SColor(0, 255, 0, 0));
-    black_arm=geo->createCylinderMesh(2.5,100,16,SColor(0, 128, 128, 128));
-    motor=geo->createCylinderMesh(7.5,15,16);//,SColor(0, 128, 128, 128));
-    //geo->drop();
-
-    ITexture* texture=getGui()->getTexture("carbone.jpg");
-    fl_arm=new MeshSceneNode(this, red_arm, vector3df(0,0,0),vector3df(0,0,-135));
-    fr_arm=new MeshSceneNode(this, red_arm, vector3df(0,0,0),vector3df(0,0,-45));
-    rl_arm=new MeshSceneNode(this, black_arm, vector3df(0,0,0),vector3df(0,0,135),texture);
-    rr_arm=new MeshSceneNode(this, black_arm, vector3df(0,0,0),vector3df(0,0,45),texture);
-
-    texture=getGui()->getTexture("metal047.jpg");
-    fl_motor=new MeshSceneNode(this, motor, vector3df(70.71,-70.71,2.5),vector3df(90,0,0),texture);
-    fr_motor=new MeshSceneNode(this, motor ,vector3df(70.71,70.71,2.5),vector3df(90,0,0),texture);
-    rl_motor=new MeshSceneNode(this, motor ,vector3df(-70.71,-70.71,2.5),vector3df(90,0,0),texture);
-    rr_motor=new MeshSceneNode(this, motor ,vector3df(-70.71,70.71,2.5),vector3df(90,0,0),texture);
-
-    fl_blade=new Blade(this, vector3df(70.71,-70.71,17.5));
-    fr_blade=new Blade(this, vector3df(70.71,70.71,17.5),true);
-    rl_blade=new Blade(this, vector3df(-70.71,-70.71,17.5),true);
-    rr_blade=new Blade(this, vector3df(-70.71,70.71,17.5));
-
-    motor_speed_mutex=new Mutex(this);
-    for(int i=0;i<4;i++) motor_speed[i]=0;
-    ExtraDraw();
-}
-
-void X4::AnimateModel(void)
-{
-    motor_speed_mutex->GetMutex();
-    fl_blade->SetRotationSpeed(K_MOT*motor_speed[0]);
-    fr_blade->SetRotationSpeed(-K_MOT*motor_speed[1]);
-    rl_blade->SetRotationSpeed(-K_MOT*motor_speed[2]);
-    rr_blade->SetRotationSpeed(K_MOT*motor_speed[3]);
-    motor_speed_mutex->ReleaseMutex();
-
-    //adapt UAV size
-    if(arm_length->ValueChanged()==true)
-    {
-        setScale(arm_length->Value());
-    }
-}
-
-size_t X4::dbtSize(void) const
-{
-    return 6*sizeof(float)+4*sizeof(float);//6ddl+4helices
-}
-
-void X4::WritedbtBuf(char* dbtbuf)
-{/*
-    float *buf=(float*)dbtbuf;
-    vector3df vect=getPosition();
-    memcpy(buf,&vect.X,sizeof(float));
-    buf++;
-    memcpy(buf,&vect.Y,sizeof(float));
-    buf++;
-    memcpy(buf,&vect.Z,sizeof(float));
-    buf++;
-    vect=getRotation();
-    memcpy(buf,&vect.X,sizeof(float));
-    buf++;
-    memcpy(buf,&vect.Y,sizeof(float));
-    buf++;
-    memcpy(buf,&vect.Z,sizeof(float));
-    buf++;
-    memcpy(buf,&motors,sizeof(rtsimu_motors));*/
-}
-
-void X4::ReaddbtBuf(char* dbtbuf)
-{/*
-    float *buf=(float*)dbtbuf;
-    vector3df vect;
-    memcpy(&vect.X,buf,sizeof(float));
-    buf++;
-    memcpy(&vect.Y,buf,sizeof(float));
-    buf++;
-    memcpy(&vect.Z,buf,sizeof(float));
-    buf++;
-    setPosition(vect);
-    memcpy(&vect.X,buf,sizeof(float));
-    buf++;
-    memcpy(&vect.Y,buf,sizeof(float));
-    buf++;
-    memcpy(&vect.Z,buf,sizeof(float));
-    buf++;
-    ((ISceneNode*)(this))->setRotation(vect);
-    memcpy(&motors,buf,sizeof(rtsimu_motors));
-    AnimateModele();*/
-}
-#endif //GL
-
-//states are computed on fixed frame NED
-//x north
-//y east
-//z down
-void X4::CalcModel(void)
-{
-    float fl_speed,fr_speed,rl_speed,rr_speed;
-    float u_roll,u_pitch,u_yaw,u_thrust;
-#ifdef GL
-    motor_speed_mutex->GetMutex();
-#endif //GL
-    motors->GetSpeeds(motor_speed);
-#ifdef GL
-    motor_speed_mutex->ReleaseMutex();
-#endif //GL
-	fl_speed=motor_speed[0];
-	fr_speed=motor_speed[1];
-	rl_speed=motor_speed[2];
-	rr_speed=motor_speed[3];
-
-    /*
-	** ===================================================================
-	**    u roll: roll torque
-	**
-	** ===================================================================
-	*/
-	u_roll=arm_length->Value()*k_mot->Value()*(fl_speed*fl_speed+rl_speed*rl_speed-fr_speed*fr_speed-rr_speed*rr_speed)*sqrtf(2)/2;
-
-    /// Classical Nonlinear model of a quadrotor ( This is the w_x angular speed of the quadri in the body frame). It is a discrete integrator
-	state[0].W.x=(dT()/j_roll->Value())*((j_yaw->Value()-j_pitch->Value())*state[-1].W.y*state[-1].W.z + u_roll) +state[-1].W.x;
-
-	//u_roll=arm_length->Value()*k_mot->Value()*(fl_speed*fl_speed+rl_speed*rl_speed-fr_speed*fr_speed-rr_speed*rr_speed)*sqrtf(2)/2;
-	//state[0].W.x=(dT()/j_roll->Value())*(u_roll-m->Value()*G*l_cg->Value()*sinf(state[-2].W.x)-f_air_vert->Value()*arm_length->Value()*arm_length->Value()*state[-1].W.x)+state[-1].W.x;
-
-	/*
-	** ===================================================================
-	**   u pitch : pitch torque
-	**
-	** ===================================================================
-	*/
-	u_pitch=arm_length->Value()*k_mot->Value()*(fl_speed*fl_speed+fr_speed*fr_speed-rl_speed*rl_speed-rr_speed*rr_speed)*sqrtf(2)/2;
-
-    /// Classical Nonlinear model of a quadrotor ( This is the w_y angular speed of the quadri in the body frame). It is a discrete integrator
-	state[0].W.y=(dT()/j_pitch->Value())*((j_roll->Value()-j_yaw->Value())*state[-1].W.x*state[-1].W.z + u_pitch)+state[-1].W.y;
-
-	//u_pitch=arm_length->Value()*k_mot->Value()*(fl_speed*fl_speed+fr_speed*fr_speed-rl_speed*rl_speed-rr_speed*rr_speed)*sqrtf(2)/2;
-	//state[0].W.y=(dT()/j_pitch->Value())*(u_pitch-m->Value()*G*l_cg->Value()*sinf(state[-2].W.y)-f_air_vert->Value()*arm_length->Value()*arm_length->Value()*state[-1].W.y)+state[-1].W.y;
-
-	/*
-	** ===================================================================
-	**    u yaw : yaw torque
-	**
-	** ===================================================================
-	*/
-	u_yaw=c_mot->Value()*(fl_speed*fl_speed+rr_speed*rr_speed-fr_speed*fr_speed-rl_speed*rl_speed);
-
-    /// Classical Nonlinear model of a quadrotor ( This is the w_z angular speed of the quadri in the body frame). It is a discrete integrator
-	state[0].W.z=(dT()/j_yaw->Value())* u_yaw +state[-1].W.z;
-
-	//u_yaw=c_mot->Value()*(fl_speed*fl_speed+rr_speed*rr_speed-fr_speed*fr_speed-rl_speed*rl_speed);
-	//state[0].W.z=(dT()/j_yaw->Value())*(u_yaw-f_air_lat->Value()*state[-1].W.z)+state[-1].W.z;
-
-    // compute quaternion from W
-    // Quaternion derivative: dQ = 0.5*(Q*Qw)
-    Quaternion dQ=state[-1].Quat.GetDerivative(state[0].W);
-
-    // Quaternion integration
-    state[0].Quat = state[-1].Quat +dQ*dT();
-    state[0].Quat.Normalize();
-
-    // Calculation of the thrust from the reference speed of motors
-	u_thrust=k_mot->Value()*(fl_speed*fl_speed+fr_speed*fr_speed+rl_speed*rl_speed+rr_speed*rr_speed);
-    Vector3D vect(0,0,-u_thrust);
-    vect.Rotate(state[0].Quat);
-
-    /*
-	** ===================================================================
-	**     x double integrator
-	**
-	** ===================================================================
-	*/
-	state[0].Pos.x=(dT()*dT()/m->Value())*(vect.x-f_air_lat->Value()*(state[-1].Pos.x-state[-2].Pos.x)/dT())+2*state[-1].Pos.x-state[-2].Pos.x;
-    state[0].Vel.x=(state[0].Pos.x-state[-1].Pos.x)/dT();
-
-	/*
-	** ===================================================================
-	**     y double integrator
-	**
-	** ===================================================================
-	*/
-	state[0].Pos.y=(dT()*dT()/m->Value())*(vect.y-f_air_lat->Value()*(state[-1].Pos.y-state[-2].Pos.y)/dT())+2*state[-1].Pos.y-state[-2].Pos.y;
-    state[0].Vel.y=(state[0].Pos.y-state[-1].Pos.y)/dT();
-
-	/*
-	** ===================================================================
-	**     z double integrator
-	**
-	** ===================================================================
-	*/
-	state[0].Pos.z=(dT()*dT()/m->Value())*(vect.z+f_air_vert->Value()*(state[-1].Pos.z-state[-2].Pos.z)/dT()+m->Value()*G)+2*state[-1].Pos.z-state[-2].Pos.z;
-    state[0].Vel.z=(state[0].Pos.z-state[-1].Pos.z)/dT();
+namespace flair {
+namespace simulator {
+
+X4::X4(const Simulator *parent, std::string name, int dev_id)
+    : Model(parent, name) {
+  Tab *setup_tab = new Tab(GetTabWidget(), "model");
+  m = new DoubleSpinBox(setup_tab->NewRow(), "mass (kg):", 0, 20, 0.1);
+  arm_length = new DoubleSpinBox(setup_tab->LastRowLastCol(), "arm length (m):",
+                                 0, 2, 0.1);
+  // l_cg=new DoubleSpinBox(setup_tab,"position G
+  // (m):",0,2,-0.5,0.5,0.02);//position du centre de gravité/centre de poussé
+  k_mot =
+      new DoubleSpinBox(setup_tab->NewRow(), "k_mot:", 0, 1, 0.001,
+                        3); // vitesse rotation² (unité arbitraire) -> force (N)
+  c_mot = new DoubleSpinBox(
+      setup_tab->LastRowLastCol(), "c_mot:", 0, 1, 0.001,
+      3); // vitesse rotation moteur -> couple (N.m/unité arbitraire)
+  f_air_vert = new DoubleSpinBox(setup_tab->NewRow(), "f_air_vert:", 0, 10,
+                                 1); // frottements air depl. vertical, aussi
+                                     // utilisé pour les rotations ( N/(m/s) )
+                                     // (du aux helices en rotation)
+  f_air_lat =
+      new DoubleSpinBox(setup_tab->LastRowLastCol(), "f_air_lat:", 0, 10,
+                        1); // frottements air deplacements lateraux ( N/(m/s) )
+  j_roll = new DoubleSpinBox(setup_tab->NewRow(), "j_roll:", 0, 1, 0.001,
+                             5); // moment d'inertie d'un axe (N.m.s²/rad)
+  j_pitch =
+      new DoubleSpinBox(setup_tab->LastRowLastCol(), "j_pitch:", 0, 1, 0.001,
+                        5); // moment d'inertie d'un axe (N.m.s²/rad)
+  j_yaw = new DoubleSpinBox(setup_tab->LastRowLastCol(), "j_yaw:", 0, 1, 0.001,
+                            5); // moment d'inertie d'un axe (N.m.s²/rad)
+
+  motors = new SimuBldc(this, name, 4, dev_id);
+}
+
+X4::~X4() {
+  // les objets irrlicht seront automatiquement detruits (moteurs, helices,
+  // pales) par parenté
+}
+
+#ifdef GL
+
+void X4::Draw(void) {
+  // create unite (1m=100cm) UAV; scale will be adapted according to arm_length
+  // parameter
+  // note that the frame used is irrlicht one:
+  // left handed, North East Up
+  const IGeometryCreator *geo;
+  geo = getGui()->getSceneManager()->getGeometryCreator();
+
+  // cylinders are aligned with y axis
+  red_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 255, 0, 0));
+  black_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 128, 128, 128));
+  motor = geo->createCylinderMesh(7.5, 15, 16); //,SColor(0, 128, 128, 128));
+  // geo->drop();
+
+  ITexture *texture = getGui()->getTexture("carbone.jpg");
+  fl_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
+                             vector3df(0, 0, -135));
+  fr_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
+                             vector3df(0, 0, -45));
+  rl_arm = new MeshSceneNode(this, black_arm, vector3df(0, 0, 0),
+                             vector3df(0, 0, 135), texture);
+  rr_arm = new MeshSceneNode(this, black_arm, vector3df(0, 0, 0),
+                             vector3df(0, 0, 45), texture);
+
+  texture = getGui()->getTexture("metal047.jpg");
+  fl_motor = new MeshSceneNode(this, motor, vector3df(70.71, -70.71, 2.5),
+                               vector3df(90, 0, 0), texture);
+  fr_motor = new MeshSceneNode(this, motor, vector3df(70.71, 70.71, 2.5),
+                               vector3df(90, 0, 0), texture);
+  rl_motor = new MeshSceneNode(this, motor, vector3df(-70.71, -70.71, 2.5),
+                               vector3df(90, 0, 0), texture);
+  rr_motor = new MeshSceneNode(this, motor, vector3df(-70.71, 70.71, 2.5),
+                               vector3df(90, 0, 0), texture);
+
+  fl_blade = new Blade(this, vector3df(70.71, -70.71, 17.5));
+  fr_blade = new Blade(this, vector3df(70.71, 70.71, 17.5), true);
+  rl_blade = new Blade(this, vector3df(-70.71, -70.71, 17.5), true);
+  rr_blade = new Blade(this, vector3df(-70.71, 70.71, 17.5));
+
+  motor_speed_mutex = new Mutex(this);
+  for (int i = 0; i < 4; i++)
+    motor_speed[i] = 0;
+  ExtraDraw();
+}
+
+void X4::AnimateModel(void) {
+  motor_speed_mutex->GetMutex();
+  fl_blade->SetRotationSpeed(K_MOT * motor_speed[0]);
+  fr_blade->SetRotationSpeed(-K_MOT * motor_speed[1]);
+  rl_blade->SetRotationSpeed(-K_MOT * motor_speed[2]);
+  rr_blade->SetRotationSpeed(K_MOT * motor_speed[3]);
+  motor_speed_mutex->ReleaseMutex();
+
+  // adapt UAV size
+  if (arm_length->ValueChanged() == true) {
+    setScale(arm_length->Value());
+  }
+}
+
+size_t X4::dbtSize(void) const {
+  return 6 * sizeof(float) + 4 * sizeof(float); // 6ddl+4helices
+}
+
+void X4::WritedbtBuf(
+    char *dbtbuf) { /*
+                       float *buf=(float*)dbtbuf;
+                       vector3df vect=getPosition();
+                       memcpy(buf,&vect.X,sizeof(float));
+                       buf++;
+                       memcpy(buf,&vect.Y,sizeof(float));
+                       buf++;
+                       memcpy(buf,&vect.Z,sizeof(float));
+                       buf++;
+                       vect=getRotation();
+                       memcpy(buf,&vect.X,sizeof(float));
+                       buf++;
+                       memcpy(buf,&vect.Y,sizeof(float));
+                       buf++;
+                       memcpy(buf,&vect.Z,sizeof(float));
+                       buf++;
+                       memcpy(buf,&motors,sizeof(rtsimu_motors));*/
+}
+
+void X4::ReaddbtBuf(
+    char *dbtbuf) { /*
+                       float *buf=(float*)dbtbuf;
+                       vector3df vect;
+                       memcpy(&vect.X,buf,sizeof(float));
+                       buf++;
+                       memcpy(&vect.Y,buf,sizeof(float));
+                       buf++;
+                       memcpy(&vect.Z,buf,sizeof(float));
+                       buf++;
+                       setPosition(vect);
+                       memcpy(&vect.X,buf,sizeof(float));
+                       buf++;
+                       memcpy(&vect.Y,buf,sizeof(float));
+                       buf++;
+                       memcpy(&vect.Z,buf,sizeof(float));
+                       buf++;
+                       ((ISceneNode*)(this))->setRotation(vect);
+                       memcpy(&motors,buf,sizeof(rtsimu_motors));
+                       AnimateModele();*/
+}
+#endif // GL
+
+// states are computed on fixed frame NED
+// x north
+// y east
+// z down
+void X4::CalcModel(void) {
+  float fl_speed, fr_speed, rl_speed, rr_speed;
+  float u_roll, u_pitch, u_yaw, u_thrust;
+#ifdef GL
+  motor_speed_mutex->GetMutex();
+#endif // GL
+  motors->GetSpeeds(motor_speed);
+#ifdef GL
+  motor_speed_mutex->ReleaseMutex();
+#endif // GL
+  fl_speed = motor_speed[0];
+  fr_speed = motor_speed[1];
+  rl_speed = motor_speed[2];
+  rr_speed = motor_speed[3];
+
+  /*
+      ** ===================================================================
+      **    u roll: roll torque
+      **
+      ** ===================================================================
+      */
+  u_roll = arm_length->Value() * k_mot->Value() *
+           (fl_speed * fl_speed + rl_speed * rl_speed - fr_speed * fr_speed -
+            rr_speed * rr_speed) *
+           sqrtf(2) / 2;
+
+  /// Classical Nonlinear model of a quadrotor ( This is the w_x angular speed
+  /// of the quadri in the body frame). It is a discrete integrator
+  state[0].W.x =
+      (dT() / j_roll->Value()) *
+          ((j_yaw->Value() - j_pitch->Value()) * state[-1].W.y * state[-1].W.z +
+           u_roll) +
+      state[-1].W.x;
+
+  // u_roll=arm_length->Value()*k_mot->Value()*(fl_speed*fl_speed+rl_speed*rl_speed-fr_speed*fr_speed-rr_speed*rr_speed)*sqrtf(2)/2;
+  // state[0].W.x=(dT()/j_roll->Value())*(u_roll-m->Value()*G*l_cg->Value()*sinf(state[-2].W.x)-f_air_vert->Value()*arm_length->Value()*arm_length->Value()*state[-1].W.x)+state[-1].W.x;
+
+  /*
+  ** ===================================================================
+  **   u pitch : pitch torque
+  **
+  ** ===================================================================
+  */
+  u_pitch = arm_length->Value() * k_mot->Value() *
+            (fl_speed * fl_speed + fr_speed * fr_speed - rl_speed * rl_speed -
+             rr_speed * rr_speed) *
+            sqrtf(2) / 2;
+
+  /// Classical Nonlinear model of a quadrotor ( This is the w_y angular speed
+  /// of the quadri in the body frame). It is a discrete integrator
+  state[0].W.y =
+      (dT() / j_pitch->Value()) *
+          ((j_roll->Value() - j_yaw->Value()) * state[-1].W.x * state[-1].W.z +
+           u_pitch) +
+      state[-1].W.y;
+
+  // u_pitch=arm_length->Value()*k_mot->Value()*(fl_speed*fl_speed+fr_speed*fr_speed-rl_speed*rl_speed-rr_speed*rr_speed)*sqrtf(2)/2;
+  // state[0].W.y=(dT()/j_pitch->Value())*(u_pitch-m->Value()*G*l_cg->Value()*sinf(state[-2].W.y)-f_air_vert->Value()*arm_length->Value()*arm_length->Value()*state[-1].W.y)+state[-1].W.y;
+
+  /*
+  ** ===================================================================
+  **    u yaw : yaw torque
+  **
+  ** ===================================================================
+  */
+  u_yaw = c_mot->Value() * (fl_speed * fl_speed + rr_speed * rr_speed -
+                            fr_speed * fr_speed - rl_speed * rl_speed);
+
+  /// Classical Nonlinear model of a quadrotor ( This is the w_z angular speed
+  /// of the quadri in the body frame). It is a discrete integrator
+  state[0].W.z = (dT() / j_yaw->Value()) * u_yaw + state[-1].W.z;
+
+  // u_yaw=c_mot->Value()*(fl_speed*fl_speed+rr_speed*rr_speed-fr_speed*fr_speed-rl_speed*rl_speed);
+  // state[0].W.z=(dT()/j_yaw->Value())*(u_yaw-f_air_lat->Value()*state[-1].W.z)+state[-1].W.z;
+
+  // compute quaternion from W
+  // Quaternion derivative: dQ = 0.5*(Q*Qw)
+  Quaternion dQ = state[-1].Quat.GetDerivative(state[0].W);
+
+  // Quaternion integration
+  state[0].Quat = state[-1].Quat + dQ * dT();
+  state[0].Quat.Normalize();
+
+  // Calculation of the thrust from the reference speed of motors
+  u_thrust = k_mot->Value() * (fl_speed * fl_speed + fr_speed * fr_speed +
+                               rl_speed * rl_speed + rr_speed * rr_speed);
+  Vector3D vect(0, 0, -u_thrust);
+  vect.Rotate(state[0].Quat);
+
+  /*
+      ** ===================================================================
+      **     x double integrator
+      **
+      ** ===================================================================
+      */
+  state[0].Pos.x =
+      (dT() * dT() / m->Value()) *
+          (vect.x -
+           f_air_lat->Value() * (state[-1].Pos.x - state[-2].Pos.x) / dT()) +
+      2 * state[-1].Pos.x - state[-2].Pos.x;
+  state[0].Vel.x = (state[0].Pos.x - state[-1].Pos.x) / dT();
+
+  /*
+  ** ===================================================================
+  **     y double integrator
+  **
+  ** ===================================================================
+  */
+  state[0].Pos.y =
+      (dT() * dT() / m->Value()) *
+          (vect.y -
+           f_air_lat->Value() * (state[-1].Pos.y - state[-2].Pos.y) / dT()) +
+      2 * state[-1].Pos.y - state[-2].Pos.y;
+  state[0].Vel.y = (state[0].Pos.y - state[-1].Pos.y) / dT();
+
+  /*
+  ** ===================================================================
+  **     z double integrator
+  **
+  ** ===================================================================
+  */
+  state[0].Pos.z =
+      (dT() * dT() / m->Value()) *
+          (vect.z +
+           f_air_vert->Value() * (state[-1].Pos.z - state[-2].Pos.z) / dT() +
+           m->Value() * G) +
+      2 * state[-1].Pos.z - state[-2].Pos.z;
+  state[0].Vel.z = (state[0].Pos.z - state[-1].Pos.z) / dT();
 
 #ifndef GL
-    if(state[0].Pos.z<0) state[0].Pos.z=0;
+  if (state[0].Pos.z < 0)
+    state[0].Pos.z = 0;
 #endif
-
 }
 
Index: trunk/lib/FlairSimulator/src/X4.h
===================================================================
--- trunk/lib/FlairSimulator/src/X4.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/X4.h	(revision 15)
@@ -22,71 +22,62 @@
 #include <stdio.h>
 
-namespace flair
-{
-    namespace core
-    {
-        class Mutex;
-    }
-    namespace gui
-    {
-        class DoubleSpinBox;
-    }
-    namespace actuator
-    {
-        class SimuBldc;
-    }
+namespace flair {
+namespace core {
+class Mutex;
+}
+namespace gui {
+class DoubleSpinBox;
+}
+namespace actuator {
+class SimuBldc;
+}
 }
 
 #ifdef GL
-namespace irr
-{
-    namespace scene
-    {
-        class IMesh;
-    }
+namespace irr {
+namespace scene {
+class IMesh;
+}
 }
 #endif
 
-namespace flair
-{
-namespace simulator
-{
-    class Simulator;
-    class Blade;
-    class MeshSceneNode;
+namespace flair {
+namespace simulator {
+class Simulator;
+class Blade;
+class MeshSceneNode;
 
-    class X4 : public Model
-    {
-        public:
-            X4(const Simulator* parent,std::string name, int dev_id);
-            ~X4();
+class X4 : public Model {
+public:
+  X4(const Simulator *parent, std::string name, int dev_id);
+  ~X4();
 #ifdef GL
-            virtual void Draw(void);
-            virtual void ExtraDraw(void){};
+  virtual void Draw(void);
+  virtual void ExtraDraw(void){};
 
-        protected:
-                    irr::scene::IMesh *red_arm,*black_arm,*motor;
-                    MeshSceneNode *fl_arm,*fr_arm,*rl_arm,*rr_arm;
-                    MeshSceneNode *fl_motor,*fr_motor,*rl_motor,*rr_motor;
-                    Blade *fl_blade,*fr_blade,*rl_blade,*rr_blade;
-                    core::Mutex *motor_speed_mutex;
+protected:
+  irr::scene::IMesh *red_arm, *black_arm, *motor;
+  MeshSceneNode *fl_arm, *fr_arm, *rl_arm, *rr_arm;
+  MeshSceneNode *fl_motor, *fr_motor, *rl_motor, *rr_motor;
+  Blade *fl_blade, *fr_blade, *rl_blade, *rr_blade;
+  core::Mutex *motor_speed_mutex;
 #endif
-        private:
-            void CalcModel(void);
-    #ifdef GL
-            bool OnEvent(const irr::SEvent& event){};
-            void AnimateModel(void);
-            size_t dbtSize(void) const;
-            void WritedbtBuf(char* dbtbuf);
-            void ReaddbtBuf(char* dbtbuf);
-    #endif
+private:
+  void CalcModel(void);
+#ifdef GL
+  bool OnEvent(const irr::SEvent &event){};
+  void AnimateModel(void);
+  size_t dbtSize(void) const;
+  void WritedbtBuf(char *dbtbuf);
+  void ReaddbtBuf(char *dbtbuf);
+#endif
 
-            actuator::SimuBldc *motors;
-            float motor_speed[4];
-            gui::DoubleSpinBox *m,*arm_length,*l_cg;
-            gui::DoubleSpinBox *k_mot,*c_mot;
-            gui::DoubleSpinBox *f_air_vert,*f_air_lat;
-            gui::DoubleSpinBox *j_roll,*j_pitch,*j_yaw;
-    };
+  actuator::SimuBldc *motors;
+  float motor_speed[4];
+  gui::DoubleSpinBox *m, *arm_length, *l_cg;
+  gui::DoubleSpinBox *k_mot, *c_mot;
+  gui::DoubleSpinBox *f_air_vert, *f_air_lat;
+  gui::DoubleSpinBox *j_roll, *j_pitch, *j_yaw;
+};
 } // end namespace simulator
 } // end namespace flair
Index: trunk/lib/FlairSimulator/src/X8.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/X8.cpp	(revision 10)
+++ trunk/lib/FlairSimulator/src/X8.cpp	(revision 15)
@@ -31,6 +31,6 @@
 #endif
 
-#define K_MOT 0.4f //blade animation
-#define G (float)9.81 //gravity ( N/(m/s²) )
+#define K_MOT 0.4f    // blade animation
+#define G (float)9.81 // gravity ( N/(m/s²) )
 
 #ifdef GL
@@ -43,280 +43,347 @@
 using namespace flair::actuator;
 
-namespace flair
-{
-namespace simulator
-{
-
-X8::X8(const Simulator* parent,std::string name, int dev_id): Model(parent,name)
-{
-    Tab *setup_tab=new Tab(GetTabWidget(),"model");
-        m=new DoubleSpinBox(setup_tab->NewRow(),"mass (kg):",0,20,0.1);
-        arm_length=new DoubleSpinBox(setup_tab->LastRowLastCol(),"arm length (m):",0,2,0.1);
-        l_cg=new DoubleSpinBox(setup_tab->LastRowLastCol(),"position G (m):",-0.5,0.5,0.02);//position du centre de gravité/centre de poussé
-        k_mot=new DoubleSpinBox(setup_tab->NewRow(),"k_mot:",0,1,0.001,3);// vitesse rotation² (unité arbitraire) -> force (N)
-        c_mot=new DoubleSpinBox(setup_tab->LastRowLastCol(),"c_mot:",0,1,0.001,3);// vitesse rotation moteur -> couple (N.m/unité arbitraire)
-        f_air_vert=new DoubleSpinBox(setup_tab->NewRow(),"f_air_vert:",0,10,1);//frottements air depl. vertical, aussi utilisé pour les rotations ( N/(m/s) ) (du aux helices en rotation)
-        f_air_lat=new DoubleSpinBox(setup_tab->LastRowLastCol(),"f_air_lat:",0,10,1);//frottements air deplacements lateraux ( N/(m/s) )
-        j_roll=new DoubleSpinBox(setup_tab->NewRow(),"j_roll:",0,1,0.001,5); //moment d'inertie d'un axe (N.m.s²/rad)
-        j_pitch=new DoubleSpinBox(setup_tab->LastRowLastCol(),"j_pitch:",0,1,0.001,5); //moment d'inertie d'un axe (N.m.s²/rad)
-        j_yaw=new DoubleSpinBox(setup_tab->LastRowLastCol(),"j_yaw:",0,1,0.001,5); //moment d'inertie d'un axe (N.m.s²/rad)
-        j_r=new DoubleSpinBox(setup_tab->NewRow(),"j_r:",0,1,0.001);// moment des helices (N.m.s²/rad)
-        sigma=new DoubleSpinBox(setup_tab->LastRowLastCol(),"sigma:",0,1,0.1); // coefficient de perte d efficacite aerodynamique (sans unite)
-        S=new DoubleSpinBox(setup_tab->LastRowLastCol(),"S:",1,2,0.1); // coefficient de forme des helices 1<S=1+Ss/Sprop<2 (sans unite)
-
-    motors=new SimuBldc(this,name,8,dev_id);
-}
-
-void X8::Draw(){
-#ifdef GL
-
-	//create unite (1m=100cm) UAV; scale will be adapted according to arm_length parameter
-    //note that the frame used is irrlicht one:
-    //left handed, North East Up
-
-    const IGeometryCreator *geo;
-    geo=getGui()->getSceneManager()->getGeometryCreator();
-
-    //cylinders are aligned with y axis
-    red_arm=geo->createCylinderMesh(2.5,100,16,SColor(0, 255, 0, 0));
-    black_arm=geo->createCylinderMesh(2.5,100,16,SColor(0, 128, 128, 128));
-    motor=geo->createCylinderMesh(7.5,15,16);//,SColor(0, 128, 128, 128));
-    //geo->drop();
-
-    ITexture* texture=getGui()->getTexture("carbone.jpg");
-    fl_arm=new MeshSceneNode(this, red_arm, vector3df(0,0,0),vector3df(0,0,-135));
-    fr_arm=new MeshSceneNode(this, red_arm, vector3df(0,0,0),vector3df(0,0,-45));
-    rl_arm=new MeshSceneNode(this, black_arm, vector3df(0,0,0),vector3df(0,0,135),texture);
-    rr_arm=new MeshSceneNode(this, black_arm, vector3df(0,0,0),vector3df(0,0,45),texture);
-
-    texture=getGui()->getTexture("metal047.jpg");
-    tfl_motor=new MeshSceneNode(this, motor, vector3df(70.71,-70.71,2.5),vector3df(90,0,0),texture);
-    tfr_motor=new MeshSceneNode(this, motor ,vector3df(70.71,70.71,2.5),vector3df(90,0,0),texture);
-    trl_motor=new MeshSceneNode(this, motor ,vector3df(-70.71,-70.71,2.5),vector3df(90,0,0),texture);
-    trr_motor=new MeshSceneNode(this, motor ,vector3df(-70.71,70.71,2.5),vector3df(90,0,0),texture);
-
-    bfl_motor=new MeshSceneNode(this, motor, vector3df(70.71,-70.71,-17.5),vector3df(90,0,0),texture);
-    bfr_motor=new MeshSceneNode(this, motor ,vector3df(70.71,70.71,-17.5),vector3df(90,0,0),texture);
-    brl_motor=new MeshSceneNode(this, motor ,vector3df(-70.71,-70.71,-17.5),vector3df(90,0,0),texture);
-    brr_motor=new MeshSceneNode(this, motor ,vector3df(-70.71,70.71,-17.5),vector3df(90,0,0),texture);
-
-    tfl_blade=new Blade(this, vector3df(70.71,-70.71,17.5));
-    tfr_blade=new Blade(this, vector3df(70.71,70.71,17.5),true);
-    trl_blade=new Blade(this, vector3df(-70.71,-70.71,17.5),true);
-    trr_blade=new Blade(this, vector3df(-70.71,70.71,17.5));
-
-    bfl_blade=new Blade(this, vector3df(70.71,-70.71,-17.5));
-    bfr_blade=new Blade(this, vector3df(70.71,70.71,-17.5),true);
-    brl_blade=new Blade(this, vector3df(-70.71,-70.71,-17.5),true);
-    brr_blade=new Blade(this, vector3df(-70.71,70.71,-17.5));
-
-    motor_speed_mutex=new Mutex(this);
-    for(int i=0;i<8;i++) motor_speed[i]=0;
-    ExtraDraw();
-    #endif
-}
-
-X8::~X8()
-{
-    //les objets irrlicht seront automatiquement detruits (moteurs, helices, pales) par parenté
-}
-
-#ifdef GL
-void X8::AnimateModel(void)
-{
-    motor_speed_mutex->GetMutex();
-    tfl_blade->SetRotationSpeed(K_MOT*motor_speed[0]);
-    tfr_blade->SetRotationSpeed(-K_MOT*motor_speed[1]);
-    trl_blade->SetRotationSpeed(-K_MOT*motor_speed[2]);
-    trr_blade->SetRotationSpeed(K_MOT*motor_speed[3]);
-
-    bfl_blade->SetRotationSpeed(-K_MOT*motor_speed[4]);
-    bfr_blade->SetRotationSpeed(K_MOT*motor_speed[5]);
-    brl_blade->SetRotationSpeed(K_MOT*motor_speed[6]);
-    brr_blade->SetRotationSpeed(-K_MOT*motor_speed[7]);
-    motor_speed_mutex->ReleaseMutex();
-
-    //adapt UAV size
-    if(arm_length->ValueChanged()==true)
-    {
-        setScale(arm_length->Value());
-    }
-}
-
-size_t X8::dbtSize(void) const
-{
-    return 6*sizeof(float)+4*sizeof(float);//6ddl+4helices
-}
-
-void X8::WritedbtBuf(char* dbtbuf)
-{/*
-    float *buf=(float*)dbtbuf;
-    vector3df vect=getPosition();
-    memcpy(buf,&vect.X,sizeof(float));
-    buf++;
-    memcpy(buf,&vect.Y,sizeof(float));
-    buf++;
-    memcpy(buf,&vect.Z,sizeof(float));
-    buf++;
-    vect=getRotation();
-    memcpy(buf,&vect.X,sizeof(float));
-    buf++;
-    memcpy(buf,&vect.Y,sizeof(float));
-    buf++;
-    memcpy(buf,&vect.Z,sizeof(float));
-    buf++;
-    memcpy(buf,&motors,sizeof(rtsimu_motors));*/
-}
-
-void X8::ReaddbtBuf(char* dbtbuf)
-{/*
-    float *buf=(float*)dbtbuf;
-    vector3df vect;
-    memcpy(&vect.X,buf,sizeof(float));
-    buf++;
-    memcpy(&vect.Y,buf,sizeof(float));
-    buf++;
-    memcpy(&vect.Z,buf,sizeof(float));
-    buf++;
-    setPosition(vect);
-    memcpy(&vect.X,buf,sizeof(float));
-    buf++;
-    memcpy(&vect.Y,buf,sizeof(float));
-    buf++;
-    memcpy(&vect.Z,buf,sizeof(float));
-    buf++;
-    ((ISceneNode*)(this))->setRotation(vect);
-    memcpy(&motors,buf,sizeof(rtsimu_motors));
-    AnimateModele();*/
-}
-#endif //GL
-
-//states are computed on fixed frame NED
-//x north
-//y east
-//z down
-void X8::CalcModel(void)
-{
-    float tfl_speed,tfr_speed,trl_speed,trr_speed;
-    float bfl_speed,bfr_speed,brl_speed,brr_speed;
-    float u_roll,u_pitch,u_yaw,u_thrust;
-    float omega;
-#ifdef GL
-    motor_speed_mutex->GetMutex();
-#endif //GL
-    motors->GetSpeeds(motor_speed);
-#ifdef GL
-    motor_speed_mutex->ReleaseMutex();
-#endif //GL
-	tfl_speed=motor_speed[0];
-	tfr_speed=motor_speed[1];
-	trl_speed=motor_speed[2];
-	trr_speed=motor_speed[3];
-	bfl_speed=motor_speed[4];
-	bfr_speed=motor_speed[5];
-	brl_speed=motor_speed[6];
-	brr_speed=motor_speed[7];
-
-	omega=tfl_speed+brl_speed+trr_speed+bfr_speed-bfl_speed-trl_speed-brr_speed-tfr_speed;
-
-
-    /*
-	** ===================================================================
-	**    u roll: roll torque
-	**
-	** ===================================================================
-	*/
-
-    u_roll=arm_length->Value()*k_mot->Value()*(sigma->Value()*tfl_speed*tfl_speed+bfl_speed*bfl_speed
-                                                +sigma->Value()*trl_speed*trl_speed+brl_speed*brl_speed
-                                                -sigma->Value()*tfr_speed*tfr_speed-bfr_speed*bfr_speed
-                                                -sigma->Value()*trr_speed*trr_speed-brr_speed*brr_speed)*sqrtf(2)/2;
-
-    /// Classical Nonlinear model of a quadrotor ( This is the w_x angular speed of the quadri in the body frame). It is a discrete integrator
-	//state[0].W.x=(dT()/j_roll->Value())*((j_yaw->Value()-j_pitch->Value())*state[-1].W.y*state[-1].W.z-j_r->Value()*state[-1].W.y*omega + u_roll) +state[-1].W.x;//Osamah
-    state[0].W.x=(dT()/j_roll->Value())*((j_pitch->Value()-j_yaw->Value())*state[-1].W.y*state[-1].W.z-j_r->Value()*state[-1].W.y*omega + u_roll) +state[-1].W.x;//Majd
-
-	//state[0].W.x=(dT()/j_roll->Value())*(u_roll-m->Value()*G*l_cg->Value()*sinf(state[-2].W.x)-f_air_vert->Value()*arm_length->Value()*arm_length->Value()*state[-1].W.x)+state[-1].W.x;
-
-	/*
-	** ===================================================================
-	**   u pitch : pitch torque
-	**
-	** ===================================================================
-	*/
-	u_pitch=arm_length->Value()*k_mot->Value()*(sigma->Value()*tfl_speed*tfl_speed+bfl_speed*bfl_speed
-                                             +sigma->Value()*tfr_speed*tfr_speed+bfr_speed*bfr_speed
-                                            -sigma->Value()*trl_speed*trl_speed-brl_speed*brl_speed
-                                             -sigma->Value()*trr_speed*trr_speed-brr_speed*brr_speed)*sqrtf(2)/2;
-
-    /// Classical Nonlinear model of a quadrotor ( This is the w_y angular speed of the quadri in the body frame). It is a discrete integrator
-	//state[0].W.y=(dT()/j_pitch->Value())*((j_roll->Value()-j_yaw->Value())*state[-1].W.x*state[-1].W.z-j_r->Value()*state[-1].W.x*omega + u_pitch)+state[-1].W.y;//Osamah
-    state[0].W.y=(dT()/j_pitch->Value())*((j_yaw->Value()-j_roll->Value())*state[-1].W.x*state[-1].W.z-j_r->Value()*state[-1].W.x*omega + u_pitch)+state[-1].W.y;//Majd
-
-   //state[0].W.y=(dT()/j_pitch->Value())*(u_pitch-m->Value()*G*l_cg->Value()*sinf(state[-2].W.y)-f_air_vert->Value()*arm_length->Value()*arm_length->Value()*state[-1].W.y)+state[-1].W.y;
-
-	/*
-	** ===================================================================
-	**    u yaw : yaw torque
-	**
-	** ===================================================================
-	*/
-	u_yaw=c_mot->Value()*(tfl_speed*tfl_speed-bfl_speed*bfl_speed
-                        +trr_speed*trr_speed-brr_speed*brr_speed
-                        -tfr_speed*tfr_speed+bfr_speed*bfr_speed
-                        -trl_speed*trl_speed+brl_speed*brl_speed);
-
-    /// Classical Nonlinear model of a quadrotor ( This is the w_z angular speed of the quadri in the body frame). It is a discrete integrator
-	//state[0].W.z=(dT()/j_yaw->Value())* u_yaw +state[-1].W.z;//Osamah
-	state[0].W.z=(dT()/j_yaw->Value())*((j_roll->Value()-j_pitch->Value())*state[-1].W.x*state[-1].W.y+u_yaw )+state[-1].W.z;//Majd
-
-	//state[0].W.z=(dT()/j_yaw->Value())*(u_yaw-f_air_lat->Value()*state[-1].W.z)+state[-1].W.z;
-
-    // compute quaternion from W
-    // Quaternion derivative: dQ = 0.5*(Q*Qw)
-    Quaternion dQ=state[-1].Quat.GetDerivative(state[0].W);
-
-    // Quaternion integration
-    state[0].Quat =state[-1].Quat +dQ*dT();
-    state[0].Quat.Normalize();
-
-    // Calculation of the thrust from the reference speed of motors
-    u_thrust=k_mot->Value()*S->Value()*
-       (sigma->Value()*tfl_speed*tfl_speed+sigma->Value()*tfr_speed*tfr_speed+sigma->Value()*trl_speed*trl_speed+sigma->Value()*trr_speed*trr_speed
-       +bfl_speed*bfl_speed+bfr_speed*bfr_speed+brl_speed*brl_speed+brr_speed*brr_speed);
-    Vector3D vect(0,0,-u_thrust);
-    vect.Rotate(state[0].Quat);
-
-    /*
-	** ===================================================================
-	**     x double integrator
-	**
-	** ===================================================================
-	*/
-	state[0].Pos.x=(dT()*dT()/m->Value())*(vect.x-f_air_lat->Value()*(state[-1].Pos.x-state[-2].Pos.x)/dT())+2*state[-1].Pos.x-state[-2].Pos.x;
-    state[0].Vel.x=(state[0].Pos.x-state[-1].Pos.x)/dT();
-
-    /*
-	** ===================================================================
-	**     y double integrator
-	**
-	** ===================================================================
-	*/
-	state[0].Pos.y=(dT()*dT()/m->Value())*(vect.y-f_air_lat->Value()*(state[-1].Pos.y-state[-2].Pos.y)/dT())+2*state[-1].Pos.y-state[-2].Pos.y;
-    state[0].Vel.y=(state[0].Pos.y-state[-1].Pos.y)/dT();
-
-	/*
-	** ===================================================================
-	**     z double integrator
-	**
-	** ===================================================================
-	*/
-	state[0].Pos.z=(dT()*dT()/m->Value())*(vect.z+f_air_vert->Value()*(state[-1].Pos.z-state[-2].Pos.z)/dT()+m->Value()*G)+2*state[-1].Pos.z-state[-2].Pos.z;
-    state[0].Vel.z=(state[0].Pos.z-state[-1].Pos.z)/dT();
+namespace flair {
+namespace simulator {
+
+X8::X8(const Simulator *parent, std::string name, int dev_id)
+    : Model(parent, name) {
+  Tab *setup_tab = new Tab(GetTabWidget(), "model");
+  m = new DoubleSpinBox(setup_tab->NewRow(), "mass (kg):", 0, 20, 0.1);
+  arm_length = new DoubleSpinBox(setup_tab->LastRowLastCol(), "arm length (m):",
+                                 0, 2, 0.1);
+  l_cg = new DoubleSpinBox(
+      setup_tab->LastRowLastCol(), "position G (m):", -0.5, 0.5,
+      0.02); // position du centre de gravité/centre de poussé
+  k_mot =
+      new DoubleSpinBox(setup_tab->NewRow(), "k_mot:", 0, 1, 0.001,
+                        3); // vitesse rotation² (unité arbitraire) -> force (N)
+  c_mot = new DoubleSpinBox(
+      setup_tab->LastRowLastCol(), "c_mot:", 0, 1, 0.001,
+      3); // vitesse rotation moteur -> couple (N.m/unité arbitraire)
+  f_air_vert = new DoubleSpinBox(setup_tab->NewRow(), "f_air_vert:", 0, 10,
+                                 1); // frottements air depl. vertical, aussi
+                                     // utilisé pour les rotations ( N/(m/s) )
+                                     // (du aux helices en rotation)
+  f_air_lat =
+      new DoubleSpinBox(setup_tab->LastRowLastCol(), "f_air_lat:", 0, 10,
+                        1); // frottements air deplacements lateraux ( N/(m/s) )
+  j_roll = new DoubleSpinBox(setup_tab->NewRow(), "j_roll:", 0, 1, 0.001,
+                             5); // moment d'inertie d'un axe (N.m.s²/rad)
+  j_pitch =
+      new DoubleSpinBox(setup_tab->LastRowLastCol(), "j_pitch:", 0, 1, 0.001,
+                        5); // moment d'inertie d'un axe (N.m.s²/rad)
+  j_yaw = new DoubleSpinBox(setup_tab->LastRowLastCol(), "j_yaw:", 0, 1, 0.001,
+                            5); // moment d'inertie d'un axe (N.m.s²/rad)
+  j_r = new DoubleSpinBox(setup_tab->NewRow(), "j_r:", 0, 1,
+                          0.001); // moment des helices (N.m.s²/rad)
+  sigma = new DoubleSpinBox(
+      setup_tab->LastRowLastCol(), "sigma:", 0, 1,
+      0.1); // coefficient de perte d efficacite aerodynamique (sans unite)
+  S = new DoubleSpinBox(
+      setup_tab->LastRowLastCol(), "S:", 1, 2,
+      0.1); // coefficient de forme des helices 1<S=1+Ss/Sprop<2 (sans unite)
+
+  motors = new SimuBldc(this, name, 8, dev_id);
+}
+
+void X8::Draw() {
+#ifdef GL
+
+  // create unite (1m=100cm) UAV; scale will be adapted according to arm_length
+  // parameter
+  // note that the frame used is irrlicht one:
+  // left handed, North East Up
+
+  const IGeometryCreator *geo;
+  geo = getGui()->getSceneManager()->getGeometryCreator();
+
+  // cylinders are aligned with y axis
+  red_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 255, 0, 0));
+  black_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 128, 128, 128));
+  motor = geo->createCylinderMesh(7.5, 15, 16); //,SColor(0, 128, 128, 128));
+  // geo->drop();
+
+  ITexture *texture = getGui()->getTexture("carbone.jpg");
+  fl_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
+                             vector3df(0, 0, -135));
+  fr_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
+                             vector3df(0, 0, -45));
+  rl_arm = new MeshSceneNode(this, black_arm, vector3df(0, 0, 0),
+                             vector3df(0, 0, 135), texture);
+  rr_arm = new MeshSceneNode(this, black_arm, vector3df(0, 0, 0),
+                             vector3df(0, 0, 45), texture);
+
+  texture = getGui()->getTexture("metal047.jpg");
+  tfl_motor = new MeshSceneNode(this, motor, vector3df(70.71, -70.71, 2.5),
+                                vector3df(90, 0, 0), texture);
+  tfr_motor = new MeshSceneNode(this, motor, vector3df(70.71, 70.71, 2.5),
+                                vector3df(90, 0, 0), texture);
+  trl_motor = new MeshSceneNode(this, motor, vector3df(-70.71, -70.71, 2.5),
+                                vector3df(90, 0, 0), texture);
+  trr_motor = new MeshSceneNode(this, motor, vector3df(-70.71, 70.71, 2.5),
+                                vector3df(90, 0, 0), texture);
+
+  bfl_motor = new MeshSceneNode(this, motor, vector3df(70.71, -70.71, -17.5),
+                                vector3df(90, 0, 0), texture);
+  bfr_motor = new MeshSceneNode(this, motor, vector3df(70.71, 70.71, -17.5),
+                                vector3df(90, 0, 0), texture);
+  brl_motor = new MeshSceneNode(this, motor, vector3df(-70.71, -70.71, -17.5),
+                                vector3df(90, 0, 0), texture);
+  brr_motor = new MeshSceneNode(this, motor, vector3df(-70.71, 70.71, -17.5),
+                                vector3df(90, 0, 0), texture);
+
+  tfl_blade = new Blade(this, vector3df(70.71, -70.71, 17.5));
+  tfr_blade = new Blade(this, vector3df(70.71, 70.71, 17.5), true);
+  trl_blade = new Blade(this, vector3df(-70.71, -70.71, 17.5), true);
+  trr_blade = new Blade(this, vector3df(-70.71, 70.71, 17.5));
+
+  bfl_blade = new Blade(this, vector3df(70.71, -70.71, -17.5));
+  bfr_blade = new Blade(this, vector3df(70.71, 70.71, -17.5), true);
+  brl_blade = new Blade(this, vector3df(-70.71, -70.71, -17.5), true);
+  brr_blade = new Blade(this, vector3df(-70.71, 70.71, -17.5));
+
+  motor_speed_mutex = new Mutex(this);
+  for (int i = 0; i < 8; i++)
+    motor_speed[i] = 0;
+  ExtraDraw();
+#endif
+}
+
+X8::~X8() {
+  // les objets irrlicht seront automatiquement detruits (moteurs, helices,
+  // pales) par parenté
+}
+
+#ifdef GL
+void X8::AnimateModel(void) {
+  motor_speed_mutex->GetMutex();
+  tfl_blade->SetRotationSpeed(K_MOT * motor_speed[0]);
+  tfr_blade->SetRotationSpeed(-K_MOT * motor_speed[1]);
+  trl_blade->SetRotationSpeed(-K_MOT * motor_speed[2]);
+  trr_blade->SetRotationSpeed(K_MOT * motor_speed[3]);
+
+  bfl_blade->SetRotationSpeed(-K_MOT * motor_speed[4]);
+  bfr_blade->SetRotationSpeed(K_MOT * motor_speed[5]);
+  brl_blade->SetRotationSpeed(K_MOT * motor_speed[6]);
+  brr_blade->SetRotationSpeed(-K_MOT * motor_speed[7]);
+  motor_speed_mutex->ReleaseMutex();
+
+  // adapt UAV size
+  if (arm_length->ValueChanged() == true) {
+    setScale(arm_length->Value());
+  }
+}
+
+size_t X8::dbtSize(void) const {
+  return 6 * sizeof(float) + 4 * sizeof(float); // 6ddl+4helices
+}
+
+void X8::WritedbtBuf(
+    char *dbtbuf) { /*
+                       float *buf=(float*)dbtbuf;
+                       vector3df vect=getPosition();
+                       memcpy(buf,&vect.X,sizeof(float));
+                       buf++;
+                       memcpy(buf,&vect.Y,sizeof(float));
+                       buf++;
+                       memcpy(buf,&vect.Z,sizeof(float));
+                       buf++;
+                       vect=getRotation();
+                       memcpy(buf,&vect.X,sizeof(float));
+                       buf++;
+                       memcpy(buf,&vect.Y,sizeof(float));
+                       buf++;
+                       memcpy(buf,&vect.Z,sizeof(float));
+                       buf++;
+                       memcpy(buf,&motors,sizeof(rtsimu_motors));*/
+}
+
+void X8::ReaddbtBuf(
+    char *dbtbuf) { /*
+                       float *buf=(float*)dbtbuf;
+                       vector3df vect;
+                       memcpy(&vect.X,buf,sizeof(float));
+                       buf++;
+                       memcpy(&vect.Y,buf,sizeof(float));
+                       buf++;
+                       memcpy(&vect.Z,buf,sizeof(float));
+                       buf++;
+                       setPosition(vect);
+                       memcpy(&vect.X,buf,sizeof(float));
+                       buf++;
+                       memcpy(&vect.Y,buf,sizeof(float));
+                       buf++;
+                       memcpy(&vect.Z,buf,sizeof(float));
+                       buf++;
+                       ((ISceneNode*)(this))->setRotation(vect);
+                       memcpy(&motors,buf,sizeof(rtsimu_motors));
+                       AnimateModele();*/
+}
+#endif // GL
+
+// states are computed on fixed frame NED
+// x north
+// y east
+// z down
+void X8::CalcModel(void) {
+  float tfl_speed, tfr_speed, trl_speed, trr_speed;
+  float bfl_speed, bfr_speed, brl_speed, brr_speed;
+  float u_roll, u_pitch, u_yaw, u_thrust;
+  float omega;
+#ifdef GL
+  motor_speed_mutex->GetMutex();
+#endif // GL
+  motors->GetSpeeds(motor_speed);
+#ifdef GL
+  motor_speed_mutex->ReleaseMutex();
+#endif // GL
+  tfl_speed = motor_speed[0];
+  tfr_speed = motor_speed[1];
+  trl_speed = motor_speed[2];
+  trr_speed = motor_speed[3];
+  bfl_speed = motor_speed[4];
+  bfr_speed = motor_speed[5];
+  brl_speed = motor_speed[6];
+  brr_speed = motor_speed[7];
+
+  omega = tfl_speed + brl_speed + trr_speed + bfr_speed - bfl_speed -
+          trl_speed - brr_speed - tfr_speed;
+
+  /*
+      ** ===================================================================
+      **    u roll: roll torque
+      **
+      ** ===================================================================
+      */
+
+  u_roll = arm_length->Value() * k_mot->Value() *
+           (sigma->Value() * tfl_speed * tfl_speed + bfl_speed * bfl_speed +
+            sigma->Value() * trl_speed * trl_speed + brl_speed * brl_speed -
+            sigma->Value() * tfr_speed * tfr_speed - bfr_speed * bfr_speed -
+            sigma->Value() * trr_speed * trr_speed - brr_speed * brr_speed) *
+           sqrtf(2) / 2;
+
+  /// Classical Nonlinear model of a quadrotor ( This is the w_x angular speed
+  /// of the quadri in the body frame). It is a discrete integrator
+  // state[0].W.x=(dT()/j_roll->Value())*((j_yaw->Value()-j_pitch->Value())*state[-1].W.y*state[-1].W.z-j_r->Value()*state[-1].W.y*omega
+  // + u_roll) +state[-1].W.x;//Osamah
+  state[0].W.x =
+      (dT() / j_roll->Value()) *
+          ((j_pitch->Value() - j_yaw->Value()) * state[-1].W.y * state[-1].W.z -
+           j_r->Value() * state[-1].W.y * omega + u_roll) +
+      state[-1].W.x; // Majd
+
+  // state[0].W.x=(dT()/j_roll->Value())*(u_roll-m->Value()*G*l_cg->Value()*sinf(state[-2].W.x)-f_air_vert->Value()*arm_length->Value()*arm_length->Value()*state[-1].W.x)+state[-1].W.x;
+
+  /*
+  ** ===================================================================
+  **   u pitch : pitch torque
+  **
+  ** ===================================================================
+  */
+  u_pitch = arm_length->Value() * k_mot->Value() *
+            (sigma->Value() * tfl_speed * tfl_speed + bfl_speed * bfl_speed +
+             sigma->Value() * tfr_speed * tfr_speed + bfr_speed * bfr_speed -
+             sigma->Value() * trl_speed * trl_speed - brl_speed * brl_speed -
+             sigma->Value() * trr_speed * trr_speed - brr_speed * brr_speed) *
+            sqrtf(2) / 2;
+
+  /// Classical Nonlinear model of a quadrotor ( This is the w_y angular speed
+  /// of the quadri in the body frame). It is a discrete integrator
+  // state[0].W.y=(dT()/j_pitch->Value())*((j_roll->Value()-j_yaw->Value())*state[-1].W.x*state[-1].W.z-j_r->Value()*state[-1].W.x*omega
+  // + u_pitch)+state[-1].W.y;//Osamah
+  state[0].W.y =
+      (dT() / j_pitch->Value()) *
+          ((j_yaw->Value() - j_roll->Value()) * state[-1].W.x * state[-1].W.z -
+           j_r->Value() * state[-1].W.x * omega + u_pitch) +
+      state[-1].W.y; // Majd
+
+  // state[0].W.y=(dT()/j_pitch->Value())*(u_pitch-m->Value()*G*l_cg->Value()*sinf(state[-2].W.y)-f_air_vert->Value()*arm_length->Value()*arm_length->Value()*state[-1].W.y)+state[-1].W.y;
+
+  /*
+  ** ===================================================================
+  **    u yaw : yaw torque
+  **
+  ** ===================================================================
+  */
+  u_yaw = c_mot->Value() * (tfl_speed * tfl_speed - bfl_speed * bfl_speed +
+                            trr_speed * trr_speed - brr_speed * brr_speed -
+                            tfr_speed * tfr_speed + bfr_speed * bfr_speed -
+                            trl_speed * trl_speed + brl_speed * brl_speed);
+
+  /// Classical Nonlinear model of a quadrotor ( This is the w_z angular speed
+  /// of the quadri in the body frame). It is a discrete integrator
+  // state[0].W.z=(dT()/j_yaw->Value())* u_yaw +state[-1].W.z;//Osamah
+  state[0].W.z =
+      (dT() / j_yaw->Value()) * ((j_roll->Value() - j_pitch->Value()) *
+                                     state[-1].W.x * state[-1].W.y +
+                                 u_yaw) +
+      state[-1].W.z; // Majd
+
+  // state[0].W.z=(dT()/j_yaw->Value())*(u_yaw-f_air_lat->Value()*state[-1].W.z)+state[-1].W.z;
+
+  // compute quaternion from W
+  // Quaternion derivative: dQ = 0.5*(Q*Qw)
+  Quaternion dQ = state[-1].Quat.GetDerivative(state[0].W);
+
+  // Quaternion integration
+  state[0].Quat = state[-1].Quat + dQ * dT();
+  state[0].Quat.Normalize();
+
+  // Calculation of the thrust from the reference speed of motors
+  u_thrust =
+      k_mot->Value() * S->Value() *
+      (sigma->Value() * tfl_speed * tfl_speed +
+       sigma->Value() * tfr_speed * tfr_speed +
+       sigma->Value() * trl_speed * trl_speed +
+       sigma->Value() * trr_speed * trr_speed + bfl_speed * bfl_speed +
+       bfr_speed * bfr_speed + brl_speed * brl_speed + brr_speed * brr_speed);
+  Vector3D vect(0, 0, -u_thrust);
+  vect.Rotate(state[0].Quat);
+
+  /*
+      ** ===================================================================
+      **     x double integrator
+      **
+      ** ===================================================================
+      */
+  state[0].Pos.x =
+      (dT() * dT() / m->Value()) *
+          (vect.x -
+           f_air_lat->Value() * (state[-1].Pos.x - state[-2].Pos.x) / dT()) +
+      2 * state[-1].Pos.x - state[-2].Pos.x;
+  state[0].Vel.x = (state[0].Pos.x - state[-1].Pos.x) / dT();
+
+  /*
+      ** ===================================================================
+      **     y double integrator
+      **
+      ** ===================================================================
+      */
+  state[0].Pos.y =
+      (dT() * dT() / m->Value()) *
+          (vect.y -
+           f_air_lat->Value() * (state[-1].Pos.y - state[-2].Pos.y) / dT()) +
+      2 * state[-1].Pos.y - state[-2].Pos.y;
+  state[0].Vel.y = (state[0].Pos.y - state[-1].Pos.y) / dT();
+
+  /*
+  ** ===================================================================
+  **     z double integrator
+  **
+  ** ===================================================================
+  */
+  state[0].Pos.z =
+      (dT() * dT() / m->Value()) *
+          (vect.z +
+           f_air_vert->Value() * (state[-1].Pos.z - state[-2].Pos.z) / dT() +
+           m->Value() * G) +
+      2 * state[-1].Pos.z - state[-2].Pos.z;
+  state[0].Vel.z = (state[0].Pos.z - state[-1].Pos.z) / dT();
 
 #ifndef GL
-    if(state[0].Pos.z<0) state[0].Pos.z=0;
+  if (state[0].Pos.z < 0)
+    state[0].Pos.z = 0;
 #endif
-
 }
 
Index: trunk/lib/FlairSimulator/src/X8.h
===================================================================
--- trunk/lib/FlairSimulator/src/X8.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/X8.h	(revision 15)
@@ -21,73 +21,65 @@
 #include <stdint.h>
 
-namespace flair
-{
-    namespace core
-    {
-        class Mutex;
-    }
-    namespace gui
-    {
-        class DoubleSpinBox;
-    }
-    namespace actuator
-    {
-        class SimuBldc;
-    }
+namespace flair {
+namespace core {
+class Mutex;
+}
+namespace gui {
+class DoubleSpinBox;
+}
+namespace actuator {
+class SimuBldc;
+}
 }
 
 #ifdef GL
-namespace irr
-{
-    namespace scene
-    {
-        class IMesh;
-    }
+namespace irr {
+namespace scene {
+class IMesh;
+}
 }
 #endif
 
-namespace flair
-{
-namespace simulator
-{
-    class Simulator;
-    class Blade;
-    class MeshSceneNode;
+namespace flair {
+namespace simulator {
+class Simulator;
+class Blade;
+class MeshSceneNode;
 
-    class X8 : public Model
-    {
-        public:
-            X8(const Simulator* parent,std::string name, int dev_id);
-            ~X8();
-            virtual void Draw(void);
-			virtual void ExtraDraw(void){};
-        protected:
+class X8 : public Model {
+public:
+  X8(const Simulator *parent, std::string name, int dev_id);
+  ~X8();
+  virtual void Draw(void);
+  virtual void ExtraDraw(void){};
+
+protected:
 #ifdef GL
-            irr::scene::IMesh *red_arm,*black_arm,*motor;
-			MeshSceneNode *fl_arm,*fr_arm,*rl_arm,*rr_arm;
-			MeshSceneNode *tfl_motor,*tfr_motor,*trl_motor,*trr_motor;
-			MeshSceneNode *bfl_motor,*bfr_motor,*brl_motor,*brr_motor;
-			Blade *tfl_blade,*tfr_blade,*trl_blade,*trr_blade;
-			Blade *bfl_blade,*bfr_blade,*brl_blade,*brr_blade;
+  irr::scene::IMesh *red_arm, *black_arm, *motor;
+  MeshSceneNode *fl_arm, *fr_arm, *rl_arm, *rr_arm;
+  MeshSceneNode *tfl_motor, *tfr_motor, *trl_motor, *trr_motor;
+  MeshSceneNode *bfl_motor, *bfr_motor, *brl_motor, *brr_motor;
+  Blade *tfl_blade, *tfr_blade, *trl_blade, *trr_blade;
+  Blade *bfl_blade, *bfr_blade, *brl_blade, *brr_blade;
 #endif
-        private:
-            void CalcModel(void);
-    #ifdef GL
-            bool OnEvent(const irr::SEvent& event){};
-            void AnimateModel(void);
-            size_t dbtSize(void) const;
-            void WritedbtBuf(char* dbtbuf);
-            void ReaddbtBuf(char* dbtbuf);
-            core::Mutex *motor_speed_mutex;
-    #endif
+private:
+  void CalcModel(void);
+#ifdef GL
+  bool OnEvent(const irr::SEvent &event){};
+  void AnimateModel(void);
+  size_t dbtSize(void) const;
+  void WritedbtBuf(char *dbtbuf);
+  void ReaddbtBuf(char *dbtbuf);
+  core::Mutex *motor_speed_mutex;
+#endif
 
-            actuator::SimuBldc *motors;
-            float motor_speed[8];
-            gui::DoubleSpinBox *m,*arm_length,*l_cg;
-            gui::DoubleSpinBox *k_mot,*c_mot;
-            gui::DoubleSpinBox *f_air_vert,*f_air_lat;
-            gui::DoubleSpinBox *j_roll,*j_pitch,*j_yaw;
-            gui::DoubleSpinBox *j_r,*sigma,*S;
-    };
+  actuator::SimuBldc *motors;
+  float motor_speed[8];
+  gui::DoubleSpinBox *m, *arm_length, *l_cg;
+  gui::DoubleSpinBox *k_mot, *c_mot;
+  gui::DoubleSpinBox *f_air_vert, *f_air_lat;
+  gui::DoubleSpinBox *j_roll, *j_pitch, *j_yaw;
+  gui::DoubleSpinBox *j_r, *sigma, *S;
+};
 } // end namespace simulator
 } // end namespace flair
Index: trunk/lib/FlairSimulator/src/unexported/AnimPoursuite.h
===================================================================
--- trunk/lib/FlairSimulator/src/unexported/AnimPoursuite.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/unexported/AnimPoursuite.h	(revision 15)
@@ -22,39 +22,35 @@
 #include <vector3d.h>
 
-namespace flair
-{
-namespace simulator
-{
+namespace flair {
+namespace simulator {
 
-    class AnimPoursuite : public irr::scene::ISceneNodeAnimator
-    {
-        public:
-            AnimPoursuite(const irr::scene::ISceneNode* parent,float rotateSpeed = -500.0f, float zoomSpeed = 4.0f);
-            ~AnimPoursuite();
+class AnimPoursuite : public irr::scene::ISceneNodeAnimator {
+public:
+  AnimPoursuite(const irr::scene::ISceneNode *parent,
+                float rotateSpeed = -500.0f, float zoomSpeed = 4.0f);
+  ~AnimPoursuite();
 
-            void animateNode(irr::scene::ISceneNode* node, irr::u32 timeMs);
-            ISceneNodeAnimator* createClone(irr::scene::ISceneNode* node,irr::scene::ISceneManager* newManager=0);
-            bool MouseMoved(const irr::SEvent& event,irr::core::position2df MousePos);
-            void setPositionOffset(irr::core::vector3df newpos);
-            void setTargetOffset(irr::core::vector3df newpos);
+  void animateNode(irr::scene::ISceneNode *node, irr::u32 timeMs);
+  ISceneNodeAnimator *createClone(irr::scene::ISceneNode *node,
+                                  irr::scene::ISceneManager *newManager = 0);
+  bool MouseMoved(const irr::SEvent &event, irr::core::position2df MousePos);
+  void setPositionOffset(irr::core::vector3df newpos);
+  void setTargetOffset(irr::core::vector3df newpos);
 
-        private:
-            virtual bool isEventReceiverEnabled(void) const
-            {
-                return true;
-            }
+private:
+  virtual bool isEventReceiverEnabled(void) const { return true; }
 
-            irr::core::vector3df pos_offset,target_offset;
-            bool LMouseKey;
-            irr::core::position2df RotateStart;
-            irr::core::position2df MousePos;
-            const irr::scene::ISceneNode* parent;
-            bool Rotating;
-            float RotY,RotZ;
-            float rotateSpeed;
-            float zoomSpeed;
-            float currentZoom;
-            float sat(float value);
-    };
+  irr::core::vector3df pos_offset, target_offset;
+  bool LMouseKey;
+  irr::core::position2df RotateStart;
+  irr::core::position2df MousePos;
+  const irr::scene::ISceneNode *parent;
+  bool Rotating;
+  float RotY, RotZ;
+  float rotateSpeed;
+  float zoomSpeed;
+  float currentZoom;
+  float sat(float value);
+};
 
 } // end namespace simulator
Index: trunk/lib/FlairSimulator/src/unexported/GenericObject.h
===================================================================
--- trunk/lib/FlairSimulator/src/unexported/GenericObject.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/unexported/GenericObject.h	(revision 15)
@@ -35,19 +35,16 @@
 #include <Vector3D.h>
 
-
 #include <aabbox3d.h>
 #include <IMeshSceneNode.h>
 
-namespace irr
-{
-    class SEvent;
-    namespace scene
-    {
-        class IMesh;
-        class ISceneManager;
-        class ITriangleSelector;
-        class IMetaTriangleSelector;
-        class ISceneNodeAnimatorCollisionResponse;
-    }
+namespace irr {
+class SEvent;
+namespace scene {
+class IMesh;
+class ISceneManager;
+class ITriangleSelector;
+class IMetaTriangleSelector;
+class ISceneNodeAnimatorCollisionResponse;
+}
 }
 
@@ -55,60 +52,53 @@
 class Simulator_impl;
 
-namespace flair
-{
-namespace core
-{
+namespace flair {
+namespace core {
 class ConditionVariable;
 }
-namespace simulator
-{
+namespace simulator {
 class Simulator;
 class AnimPoursuite;
 
-class GenericObject : public irr::scene::IMeshSceneNode
-{
-    friend class ::Simulator_impl;
+class GenericObject : public irr::scene::IMeshSceneNode {
+  friend class ::Simulator_impl;
 
 public:
-    GenericObject(Simulator* parent,std::string name, irr::scene::ISceneManager* sceneManager);
-    virtual ~GenericObject();
+  GenericObject(Simulator *parent, std::string name,
+                irr::scene::ISceneManager *sceneManager);
+  virtual ~GenericObject();
 
-    //FROM IMPL
-    irr::scene::ITriangleSelector* TriangleSelector(void);
-    irr::core::aabbox3d<irr::f32> box;
-    //END FROM IMPL
+  // FROM IMPL
+  irr::scene::ITriangleSelector *TriangleSelector(void);
+  irr::core::aabbox3d<irr::f32> box;
+  // END FROM IMPL
 
-    irr::scene::ISceneNode* getSceneNode();
-    virtual const irr::core::aabbox3d<irr::f32>& getBoundingBox(void) const
-    {
-        return box;
-    }
+  irr::scene::ISceneNode *getSceneNode();
+  virtual const irr::core::aabbox3d<irr::f32> &getBoundingBox(void) const {
+    return box;
+  }
 
-    void setPosition(irr::core::vector3df position);
-    void setScale(float value);
-    void setScale(irr::core::vector3df scale);
-    void setRotation(irr::core::vector3df rotation);
-    void OnRegisterSceneNode(void);
-    void setMesh(irr::scene::IMesh* mesh);
-    irr::scene::IMesh* getMesh(void);
-    void render(void);
-    virtual void setReadOnlyMaterials(bool readonly){};
-    virtual bool isReadOnlyMaterials(void) const
-    {
-        return false;
-    }
-    virtual irr::scene::IShadowVolumeSceneNode* addShadowVolumeSceneNode(const irr::scene::IMesh* shadowMesh=0,
-            irr::s32 id=-1, bool zfailmethod=true, irr::f32 infinity=1000.0f)
-    {
-        return NULL;
-    }
+  void setPosition(irr::core::vector3df position);
+  void setScale(float value);
+  void setScale(irr::core::vector3df scale);
+  void setRotation(irr::core::vector3df rotation);
+  void OnRegisterSceneNode(void);
+  void setMesh(irr::scene::IMesh *mesh);
+  irr::scene::IMesh *getMesh(void);
+  void render(void);
+  virtual void setReadOnlyMaterials(bool readonly){};
+  virtual bool isReadOnlyMaterials(void) const { return false; }
+  virtual irr::scene::IShadowVolumeSceneNode *
+  addShadowVolumeSceneNode(const irr::scene::IMesh *shadowMesh = 0,
+                           irr::s32 id = -1, bool zfailmethod = true,
+                           irr::f32 infinity = 1000.0f) {
+    return NULL;
+  }
 
 private:
-    void UpdateFrom(core::io_data *data) {};
-    irr::scene::IMesh *mesh;
-    irr::scene::ITriangleSelector* selector;
-    flair::core::ConditionVariable* cond;
-    irr::video::SMaterial Material;
-
+  void UpdateFrom(core::io_data *data){};
+  irr::scene::IMesh *mesh;
+  irr::scene::ITriangleSelector *selector;
+  flair::core::ConditionVariable *cond;
+  irr::video::SMaterial Material;
 };
 } // end namespace simulator
Index: trunk/lib/FlairSimulator/src/unexported/Gui_impl.h
===================================================================
--- trunk/lib/FlairSimulator/src/unexported/Gui_impl.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/unexported/Gui_impl.h	(revision 15)
@@ -24,66 +24,64 @@
 #include <vector3d.h>
 
-namespace irr
-{
-    class IrrlichtDevice;
-    namespace scene
-    {
-        class ISceneManager;
-        class IMeshSceneNode;
-        class ITriangleSelector;
-    }
-    namespace video
-    {
-        class IVideoDriver;
-    }
-    namespace gui
-    {
-        class IGUIFont;
-        class IGUIEnvironment;
-    }
+namespace irr {
+class IrrlichtDevice;
+namespace scene {
+class ISceneManager;
+class IMeshSceneNode;
+class ITriangleSelector;
+}
+namespace video {
+class IVideoDriver;
+}
+namespace gui {
+class IGUIFont;
+class IGUIEnvironment;
+}
 }
 
-namespace flair
-{
-    namespace core
-    {
-        class Object;
-    }
-    namespace simulator
-    {
-        class Model;
-        class GenericObject;
-        class Gui;
-    }
+namespace flair {
+namespace core {
+class Object;
+}
+namespace simulator {
+class Model;
+class GenericObject;
+class Gui;
+}
 }
 
 class MyEventReceiver;
 
-class Gui_impl
-{
-    public:
-        Gui_impl(flair::simulator::Gui* self,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);
-        ~Gui_impl();
-        void RunGui(std::vector<flair::simulator::Model*> modeles,std::vector<flair::simulator::GenericObject*> objects);
-        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));
+class Gui_impl {
+public:
+  Gui_impl(flair::simulator::Gui *self, 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);
+  ~Gui_impl();
+  void RunGui(std::vector<flair::simulator::Model *> modeles,
+              std::vector<flair::simulator::GenericObject *> objects);
+  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));
 
-        irr::scene::IMeshSceneNode* node;
-        irr::IrrlichtDevice *device;
-        std::string media_path;
-        irr::video::IVideoDriver* driver;
-        irr::scene::ISceneManager* smgr;
-        int scene_width,scene_height;
+  irr::scene::IMeshSceneNode *node;
+  irr::IrrlichtDevice *device;
+  std::string media_path;
+  irr::video::IVideoDriver *driver;
+  irr::scene::ISceneManager *smgr;
+  int scene_width, scene_height;
 
-    private:
-        MyEventReceiver *receiver;
-        irr::scene::ITriangleSelector* selector;
-        irr::gui::IGUIFont* font;
-        irr::gui::IGUIEnvironment* env;
-        void setWindowCaption(flair::core::Object* object, int fps);
-        void takeScreenshot(void);
-        hdfile_t *dbtFile_r,*dbtFile_w;
-        size_t dbtSize(std::vector<flair::simulator::Model*> modeles);
-        char* dbtbuf;
-        flair::simulator::Gui *self;
+private:
+  MyEventReceiver *receiver;
+  irr::scene::ITriangleSelector *selector;
+  irr::gui::IGUIFont *font;
+  irr::gui::IGUIEnvironment *env;
+  void setWindowCaption(flair::core::Object *object, int fps);
+  void takeScreenshot(void);
+  hdfile_t *dbtFile_r, *dbtFile_w;
+  size_t dbtSize(std::vector<flair::simulator::Model *> modeles);
+  char *dbtbuf;
+  flair::simulator::Gui *self;
 };
 
Index: trunk/lib/FlairSimulator/src/unexported/Model_impl.h
===================================================================
--- trunk/lib/FlairSimulator/src/unexported/Model_impl.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/unexported/Model_impl.h	(revision 15)
@@ -23,25 +23,21 @@
 #include "Quaternion.h"
 
-namespace flair
-{
-    namespace core
-    {
-        class cvmatrix;
-        class Mutex;
-        class ConditionVariable;
-    }
-    namespace gui
-    {
-        class TabWidget;
-        class CheckBox;
-        class DoubleSpinBox;
-        class SpinBox;
-        class Vector3DSpinBox;
-    }
-    namespace simulator
-    {
-        class Simulator;
-        class AnimPoursuite;
-    }
+namespace flair {
+namespace core {
+class cvmatrix;
+class Mutex;
+class ConditionVariable;
+}
+namespace gui {
+class TabWidget;
+class CheckBox;
+class DoubleSpinBox;
+class SpinBox;
+class Vector3DSpinBox;
+}
+namespace simulator {
+class Simulator;
+class AnimPoursuite;
+}
 }
 
@@ -50,83 +46,87 @@
 #include <IMeshSceneNode.h>
 
-namespace irr
-{
-    namespace scene
-    {
-        class ISceneManager;
-        class ITriangleSelector;
-        class IMetaTriangleSelector;
-        class ISceneNodeAnimatorCollisionResponse;
-        class ICameraSceneNode;
-    }
+namespace irr {
+namespace scene {
+class ISceneManager;
+class ITriangleSelector;
+class IMetaTriangleSelector;
+class ISceneNodeAnimatorCollisionResponse;
+class ICameraSceneNode;
+}
 }
 #endif
 
 #ifdef GL
-class Model_impl : public irr::scene::ISceneNode,public flair::core::Thread,private vrpn_Tracker
+class Model_impl : public irr::scene::ISceneNode,
+                   public flair::core::Thread,
+                   private vrpn_Tracker
 #else
-class Model_impl : public flair::core::Thread, private vrpn_Tracker
+class Model_impl : public flair::core::Thread,
+                   private vrpn_Tracker
 #endif
-{
-    public:
+                   {
+public:
 #ifdef GL
-        Model_impl(flair::simulator::Model* self,std::string name,irr::scene::ISceneManager* scenemanager,vrpn_Connection_IP* vrpn);
+  Model_impl(flair::simulator::Model *self, std::string name,
+             irr::scene::ISceneManager *scenemanager, vrpn_Connection_IP *vrpn);
 #else
-        Model_impl(flair::simulator::Model* self,std::string name,vrpn_Connection_IP* vrpn);
+  Model_impl(flair::simulator::Model *self, std::string name,
+             vrpn_Connection_IP *vrpn);
 #endif
-        ~Model_impl();
+  ~Model_impl();
 
 #ifdef GL
-        void OnRegisterSceneNode(void);
-        void render(void);
-        void Draw(void){printf("CA MARCHE PAS PUNAISE\r\n");ExtraDraw();};
-        void ExtraDraw(void){printf("nope\r\n");};
+  void OnRegisterSceneNode(void);
+  void render(void);
+  void Draw(void) {
+    printf("CA MARCHE PAS PUNAISE\r\n");
+    ExtraDraw();
+  };
+  void ExtraDraw(void) { printf("nope\r\n"); };
 
-        const irr::core::aabbox3d<irr::f32>& getBoundingBox(void) const
-        {
-            return box;
-        }
-        void UpdatePos(void);
-        void CheckCollision(void);
-        irr::scene::ITriangleSelector* TriangleSelector(void);
-        irr::scene::IMetaTriangleSelector* MetaTriangleSelector(void);
-        irr::core::aabbox3d<irr::f32> box;
-        void SynchronizationPoint();
-        irr::scene::ICameraSceneNode* camera;
-        flair::simulator::AnimPoursuite* animator;
-        irr::scene::ITriangleSelector* selector;
+  const irr::core::aabbox3d<irr::f32> &getBoundingBox(void) const {
+    return box;
+  }
+  void UpdatePos(void);
+  void CheckCollision(void);
+  irr::scene::ITriangleSelector *TriangleSelector(void);
+  irr::scene::IMetaTriangleSelector *MetaTriangleSelector(void);
+  irr::core::aabbox3d<irr::f32> box;
+  void SynchronizationPoint();
+  irr::scene::ICameraSceneNode *camera;
+  flair::simulator::AnimPoursuite *animator;
+  irr::scene::ITriangleSelector *selector;
 #endif
-        void mainloop(void);
+  void mainloop(void);
 
-        flair::gui::TabWidget *tabwidget;
-        flair::gui::DoubleSpinBox *dT;
+  flair::gui::TabWidget *tabwidget;
+  flair::gui::DoubleSpinBox *dT;
 
-    private:
-        flair::gui::Vector3DSpinBox* pos_init;
-        flair::gui::SpinBox *yaw_init;
-        flair::gui::CheckBox *enable_opti;
-        flair::simulator::Model* self;
-        flair::core::cvmatrix* output;
-        flair::core::Mutex *states_mutex;
+private:
+  flair::gui::Vector3DSpinBox *pos_init;
+  flair::gui::SpinBox *yaw_init;
+  flair::gui::CheckBox *enable_opti;
+  flair::simulator::Model *self;
+  flair::core::cvmatrix *output;
+  flair::core::Mutex *states_mutex;
 
-        struct timeval _timestamp;
-        void Run(void);
-        flair::core::Quaternion ComputeInitRotation(flair::core::Quaternion quat_in);
+  struct timeval _timestamp;
+  void Run(void);
+  flair::core::Quaternion ComputeInitRotation(flair::core::Quaternion quat_in);
 #ifdef GL
-        void CollisionHandler(void);
+  void CollisionHandler(void);
 
-        irr::scene::IMetaTriangleSelector* meta_selector;
-        irr::scene::ISceneNodeAnimatorCollisionResponse* anim;
+  irr::scene::IMetaTriangleSelector *meta_selector;
+  irr::scene::ISceneNodeAnimatorCollisionResponse *anim;
 
-        bool position_init;
+  bool position_init;
 
-        flair::core::ConditionVariable* cond;
-        int sync_count;
+  flair::core::ConditionVariable *cond;
+  int sync_count;
 
-        flair::core::Mutex *collision_mutex;
-        bool collision_occured;
-        flair::core::Vector3D collision_point;
+  flair::core::Mutex *collision_mutex;
+  bool collision_occured;
+  flair::core::Vector3D collision_point;
 #endif
-
 };
 
Index: trunk/lib/FlairSimulator/src/unexported/Simulator_impl.h
===================================================================
--- trunk/lib/FlairSimulator/src/unexported/Simulator_impl.h	(revision 10)
+++ trunk/lib/FlairSimulator/src/unexported/Simulator_impl.h	(revision 15)
@@ -21,33 +21,30 @@
 #include <Thread.h>
 
-
-namespace flair
-{
-    namespace simulator
-    {
-        class Simulator;
-        class Model;
-        class GenericObject;
-    }
+namespace flair {
+namespace simulator {
+class Simulator;
+class Model;
+class GenericObject;
+}
 }
 
-class Simulator_impl: public vrpn_Connection_IP, private flair::core::Thread
-{
-    friend class flair::simulator::Model;
-    friend class flair::simulator::GenericObject;
+class Simulator_impl : public vrpn_Connection_IP, private flair::core::Thread {
+  friend class flair::simulator::Model;
+  friend class flair::simulator::GenericObject;
 
-    public:
-        Simulator_impl(flair::simulator::Simulator* self,int optitrack_mstime=10,float yaw_deg=30);
-        ~Simulator_impl();
+public:
+  Simulator_impl(flair::simulator::Simulator *self, int optitrack_mstime = 10,
+                 float yaw_deg = 30);
+  ~Simulator_impl();
 
-        void RunSimu(void);
-        float yaw_rad;
+  void RunSimu(void);
+  float yaw_rad;
 
-    private:
-        void Run(void);
-        flair::simulator::Simulator* self;
-        std::vector<flair::simulator::Model*> models;
-        std::vector<flair::simulator::GenericObject*> objects;
-        int optitrack_mstime;
+private:
+  void Run(void);
+  flair::simulator::Simulator *self;
+  std::vector<flair::simulator::Model *> models;
+  std::vector<flair::simulator::GenericObject *> objects;
+  int optitrack_mstime;
 };
 
