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 | {
|
---|
41 | namespace simulator
|
---|
42 | {
|
---|
43 |
|
---|
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 | }
|
---|
55 |
|
---|
56 | GenericObject::~GenericObject()
|
---|
57 | {
|
---|
58 |
|
---|
59 | }
|
---|
60 |
|
---|
61 | void GenericObject::setScale(float value)
|
---|
62 | {
|
---|
63 | ISceneNode::setScale(vector3df(value,value,value));
|
---|
64 | }
|
---|
65 |
|
---|
66 | void GenericObject::setScale(vector3df scale)
|
---|
67 | {
|
---|
68 | ISceneNode::setScale(scale);
|
---|
69 | }
|
---|
70 |
|
---|
71 | ITriangleSelector* GenericObject::TriangleSelector(void)
|
---|
72 | {
|
---|
73 | return selector;
|
---|
74 | }
|
---|
75 |
|
---|
76 | void GenericObject::OnRegisterSceneNode(void)
|
---|
77 | {
|
---|
78 | if (IsVisible)
|
---|
79 | SceneManager->registerNodeForRendering(this);
|
---|
80 |
|
---|
81 | ISceneNode::OnRegisterSceneNode();
|
---|
82 | }
|
---|
83 |
|
---|
84 | void GenericObject::render(void)
|
---|
85 | {
|
---|
86 | IVideoDriver* driver = SceneManager->getVideoDriver();
|
---|
87 |
|
---|
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));
|
---|
123 | }
|
---|
124 |
|
---|
125 | } // end namespace simulator
|
---|
126 | } // end namespace flair
|
---|
127 | #endif
|
---|