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

Last change on this file since 197 was 15, checked in by Bayard Gildas, 9 years ago

sources reformatted with flair-format-dir script

File size: 2.4 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 {
36namespace simulator {
37
38Blade::Blade(Model *parent, const vector3df &position, bool inverted, s32 id)
39 : ISceneNode(parent->getSceneNode(), getGui()->getSceneManager(), id,
40 position) {
41 ISceneManager *mgr = getGui()->getSceneManager();
42
43 const IGeometryCreator *geo;
44 geo = mgr->getGeometryCreator();
45 pale = geo->createCubeMesh(vector3df(63.5, 0.5, 5));
46
47 float angle;
48 if (inverted == false) {
49 angle = 20;
50 } else {
51 angle = -20;
52 }
53
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);
61
62 anim = mgr->createRotationAnimator(vector3df(0.f, 0.f, 0.f));
63 addAnimator(anim);
64}
65
66void Blade::OnRegisterSceneNode() {
67 if (IsVisible)
68 SceneManager->registerNodeForRendering(this);
69
70 ISceneNode::OnRegisterSceneNode();
71}
72
73void 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();
82}
83
84void Blade::render() {
85 IVideoDriver *driver = SceneManager->getVideoDriver();
86 driver->setTransform(ETS_WORLD, AbsoluteTransformation);
87}
88
89} // end namespace simulator
90} // end namespace flair
91#endif // GL
Note: See TracBrowser for help on using the repository browser.