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

Last change on this file since 469 was 339, checked in by Sanahuja Guillaume, 5 years ago

allow all blade rotations

File size: 3.3 KB
RevLine 
[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
28using namespace irr;
29using namespace irr::video;
30using namespace irr::scene;
31using namespace irr::core;
32using namespace irr::io;
33using namespace flair::core;
34
[15]35namespace flair {
36namespace simulator {
[8]37
[339]38Blade::Blade(Model *parent, const vector3df &position,const vector3df &rotation, bool inverted, s32 id)
[15]39 : ISceneNode(parent->getSceneNode(), getGui()->getSceneManager(), id,
[339]40 position,rotation) {
[15]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
[339]66Blade::Blade(ISceneNode *parent, const vector3df &position,const vector3df &rotation, bool inverted, s32 id)
[286]67 : ISceneNode(parent, getGui()->getSceneManager(), id,
[339]68 position,rotation) {
[286]69 ISceneManager *mgr = getGui()->getSceneManager();
70
71 const IGeometryCreator *geo;
72 geo = mgr->getGeometryCreator();
73 pale = geo->createCubeMesh(vector3df(63.5, 0.5, 5));
74
75 float angle;
76 if (inverted == false) {
77 angle = 20;
78 } else {
79 angle = -20;
80 }
81
82 ITexture *texture = getGui()->getTexture("carbone.jpg");
83 pale_1 = new MeshSceneNode(parent, pale, vector3df(-30, 0, 0),
84 vector3df(-angle + 90, 0, 0), texture);
85 pale_1->setParent(this);
86 pale_2 = new MeshSceneNode(parent, pale, vector3df(30, 0, 0),
87 vector3df(angle + 90, 0, 0), texture);
88 pale_2->setParent(this);
89
90 anim = mgr->createRotationAnimator(vector3df(0.f, 0.f, 0.f));
91 addAnimator(anim);
92}
93
[15]94void Blade::OnRegisterSceneNode() {
95 if (IsVisible)
96 SceneManager->registerNodeForRendering(this);
[8]97
[15]98 ISceneNode::OnRegisterSceneNode();
[8]99}
[15]100
[339]101void Blade::SetRotationSpeed(const vector3df &value) {
[15]102 IAttributes *attribs =
103 getSceneManager()->getFileSystem()->createEmptyAttributes();
104
105 attribs->setAttribute("Type", "rotation");
[339]106 attribs->setAttribute("Rotation", value);
[15]107 anim->deserializeAttributes(attribs);
108
109 attribs->drop();
[8]110}
111
[15]112void Blade::render() {
113 IVideoDriver *driver = SceneManager->getVideoDriver();
114 driver->setTransform(ETS_WORLD, AbsoluteTransformation);
115}
116
[8]117} // end namespace simulator
118} // end namespace flair
[15]119#endif // GL
Note: See TracBrowser for help on using the repository browser.