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: 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 |
|
---|
35 | namespace flair
|
---|
36 | {
|
---|
37 | namespace simulator
|
---|
38 | {
|
---|
39 |
|
---|
40 | Blade::Blade(Model* parent,const vector3df& position,bool inverted,s32 id)
|
---|
41 | : ISceneNode(parent->getSceneNode(), getGui()->getSceneManager(), id,position)
|
---|
42 | {
|
---|
43 | ISceneManager* mgr=getGui()->getSceneManager();
|
---|
44 |
|
---|
45 | const IGeometryCreator *geo;
|
---|
46 | geo=mgr->getGeometryCreator();
|
---|
47 | pale=geo->createCubeMesh(vector3df(63.5,0.5,5));
|
---|
48 |
|
---|
49 | float angle;
|
---|
50 | if(inverted==false)
|
---|
51 | {
|
---|
52 | angle=20;
|
---|
53 | }
|
---|
54 | else
|
---|
55 | {
|
---|
56 | angle=-20;
|
---|
57 | }
|
---|
58 |
|
---|
59 | ITexture* texture=getGui()->getTexture("carbone.jpg");
|
---|
60 | pale_1=new MeshSceneNode(parent, pale, vector3df(-30,0,0),vector3df(-angle+90,0,0),texture);
|
---|
61 | pale_1->setParent(this);
|
---|
62 | pale_2=new MeshSceneNode(parent, pale, vector3df(30,0,0),vector3df(angle+90,0,0),texture);
|
---|
63 | pale_2->setParent(this);
|
---|
64 |
|
---|
65 | anim = mgr->createRotationAnimator(vector3df(0.f, 0.f, 0.f));
|
---|
66 | addAnimator(anim);
|
---|
67 | }
|
---|
68 |
|
---|
69 | void Blade::OnRegisterSceneNode()
|
---|
70 | {
|
---|
71 | if (IsVisible)
|
---|
72 | SceneManager->registerNodeForRendering(this);
|
---|
73 |
|
---|
74 | ISceneNode::OnRegisterSceneNode();
|
---|
75 | }
|
---|
76 |
|
---|
77 | void Blade::SetRotationSpeed(float value)
|
---|
78 | {
|
---|
79 | IAttributes* attribs =getSceneManager()->getFileSystem()->createEmptyAttributes();
|
---|
80 |
|
---|
81 | attribs->setAttribute("Type","rotation");
|
---|
82 | attribs->setAttribute("Rotation",vector3df(0.f, 0.f,value));
|
---|
83 | anim->deserializeAttributes(attribs);
|
---|
84 |
|
---|
85 | attribs->drop();
|
---|
86 | }
|
---|
87 |
|
---|
88 | void Blade::render()
|
---|
89 | {
|
---|
90 | IVideoDriver* driver = SceneManager->getVideoDriver();
|
---|
91 | driver->setTransform(ETS_WORLD, AbsoluteTransformation);
|
---|
92 | }
|
---|
93 |
|
---|
94 | } // end namespace simulator
|
---|
95 | } // end namespace flair
|
---|
96 | #endif //GL
|
---|