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

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

simulator

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