source: flair-src/trunk/lib/FlairSimulator/src/GenericObject.cpp@ 45

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

sources reformatted with flair-format-dir script

File size: 3.0 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: 2013/03/25
6// filename: GenericObject.cpp
7//
8// author: Cesar Richard
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: classe definissant un modele a simuler
14//
15/*********************************************************************/
16
17#ifdef GL
18#include "GenericObject.h"
19#include "Simulator_impl.h"
20
21#include "ConditionVariable.h"
22#include "Quaternion.h"
23#include "Gui.h"
24#include "Gui_impl.h"
25#include <IMesh.h>
26#include <ISceneManager.h>
27#include <IMetaTriangleSelector.h>
28#include <IVideoDriver.h>
29#include "AnimPoursuite.h"
30using namespace irr;
31using namespace video;
32using namespace scene;
33using namespace core;
34using namespace io;
35
36using namespace flair::core;
37using namespace flair::simulator;
38
39namespace flair {
40namespace simulator {
41
42GenericObject::GenericObject(Simulator *parent, std::string name,
43 ISceneManager *sceneManager)
44 : IMeshSceneNode(sceneManager->getRootSceneNode(), sceneManager,
45 -1) //, IODevice(parent,name)
46{
47 setMaterialFlag(EMF_LIGHTING, false);
48 Material = getMaterial(0);
49 // setMaterialTexture(0,sceneManager->getVideoDriver()->getTexture("/home/cesar/igep/uav_dev_svn/trunk/media/nskinbl.jpg"));
50 Material.NormalizeNormals = true;
51 Material.Wireframe = false;
52 Material.Lighting = false;
53
54 parent->pimpl_->objects.push_back(this);
55}
56
57GenericObject::~GenericObject() {}
58
59void GenericObject::setScale(float value) {
60 ISceneNode::setScale(vector3df(value, value, value));
61}
62
63void GenericObject::setScale(vector3df scale) { ISceneNode::setScale(scale); }
64
65ITriangleSelector *GenericObject::TriangleSelector(void) { return selector; }
66
67void GenericObject::OnRegisterSceneNode(void) {
68 if (IsVisible)
69 SceneManager->registerNodeForRendering(this);
70
71 ISceneNode::OnRegisterSceneNode();
72}
73
74void GenericObject::render(void) {
75 IVideoDriver *driver = SceneManager->getVideoDriver();
76
77 driver->setMaterial(Material);
78
79 driver->setTransform(ETS_WORLD, AbsoluteTransformation);
80 driver->drawMeshBuffer(mesh->getMeshBuffer(0));
81}
82
83void GenericObject::setMesh(IMesh *mesh) {
84 this->mesh = mesh;
85 box = mesh->getBoundingBox();
86
87 selector = getSceneManager()->createTriangleSelector(mesh, this);
88 setTriangleSelector(selector);
89}
90
91IMesh *GenericObject::getMesh(void) { return mesh; }
92
93void GenericObject::setPosition(irr::core::vector3df pos) {
94 ISceneNode::setPosition(ToIrrlichtCoordinates(pos));
95}
96
97void GenericObject::setRotation(irr::core::vector3df rotation) {
98 Euler eulerA(rotation.X, rotation.Y, rotation.Z);
99 Euler eulerB;
100 Quaternion quatA, quatB;
101 eulerA.ToQuaternion(quatA);
102 quatB = ToIrrlichtOrientation(quatA);
103 quatB.ToEuler(eulerB);
104
105 ISceneNode::setRotation(Euler::ToDegree(1) *
106 vector3df(eulerB.roll, eulerB.pitch, eulerB.yaw));
107}
108
109} // end namespace simulator
110} // end namespace flair
111#endif
Note: See TracBrowser for help on using the repository browser.