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

Last change on this file since 69 was 69, checked in by Sanahuja Guillaume, 5 years ago

refonte camera simu

File size: 2.8 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
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 "Quaternion.h"
22#include <ISceneManager.h>
23
24using namespace irr;
25using namespace video;
26using namespace scene;
27using namespace core;
28
29using namespace flair::core;
30using namespace flair::simulator;
31
32namespace flair {
33namespace simulator {
34
35GenericObject::GenericObject(Simulator *parent, std::string name,
36                             ISceneManager *sceneManager)
37    : IMeshSceneNode(sceneManager->getRootSceneNode(), sceneManager,
38                     -1) //, IODevice(parent,name)
39{
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;
46
47  parent->pimpl_->objects.push_back(this);
48}
49
50GenericObject::~GenericObject() {}
51
52void GenericObject::setScale(float value) {
53  ISceneNode::setScale(vector3df(value, value, value));
54}
55
56void GenericObject::setScale(vector3df scale) { ISceneNode::setScale(scale); }
57
58ITriangleSelector *GenericObject::TriangleSelector(void) { return selector; }
59
60void GenericObject::OnRegisterSceneNode(void) {
61  if (IsVisible)
62    SceneManager->registerNodeForRendering(this);
63
64  ISceneNode::OnRegisterSceneNode();
65}
66
67void 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));
74}
75
76void GenericObject::setMesh(IMesh *mesh) {
77  this->mesh = mesh;
78  box = mesh->getBoundingBox();
79
80  selector = getSceneManager()->createTriangleSelector(mesh, this);
81  setTriangleSelector(selector);
82}
83
84IMesh *GenericObject::getMesh(void) { return mesh; }
85
86void GenericObject::setPosition(irr::core::vector3df pos) {
87  ISceneNode::setPosition(ToIrrlichtCoordinates(pos));
88}
89
90void GenericObject::setRotation(irr::core::vector3df rotation) {
91  Euler eulerA(rotation.X, rotation.Y, rotation.Z);
92  Euler eulerB;
93  Quaternion quatA, quatB;
94  eulerA.ToQuaternion(quatA);
95  quatB = ToIrrlichtOrientation(quatA);
96  quatB.ToEuler(eulerB);
97
98  ISceneNode::setRotation(Euler::ToDegree(1) *
99                          vector3df(eulerB.roll, eulerB.pitch, eulerB.yaw));
100}
101
102} // end namespace simulator
103} // end namespace flair
104#endif
Note: See TracBrowser for help on using the repository browser.