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.h"
|
---|
20 | #include "Simulator_impl.h"
|
---|
21 | #include "Gui.h"
|
---|
22 |
|
---|
23 | #include "Quaternion.h"
|
---|
24 | #include "Euler.h"
|
---|
25 | #include <ISceneManager.h>
|
---|
26 | #include <IMeshSceneNode.h>
|
---|
27 |
|
---|
28 | using namespace irr;
|
---|
29 | using namespace video;
|
---|
30 | using namespace scene;
|
---|
31 | using namespace core;
|
---|
32 |
|
---|
33 | using namespace flair::core;
|
---|
34 | using namespace flair::simulator;
|
---|
35 |
|
---|
36 | namespace flair {
|
---|
37 | namespace simulator {
|
---|
38 |
|
---|
39 | GenericObject::GenericObject(IMesh *mesh)
|
---|
40 | {
|
---|
41 | meshSceneNode=getGui()->getSceneManager()->addMeshSceneNode(mesh);
|
---|
42 | /*
|
---|
43 | selector = getGui()->getSceneManager()->createTriangleSelector(mesh, meshSceneNode);
|
---|
44 | meshSceneNode->setTriangleSelector(selector);
|
---|
45 | */
|
---|
46 | meshSceneNode->setMaterialFlag(EMF_LIGHTING, false);
|
---|
47 |
|
---|
48 | getSimulator()->pimpl_->objects.push_back(this);
|
---|
49 | }
|
---|
50 |
|
---|
51 | GenericObject::~GenericObject() {}
|
---|
52 |
|
---|
53 | ITriangleSelector *GenericObject::TriangleSelector(void) { return selector; }
|
---|
54 |
|
---|
55 | void GenericObject::setVisible(bool isVisible) {
|
---|
56 | meshSceneNode->setVisible(isVisible);
|
---|
57 | }
|
---|
58 | void GenericObject::setScale(float value) {
|
---|
59 | meshSceneNode->setScale(vector3df(value, value, value));
|
---|
60 | }
|
---|
61 |
|
---|
62 | void GenericObject::setScale(const vector3df& scale) {
|
---|
63 | meshSceneNode->setScale(scale);
|
---|
64 | }
|
---|
65 |
|
---|
66 | void GenericObject::setPosition(const vector3df& pos) {
|
---|
67 | meshSceneNode->setPosition(ToIrrlichtCoordinates(pos));
|
---|
68 | }
|
---|
69 |
|
---|
70 | void GenericObject::setRotation(const vector3df& rotation) {
|
---|
71 | Euler eulerA(rotation.X, rotation.Y, rotation.Z);
|
---|
72 | Euler eulerB;
|
---|
73 | Quaternion quatA, quatB;
|
---|
74 | eulerA.ToQuaternion(quatA);
|
---|
75 | quatB = ToIrrlichtOrientation(quatA);
|
---|
76 | quatB.ToEuler(eulerB);
|
---|
77 |
|
---|
78 | meshSceneNode->setRotation(Euler::ToDegree(1) *
|
---|
79 | vector3df(eulerB.roll, eulerB.pitch, eulerB.yaw));
|
---|
80 | }
|
---|
81 |
|
---|
82 | } // end namespace simulator
|
---|
83 | } // end namespace flair
|
---|
84 | #endif
|
---|