[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: 2012/08/22
|
---|
| 6 | // filename: Blade.cpp
|
---|
| 7 | //
|
---|
| 8 | // author: Guillaume Sanahuja
|
---|
| 9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 10 | //
|
---|
| 11 | // version: $Id: $
|
---|
| 12 | //
|
---|
| 13 | // purpose: classe definissant une helice
|
---|
| 14 | //
|
---|
| 15 | /*********************************************************************/
|
---|
| 16 | #ifdef GL
|
---|
| 17 |
|
---|
| 18 | #include "Blade.h"
|
---|
| 19 | #include "MeshSceneNode.h"
|
---|
| 20 | #include "Model.h"
|
---|
| 21 | #include "Gui.h"
|
---|
| 22 | #include "Simulator.h"
|
---|
| 23 | #include <IGeometryCreator.h>
|
---|
| 24 | #include <ISceneManager.h>
|
---|
| 25 | #include <IFileSystem.h>
|
---|
| 26 | #include <IVideoDriver.h>
|
---|
| 27 |
|
---|
| 28 | using namespace irr;
|
---|
| 29 | using namespace irr::video;
|
---|
| 30 | using namespace irr::scene;
|
---|
| 31 | using namespace irr::core;
|
---|
| 32 | using namespace irr::io;
|
---|
| 33 | using namespace flair::core;
|
---|
| 34 |
|
---|
[15] | 35 | namespace flair {
|
---|
| 36 | namespace simulator {
|
---|
[8] | 37 |
|
---|
[15] | 38 | Blade::Blade(Model *parent, const vector3df &position, bool inverted, s32 id)
|
---|
| 39 | : ISceneNode(parent->getSceneNode(), getGui()->getSceneManager(), id,
|
---|
| 40 | position) {
|
---|
| 41 | ISceneManager *mgr = getGui()->getSceneManager();
|
---|
[8] | 42 |
|
---|
[15] | 43 | const IGeometryCreator *geo;
|
---|
| 44 | geo = mgr->getGeometryCreator();
|
---|
| 45 | pale = geo->createCubeMesh(vector3df(63.5, 0.5, 5));
|
---|
[8] | 46 |
|
---|
[15] | 47 | float angle;
|
---|
| 48 | if (inverted == false) {
|
---|
| 49 | angle = 20;
|
---|
| 50 | } else {
|
---|
| 51 | angle = -20;
|
---|
| 52 | }
|
---|
[8] | 53 |
|
---|
[15] | 54 | ITexture *texture = getGui()->getTexture("carbone.jpg");
|
---|
| 55 | pale_1 = new MeshSceneNode(parent, pale, vector3df(-30, 0, 0),
|
---|
| 56 | vector3df(-angle + 90, 0, 0), texture);
|
---|
| 57 | pale_1->setParent(this);
|
---|
| 58 | pale_2 = new MeshSceneNode(parent, pale, vector3df(30, 0, 0),
|
---|
| 59 | vector3df(angle + 90, 0, 0), texture);
|
---|
| 60 | pale_2->setParent(this);
|
---|
[8] | 61 |
|
---|
[15] | 62 | anim = mgr->createRotationAnimator(vector3df(0.f, 0.f, 0.f));
|
---|
| 63 | addAnimator(anim);
|
---|
| 64 | }
|
---|
[8] | 65 |
|
---|
[15] | 66 | void Blade::OnRegisterSceneNode() {
|
---|
| 67 | if (IsVisible)
|
---|
| 68 | SceneManager->registerNodeForRendering(this);
|
---|
[8] | 69 |
|
---|
[15] | 70 | ISceneNode::OnRegisterSceneNode();
|
---|
[8] | 71 | }
|
---|
[15] | 72 |
|
---|
| 73 | void Blade::SetRotationSpeed(float value) {
|
---|
| 74 | IAttributes *attribs =
|
---|
| 75 | getSceneManager()->getFileSystem()->createEmptyAttributes();
|
---|
| 76 |
|
---|
| 77 | attribs->setAttribute("Type", "rotation");
|
---|
| 78 | attribs->setAttribute("Rotation", vector3df(0.f, 0.f, value));
|
---|
| 79 | anim->deserializeAttributes(attribs);
|
---|
| 80 |
|
---|
| 81 | attribs->drop();
|
---|
[8] | 82 | }
|
---|
| 83 |
|
---|
[15] | 84 | void Blade::render() {
|
---|
| 85 | IVideoDriver *driver = SceneManager->getVideoDriver();
|
---|
| 86 | driver->setTransform(ETS_WORLD, AbsoluteTransformation);
|
---|
| 87 | }
|
---|
| 88 |
|
---|
[8] | 89 | } // end namespace simulator
|
---|
| 90 | } // end namespace flair
|
---|
[15] | 91 | #endif // GL
|
---|