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

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

lic

File size: 2.3 KB
Line 
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
28using namespace irr;
29using namespace irr::video;
30using namespace irr::scene;
31using namespace irr::core;
32using namespace irr::io;
33using namespace flair::core;
34
35namespace flair
36{
37namespace simulator
38{
39
40Blade::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
69void Blade::OnRegisterSceneNode()
70{
71 if (IsVisible)
72 SceneManager->registerNodeForRendering(this);
73
74 ISceneNode::OnRegisterSceneNode();
75}
76
77void 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
88void 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
Note: See TracBrowser for help on using the repository browser.