Changeset 134 in flair-src for trunk/lib/FlairSimulator/src/Parser.cpp


Ignore:
Timestamp:
02/09/17 17:10:24 (6 years ago)
Author:
Sanahuja Guillaume
Message:

correction bugs parser

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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  }
Note: See TracChangeset for help on using the changeset viewer.