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