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 "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"
|
---|
30 | using namespace irr;
|
---|
31 | using namespace video;
|
---|
32 | using namespace scene;
|
---|
33 | using namespace core;
|
---|
34 | using namespace io;
|
---|
35 |
|
---|
36 | using namespace flair::core;
|
---|
37 | using namespace flair::simulator;
|
---|
38 |
|
---|
39 | namespace flair {
|
---|
40 | namespace simulator {
|
---|
41 |
|
---|
42 | GenericObject::GenericObject(Simulator *parent, std::string name,
|
---|
43 | ISceneManager *sceneManager)
|
---|
44 | : IMeshSceneNode(sceneManager->getRootSceneNode(), sceneManager,
|
---|
45 | -1) //, IODevice(parent,name)
|
---|
46 | {
|
---|
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;
|
---|
53 |
|
---|
54 | parent->pimpl_->objects.push_back(this);
|
---|
55 | }
|
---|
56 |
|
---|
57 | GenericObject::~GenericObject() {}
|
---|
58 |
|
---|
59 | void GenericObject::setScale(float value) {
|
---|
60 | ISceneNode::setScale(vector3df(value, value, value));
|
---|
61 | }
|
---|
62 |
|
---|
63 | void GenericObject::setScale(vector3df scale) { ISceneNode::setScale(scale); }
|
---|
64 |
|
---|
65 | ITriangleSelector *GenericObject::TriangleSelector(void) { return selector; }
|
---|
66 |
|
---|
67 | void GenericObject::OnRegisterSceneNode(void) {
|
---|
68 | if (IsVisible)
|
---|
69 | SceneManager->registerNodeForRendering(this);
|
---|
70 |
|
---|
71 | ISceneNode::OnRegisterSceneNode();
|
---|
72 | }
|
---|
73 |
|
---|
74 | void 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));
|
---|
81 | }
|
---|
82 |
|
---|
83 | void GenericObject::setMesh(IMesh *mesh) {
|
---|
84 | this->mesh = mesh;
|
---|
85 | box = mesh->getBoundingBox();
|
---|
86 |
|
---|
87 | selector = getSceneManager()->createTriangleSelector(mesh, this);
|
---|
88 | setTriangleSelector(selector);
|
---|
89 | }
|
---|
90 |
|
---|
91 | IMesh *GenericObject::getMesh(void) { return mesh; }
|
---|
92 |
|
---|
93 | void GenericObject::setPosition(irr::core::vector3df pos) {
|
---|
94 | ISceneNode::setPosition(ToIrrlichtCoordinates(pos));
|
---|
95 | }
|
---|
96 |
|
---|
97 | void 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);
|
---|
104 |
|
---|
105 | ISceneNode::setRotation(Euler::ToDegree(1) *
|
---|
106 | vector3df(eulerB.roll, eulerB.pitch, eulerB.yaw));
|
---|
107 | }
|
---|
108 |
|
---|
109 | } // end namespace simulator
|
---|
110 | } // end namespace flair
|
---|
111 | #endif
|
---|