[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"
|
---|
| 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 |
|
---|
[15] | 39 | namespace flair {
|
---|
| 40 | namespace simulator {
|
---|
[8] | 41 |
|
---|
[15] | 42 | GenericObject::GenericObject(Simulator *parent, std::string name,
|
---|
| 43 | ISceneManager *sceneManager)
|
---|
| 44 | : IMeshSceneNode(sceneManager->getRootSceneNode(), sceneManager,
|
---|
| 45 | -1) //, IODevice(parent,name)
|
---|
[8] | 46 | {
|
---|
[15] | 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;
|
---|
[8] | 53 |
|
---|
[15] | 54 | parent->pimpl_->objects.push_back(this);
|
---|
[8] | 55 | }
|
---|
| 56 |
|
---|
[15] | 57 | GenericObject::~GenericObject() {}
|
---|
[8] | 58 |
|
---|
[15] | 59 | void GenericObject::setScale(float value) {
|
---|
| 60 | ISceneNode::setScale(vector3df(value, value, value));
|
---|
[8] | 61 | }
|
---|
| 62 |
|
---|
[15] | 63 | void GenericObject::setScale(vector3df scale) { ISceneNode::setScale(scale); }
|
---|
[8] | 64 |
|
---|
[15] | 65 | ITriangleSelector *GenericObject::TriangleSelector(void) { return selector; }
|
---|
[8] | 66 |
|
---|
[15] | 67 | void GenericObject::OnRegisterSceneNode(void) {
|
---|
| 68 | if (IsVisible)
|
---|
| 69 | SceneManager->registerNodeForRendering(this);
|
---|
[8] | 70 |
|
---|
[15] | 71 | ISceneNode::OnRegisterSceneNode();
|
---|
[8] | 72 | }
|
---|
| 73 |
|
---|
[15] | 74 | void GenericObject::render(void) {
|
---|
| 75 | IVideoDriver *driver = SceneManager->getVideoDriver();
|
---|
[8] | 76 |
|
---|
[15] | 77 | driver->setMaterial(Material);
|
---|
[8] | 78 |
|
---|
[15] | 79 | driver->setTransform(ETS_WORLD, AbsoluteTransformation);
|
---|
| 80 | driver->drawMeshBuffer(mesh->getMeshBuffer(0));
|
---|
[8] | 81 | }
|
---|
| 82 |
|
---|
[15] | 83 | void GenericObject::setMesh(IMesh *mesh) {
|
---|
| 84 | this->mesh = mesh;
|
---|
| 85 | box = mesh->getBoundingBox();
|
---|
[8] | 86 |
|
---|
[15] | 87 | selector = getSceneManager()->createTriangleSelector(mesh, this);
|
---|
| 88 | setTriangleSelector(selector);
|
---|
[8] | 89 | }
|
---|
| 90 |
|
---|
[15] | 91 | IMesh *GenericObject::getMesh(void) { return mesh; }
|
---|
[8] | 92 |
|
---|
[15] | 93 | void GenericObject::setPosition(irr::core::vector3df pos) {
|
---|
| 94 | ISceneNode::setPosition(ToIrrlichtCoordinates(pos));
|
---|
[8] | 95 | }
|
---|
| 96 |
|
---|
[15] | 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);
|
---|
[8] | 104 |
|
---|
[15] | 105 | ISceneNode::setRotation(Euler::ToDegree(1) *
|
---|
| 106 | vector3df(eulerB.roll, eulerB.pitch, eulerB.yaw));
|
---|
[8] | 107 | }
|
---|
| 108 |
|
---|
| 109 | } // end namespace simulator
|
---|
| 110 | } // end namespace flair
|
---|
| 111 | #endif
|
---|