Changeset 134 in flair-src


Ignore:
Timestamp:
Feb 9, 2017, 5:10:24 PM (8 years ago)
Author:
Sanahuja Guillaume
Message:

correction bugs parser

Location:
trunk/lib/FlairSimulator/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSimulator/src/GenericObject.cpp

    r69 r134  
    1717#ifdef GL
    1818#include "GenericObject.h"
     19#include "Simulator.h"
    1920#include "Simulator_impl.h"
     21#include "Gui.h"
    2022
    2123#include "Quaternion.h"
     24#include "Euler.h"
    2225#include <ISceneManager.h>
     26#include <IMeshSceneNode.h>
    2327
    2428using namespace irr;
     
    3337namespace simulator {
    3438
    35 GenericObject::GenericObject(Simulator *parent, std::string name,
    36                              ISceneManager *sceneManager)
    37     : IMeshSceneNode(sceneManager->getRootSceneNode(), sceneManager,
    38                      -1) //, IODevice(parent,name)
     39GenericObject::GenericObject(Simulator *parent, IMesh *mesh)
    3940{
    40   setMaterialFlag(EMF_LIGHTING, false);
    41   Material = getMaterial(0);
    42   // setMaterialTexture(0,sceneManager->getVideoDriver()->getTexture("/home/cesar/igep/uav_dev_svn/trunk/media/nskinbl.jpg"));
    43   Material.NormalizeNormals = true;
    44   Material.Wireframe = false;
    45   Material.Lighting = false;
     41        meshSceneNode=getGui()->getSceneManager()->addMeshSceneNode(mesh);
     42       
     43  selector = getGui()->getSceneManager()->createTriangleSelector(mesh, meshSceneNode);
     44  meshSceneNode->setTriangleSelector(selector);
     45       
     46  meshSceneNode->setMaterialFlag(EMF_LIGHTING, false);
    4647
    4748  parent->pimpl_->objects.push_back(this);
     
    5051GenericObject::~GenericObject() {}
    5152
     53ITriangleSelector *GenericObject::TriangleSelector(void) { return selector; }
     54
    5255void GenericObject::setScale(float value) {
    53   ISceneNode::setScale(vector3df(value, value, value));
     56  meshSceneNode->setScale(vector3df(value, value, value));
    5457}
    5558
    56 void GenericObject::setScale(vector3df scale) { ISceneNode::setScale(scale); }
    57 
    58 ITriangleSelector *GenericObject::TriangleSelector(void) { return selector; }
    59 
    60 void GenericObject::OnRegisterSceneNode(void) {
    61   if (IsVisible)
    62     SceneManager->registerNodeForRendering(this);
    63 
    64   ISceneNode::OnRegisterSceneNode();
     59void GenericObject::setScale(const vector3df& scale) {
     60        meshSceneNode->setScale(scale);
    6561}
    6662
    67 void GenericObject::render(void) {
    68   IVideoDriver *driver = SceneManager->getVideoDriver();
    69 
    70   driver->setMaterial(Material);
    71 
    72   driver->setTransform(ETS_WORLD, AbsoluteTransformation);
    73   driver->drawMeshBuffer(mesh->getMeshBuffer(0));
     63void GenericObject::setPosition(const vector3df& pos) {
     64  meshSceneNode->setPosition(ToIrrlichtCoordinates(pos));
    7465}
    7566
    76 void GenericObject::setMesh(IMesh *mesh) {
    77   this->mesh = mesh;
    78   box = mesh->getBoundingBox();
    79 
    80   selector = getSceneManager()->createTriangleSelector(mesh, this);
    81   setTriangleSelector(selector);
    82 }
    83 
    84 IMesh *GenericObject::getMesh(void) { return mesh; }
    85 
    86 void GenericObject::setPosition(irr::core::vector3df pos) {
    87   ISceneNode::setPosition(ToIrrlichtCoordinates(pos));
    88 }
    89 
    90 void GenericObject::setRotation(irr::core::vector3df rotation) {
     67void GenericObject::setRotation(const vector3df& rotation) {
    9168  Euler eulerA(rotation.X, rotation.Y, rotation.Z);
    9269  Euler eulerB;
     
    9673  quatB.ToEuler(eulerB);
    9774
    98   ISceneNode::setRotation(Euler::ToDegree(1) *
     75  meshSceneNode->setRotation(Euler::ToDegree(1) *
    9976                          vector3df(eulerB.roll, eulerB.pitch, eulerB.yaw));
    10077}
  • trunk/lib/FlairSimulator/src/Gui_impl.cpp

    r70 r134  
    2222#include "Model.h"
    2323#include "Model_impl.h"
     24#include "VisualizationCamera.h"
     25#include "FollowMeCamera.h"
    2426#include <Object.h>
    2527#include <Euler.h>
  • trunk/lib/FlairSimulator/src/Man.cpp

    r70 r134  
    2727#include "FollowMeCamera.h"
    2828
     29class addAnimatedMeshSceneNode;
    2930using namespace irr;
    3031using namespace irr::core;
  • trunk/lib/FlairSimulator/src/Parser.cpp

    r87 r134  
    1818#include "Parser.h"
    1919#include "Simulator.h"
     20#include "FixedCamera.h"
    2021#include "GenericObject.h"
    21 #include "FixedCamera.h"
    2222#include <vector3d.h>
    2323#include <Vector3D.h>
    2424#include <IrrlichtDevice.h>
    2525#include <IFileSystem.h>
    26 #include "GenericObject.h"
     26#include <IAnimatedMesh.h>
     27#include <IGeometryCreator.h>
     28#include <ISceneManager.h>
    2729
    2830using namespace irr;
     
    108110
    109111void Parser::processObjects(xmlNode *a_node) {
    110   FILE *fp;
    111   std::string fileName;
    112   xmlNode *cur_node = NULL;
    113 
    114   const IGeometryCreator *geo;
    115 
    116   geo = getGui()->getSceneManager()->getGeometryCreator();
     112  xmlNode *cur_node = NULL;
    117113
    118114  for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
    119115    if (xmlStrEqual(cur_node->name, (xmlChar *)"mesh")) {
    120       fileName = this->media_path;
     116                        FILE *fp;
     117                        std::string fileName = this->media_path+"/";
    121118      fp = NULL;
    122119      fp = fopen(fileName.append((char *)xmlGetProp(
    123                                      cur_node, (xmlChar *)"model")).c_str(),
    124                  "rb");
     120                                     cur_node, (xmlChar *)"model")).c_str(),"rb");
    125121      if (fp != NULL) {
    126122        GenericObject *object =
    127             new GenericObject(parent, "Object", getSceneManager());
    128         object->setMesh(getGui()->getMesh(
    129             (char *)xmlGetProp(cur_node, (xmlChar *)"model")));
     123            new GenericObject(parent, getGui()->getMesh((char *)xmlGetProp(cur_node, (xmlChar *)"model")));
    130124        object->setPosition(
    131125            getMeshVect(cur_node->children, (xmlChar *)"position"));
     
    133127            getMeshVect(cur_node->children, (xmlChar *)"rotation"));
    134128        object->setScale(getMeshVect(cur_node->children, (xmlChar *)"scale"));
    135         object->render();
    136129      } else {
    137         Err("FATAL ERROR : File %s doesn't exist !\r\n",
    138             (char *)xmlGetProp(cur_node, (xmlChar *)"model"));
     130        Err("FATAL ERROR : File %s %s doesn't exist !\r\n",
     131            (char *)xmlGetProp(cur_node, (xmlChar *)"model"),fileName.c_str());
    139132      }
    140133    } else if (xmlStrEqual(cur_node->name, (xmlChar *)"cylinder")) {
     134                        const IGeometryCreator *geo;
     135                        geo = getGui()->getSceneManager()->getGeometryCreator();
     136                        IMesh* mesh=geo->createCylinderMesh(
     137          ToIrrlichtScale(atof((char *)xmlGetProp(cur_node, (xmlChar *)"radius"))),
     138          ToIrrlichtScale(atof((char *)xmlGetProp(cur_node, (xmlChar *)"length"))),
     139          atof((char *)xmlGetProp(cur_node, (xmlChar *)"tesselation")),
     140          SColor(100, 255, 100, 100));
     141      GenericObject *object = new GenericObject(parent, mesh);
     142      object->setPosition(getMeshVect(cur_node->children, (xmlChar *)"position"));
     143      object->setRotation(getMeshVect(cur_node->children, (xmlChar *)"rotation"));
     144      object->setScale(getMeshVect(cur_node->children, (xmlChar *)"scale"));
     145    } else if (xmlStrEqual(cur_node->name, (xmlChar *)"eight")) {
     146                        const IGeometryCreator *geo;
     147                        geo = getGui()->getSceneManager()->getGeometryCreator();
     148                        IMesh* mesh=geo->createCubeMesh(
     149          vector3df(atof((char *)xmlGetProp(cur_node, (xmlChar *)"length")),
     150                    atof((char *)xmlGetProp(cur_node, (xmlChar *)"width")),
     151                    atof((char *)xmlGetProp(cur_node, (xmlChar *)"eight"))));
     152                       
    141153      GenericObject *object =
    142           new GenericObject(parent, "Object", getSceneManager());
    143       object->setMesh(geo->createCylinderMesh(
    144           ToIrrlichtScale(
    145               atof((char *)xmlGetProp(cur_node, (xmlChar *)"radius"))),
    146           ToIrrlichtScale(
    147               atof((char *)xmlGetProp(cur_node, (xmlChar *)"length"))),
    148           atof((char *)xmlGetProp(cur_node, (xmlChar *)"tesselation")),
    149           SColor(100, 255, 100, 100)));
     154          new GenericObject(parent, mesh);
    150155      object->setPosition(
    151156          getMeshVect(cur_node->children, (xmlChar *)"position"));
     
    153158          getMeshVect(cur_node->children, (xmlChar *)"rotation"));
    154159      object->setScale(getMeshVect(cur_node->children, (xmlChar *)"scale"));
    155       // object->setMaterialTexture(0,getTexture("/home/apeiron/igep/uav_dev_svn/trunk/media/nskinbl.jpg"));
    156       object->setMaterialType(video::EMT_SOLID);
    157       object->render();
    158     } else if (xmlStrEqual(cur_node->name, (xmlChar *)"eight")) {
    159       GenericObject *object =
    160           new GenericObject(parent, "Object", getSceneManager());
    161       object->setMesh(geo->createCubeMesh(
    162           vector3df(atof((char *)xmlGetProp(cur_node, (xmlChar *)"length")),
    163                     atof((char *)xmlGetProp(cur_node, (xmlChar *)"width")),
    164                     atof((char *)xmlGetProp(cur_node, (xmlChar *)"eight")))));
    165       object->setPosition(
    166           getMeshVect(cur_node->children, (xmlChar *)"position"));
    167       object->setRotation(
    168           getMeshVect(cur_node->children, (xmlChar *)"rotation"));
    169       object->setScale(getMeshVect(cur_node->children, (xmlChar *)"scale"));
    170       object->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
    171       // object->getMaterial(0).Textures[0] =
    172       // getTexture("/home/apeiron/igep/uav_dev_svn/trunk/media/nskinbl.jpg");
    173       object->setMaterialFlag(EMF_LIGHTING, false);
    174       object->render();
    175160    }
    176161  }
  • trunk/lib/FlairSimulator/src/unexported/GenericObject.h

    r69 r134  
    1919#ifdef GL
    2020
    21 #include "Simulator.h"
    22 
    23 #include "ConditionVariable.h"
    24 #include "Gui.h"
    25 #include "Gui_impl.h"
    26 #include <ISceneManager.h>
    27 #include <ISceneNodeAnimatorCollisionResponse.h>
    28 #include <IMetaTriangleSelector.h>
    29 #include <IVideoDriver.h>
    30 #include <ICameraSceneNode.h>
    31 #include "FollowMeCamera.h"
    32 
    33 #include <IODevice.h>
    34 #include <Euler.h>
    35 #include <Vector3D.h>
    36 
    37 #include <aabbox3d.h>
    38 #include <IMeshSceneNode.h>
     21#include <vector3d.h>
    3922
    4023namespace irr {
    41 class SEvent;
    42 namespace scene {
    43 class IMesh;
    44 class ISceneManager;
    45 class ITriangleSelector;
    46 class IMetaTriangleSelector;
    47 class ISceneNodeAnimatorCollisionResponse;
    48 }
     24        namespace scene {
     25                class IMesh;
     26                class IMeshSceneNode;
     27                class ITriangleSelector;
     28                class ISceneNode;
     29        }
    4930}
    5031
    51 class Gui_impl;
    5232class Simulator_impl;
    5333
    5434namespace flair {
    55 namespace core {
    56 class ConditionVariable;
    57 }
    5835namespace simulator {
    5936class Simulator;
    60 class AnimPoursuite;
    6137
    62 class GenericObject : public irr::scene::IMeshSceneNode {
     38class GenericObject {
    6339  friend class ::Simulator_impl;
    6440
    6541public:
    66   GenericObject(Simulator *parent, std::string name,
    67                 irr::scene::ISceneManager *sceneManager);
     42  GenericObject(Simulator *parent,irr::scene::IMesh *mesh);
    6843  virtual ~GenericObject();
    6944
    70   // FROM IMPL
    7145  irr::scene::ITriangleSelector *TriangleSelector(void);
    72   irr::core::aabbox3d<irr::f32> box;
    73   // END FROM IMPL
    74 
    75   irr::scene::ISceneNode *getSceneNode();
    76   virtual const irr::core::aabbox3d<irr::f32> &getBoundingBox(void) const {
    77     return box;
    78   }
    79 
    80   void setPosition(irr::core::vector3df position);
    8146  void setScale(float value);
    82   void setScale(irr::core::vector3df scale);
    83   void setRotation(irr::core::vector3df rotation);
    84   void OnRegisterSceneNode(void);
    85   void setMesh(irr::scene::IMesh *mesh);
    86   irr::scene::IMesh *getMesh(void);
    87   void render(void);
    88   virtual void setReadOnlyMaterials(bool readonly){};
    89   virtual bool isReadOnlyMaterials(void) const { return false; }
    90   virtual irr::scene::IShadowVolumeSceneNode *
    91   addShadowVolumeSceneNode(const irr::scene::IMesh *shadowMesh = 0,
    92                            irr::s32 id = -1, bool zfailmethod = true,
    93                            irr::f32 infinity = 1000.0f) {
    94     return NULL;
    95   }
    96 
     47  void setScale(const irr::core::vector3df& scale);
     48        void setPosition(const irr::core::vector3df& position);
     49  void setRotation(const irr::core::vector3df& rotation);
     50 
    9751private:
    98   void UpdateFrom(core::io_data *data){};
    99   irr::scene::IMesh *mesh;
    10052  irr::scene::ITriangleSelector *selector;
    101   flair::core::ConditionVariable *cond;
    102   irr::video::SMaterial Material;
    103 };
     53        irr::scene::IMeshSceneNode *meshSceneNode;
     54};
    10455} // end namespace simulator
    10556} // end namespace flair
Note: See TracChangeset for help on using the changeset viewer.