source: flair-src/trunk/lib/FlairSimulator/src/GenericObject.cpp @ 15

Last change on this file since 15 was 15, checked in by Bayard Gildas, 6 years ago

sources reformatted with flair-format-dir script

File size: 3.0 KB
RevLine 
[10]1// %flair:license{
[15]2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
[10]4// %flair:license}
[8]5//  created:    2013/03/25
6//  filename:   GenericObject.cpp
7//
8//  author:     Cesar Richard
9//              Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11//  version:    $Id: $
12//
13//  purpose:    classe definissant un modele a simuler
14//
15/*********************************************************************/
16
17#ifdef GL
18#include "GenericObject.h"
19#include "Simulator_impl.h"
20
21#include "ConditionVariable.h"
22#include "Quaternion.h"
23#include "Gui.h"
24#include "Gui_impl.h"
25#include <IMesh.h>
26#include <ISceneManager.h>
27#include <IMetaTriangleSelector.h>
28#include <IVideoDriver.h>
29#include "AnimPoursuite.h"
30using namespace irr;
31using namespace video;
32using namespace scene;
33using namespace core;
34using namespace io;
35
36using namespace flair::core;
37using namespace flair::simulator;
38
[15]39namespace flair {
40namespace simulator {
[8]41
[15]42GenericObject::GenericObject(Simulator *parent, std::string name,
43                             ISceneManager *sceneManager)
44    : IMeshSceneNode(sceneManager->getRootSceneNode(), sceneManager,
45                     -1) //, IODevice(parent,name)
[8]46{
[15]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;
[8]53
[15]54  parent->pimpl_->objects.push_back(this);
[8]55}
56
[15]57GenericObject::~GenericObject() {}
[8]58
[15]59void GenericObject::setScale(float value) {
60  ISceneNode::setScale(vector3df(value, value, value));
[8]61}
62
[15]63void GenericObject::setScale(vector3df scale) { ISceneNode::setScale(scale); }
[8]64
[15]65ITriangleSelector *GenericObject::TriangleSelector(void) { return selector; }
[8]66
[15]67void GenericObject::OnRegisterSceneNode(void) {
68  if (IsVisible)
69    SceneManager->registerNodeForRendering(this);
[8]70
[15]71  ISceneNode::OnRegisterSceneNode();
[8]72}
73
[15]74void GenericObject::render(void) {
75  IVideoDriver *driver = SceneManager->getVideoDriver();
[8]76
[15]77  driver->setMaterial(Material);
[8]78
[15]79  driver->setTransform(ETS_WORLD, AbsoluteTransformation);
80  driver->drawMeshBuffer(mesh->getMeshBuffer(0));
[8]81}
82
[15]83void GenericObject::setMesh(IMesh *mesh) {
84  this->mesh = mesh;
85  box = mesh->getBoundingBox();
[8]86
[15]87  selector = getSceneManager()->createTriangleSelector(mesh, this);
88  setTriangleSelector(selector);
[8]89}
90
[15]91IMesh *GenericObject::getMesh(void) { return mesh; }
[8]92
[15]93void GenericObject::setPosition(irr::core::vector3df pos) {
94  ISceneNode::setPosition(ToIrrlichtCoordinates(pos));
[8]95}
96
[15]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);
[8]104
[15]105  ISceneNode::setRotation(Euler::ToDegree(1) *
106                          vector3df(eulerB.roll, eulerB.pitch, eulerB.yaw));
[8]107}
108
109} // end namespace simulator
110} // end namespace flair
111#endif
Note: See TracBrowser for help on using the repository browser.