Ignore:
Timestamp:
Apr 8, 2016, 3:40:57 PM (6 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

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

    r10 r15  
    3737using namespace flair::simulator;
    3838
    39 namespace flair
     39namespace flair {
     40namespace simulator {
     41
     42GenericObject::GenericObject(Simulator *parent, std::string name,
     43                             ISceneManager *sceneManager)
     44    : IMeshSceneNode(sceneManager->getRootSceneNode(), sceneManager,
     45                     -1) //, IODevice(parent,name)
    4046{
    41 namespace simulator
    42 {
     47  setMaterialFlag(EMF_LIGHTING, false);
     48  Material = getMaterial(0);
     49  // setMaterialTexture(0,sceneManager->getVideoDriver()->getTexture("/home/cesar/igep/uav_dev_svn/trunk/media/nskinbl.jpg"));
     50  Material.NormalizeNormals = true;
     51  Material.Wireframe = false;
     52  Material.Lighting = false;
    4353
    44 GenericObject::GenericObject(Simulator* parent,std::string name, ISceneManager* sceneManager) : IMeshSceneNode(sceneManager->getRootSceneNode(), sceneManager, -1)//, IODevice(parent,name)
    45 {
    46     setMaterialFlag(EMF_LIGHTING,false);
    47     Material=getMaterial(0);
    48     //setMaterialTexture(0,sceneManager->getVideoDriver()->getTexture("/home/cesar/igep/uav_dev_svn/trunk/media/nskinbl.jpg"));
    49     Material.NormalizeNormals = true;
    50     Material.Wireframe = false;
    51     Material.Lighting = false;
    52 
    53     parent->pimpl_->objects.push_back(this);
     54  parent->pimpl_->objects.push_back(this);
    5455}
    5556
    56 GenericObject::~GenericObject()
    57 {
     57GenericObject::~GenericObject() {}
    5858
     59void GenericObject::setScale(float value) {
     60  ISceneNode::setScale(vector3df(value, value, value));
    5961}
    6062
    61 void GenericObject::setScale(float value)
    62 {
    63     ISceneNode::setScale(vector3df(value,value,value));
     63void GenericObject::setScale(vector3df scale) { ISceneNode::setScale(scale); }
     64
     65ITriangleSelector *GenericObject::TriangleSelector(void) { return selector; }
     66
     67void GenericObject::OnRegisterSceneNode(void) {
     68  if (IsVisible)
     69    SceneManager->registerNodeForRendering(this);
     70
     71  ISceneNode::OnRegisterSceneNode();
    6472}
    6573
    66 void GenericObject::setScale(vector3df scale)
    67 {
    68     ISceneNode::setScale(scale);
     74void GenericObject::render(void) {
     75  IVideoDriver *driver = SceneManager->getVideoDriver();
     76
     77  driver->setMaterial(Material);
     78
     79  driver->setTransform(ETS_WORLD, AbsoluteTransformation);
     80  driver->drawMeshBuffer(mesh->getMeshBuffer(0));
    6981}
    7082
    71 ITriangleSelector* GenericObject::TriangleSelector(void)
    72 {
    73     return selector;
     83void GenericObject::setMesh(IMesh *mesh) {
     84  this->mesh = mesh;
     85  box = mesh->getBoundingBox();
     86
     87  selector = getSceneManager()->createTriangleSelector(mesh, this);
     88  setTriangleSelector(selector);
    7489}
    7590
    76 void GenericObject::OnRegisterSceneNode(void)
    77 {
    78     if (IsVisible)
    79         SceneManager->registerNodeForRendering(this);
     91IMesh *GenericObject::getMesh(void) { return mesh; }
    8092
    81     ISceneNode::OnRegisterSceneNode();
     93void GenericObject::setPosition(irr::core::vector3df pos) {
     94  ISceneNode::setPosition(ToIrrlichtCoordinates(pos));
    8295}
    8396
    84 void GenericObject::render(void)
    85 {
    86     IVideoDriver* driver = SceneManager->getVideoDriver();
     97void GenericObject::setRotation(irr::core::vector3df rotation) {
     98  Euler eulerA(rotation.X, rotation.Y, rotation.Z);
     99  Euler eulerB;
     100  Quaternion quatA, quatB;
     101  eulerA.ToQuaternion(quatA);
     102  quatB = ToIrrlichtOrientation(quatA);
     103  quatB.ToEuler(eulerB);
    87104
    88     driver->setMaterial(Material);
    89 
    90     driver->setTransform(ETS_WORLD, AbsoluteTransformation);
    91     driver->drawMeshBuffer(mesh->getMeshBuffer(0));
    92 }
    93 
    94 void GenericObject::setMesh(IMesh* mesh)
    95 {
    96     this->mesh=mesh;
    97     box=mesh->getBoundingBox();
    98 
    99     selector = getSceneManager()->createTriangleSelector(mesh,this);
    100     setTriangleSelector(selector);
    101 }
    102 
    103 IMesh* GenericObject::getMesh(void)
    104 {
    105     return mesh;
    106 }
    107 
    108 void GenericObject::setPosition(irr::core::vector3df pos)
    109 {
    110     ISceneNode::setPosition(ToIrrlichtCoordinates(pos));
    111 }
    112 
    113 void GenericObject::setRotation(irr::core::vector3df rotation)
    114 {
    115     Euler eulerA(rotation.X,rotation.Y,rotation.Z);
    116     Euler eulerB;
    117     Quaternion quatA,quatB;
    118     eulerA.ToQuaternion(quatA);
    119     quatB=ToIrrlichtOrientation(quatA);
    120     quatB.ToEuler(eulerB);
    121 
    122     ISceneNode::setRotation(Euler::ToDegree(1)*vector3df(eulerB.roll,eulerB.pitch,eulerB.yaw));
     105  ISceneNode::setRotation(Euler::ToDegree(1) *
     106                          vector3df(eulerB.roll, eulerB.pitch, eulerB.yaw));
    123107}
    124108
Note: See TracChangeset for help on using the changeset viewer.