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

correction bugs parser

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.