source: flair-src/trunk/lib/FlairSimulator/src/Blade.cpp@ 8

Last change on this file since 8 was 8, checked in by Sanahuja Guillaume, 6 years ago

simulator

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