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

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

lic

File size: 2.9 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
40{
41namespace simulator
42{
43
44GenericObject::GenericObject(Simulator* parent,std::string name, ISceneManager* sceneManager) : IMeshSceneNode(sceneManager->getRootSceneNode(), sceneManager, -1)//, IODevice(parent,name)
45{
46    setMaterialFlag(EMF_LIGHTING,false);
47    Material=getMaterial(0);
48    //setMaterialTexture(0,sceneManager->getVideoDriver()->getTexture("/home/cesar/igep/uav_dev_svn/trunk/media/nskinbl.jpg"));
49    Material.NormalizeNormals = true;
50    Material.Wireframe = false;
51    Material.Lighting = false;
52
53    parent->pimpl_->objects.push_back(this);
54}
55
56GenericObject::~GenericObject()
57{
58
59}
60
61void GenericObject::setScale(float value)
62{
63    ISceneNode::setScale(vector3df(value,value,value));
64}
65
66void GenericObject::setScale(vector3df scale)
67{
68    ISceneNode::setScale(scale);
69}
70
71ITriangleSelector* GenericObject::TriangleSelector(void)
72{
73    return selector;
74}
75
76void GenericObject::OnRegisterSceneNode(void)
77{
78    if (IsVisible)
79        SceneManager->registerNodeForRendering(this);
80
81    ISceneNode::OnRegisterSceneNode();
82}
83
84void GenericObject::render(void)
85{
86    IVideoDriver* driver = SceneManager->getVideoDriver();
87
88    driver->setMaterial(Material);
89
90    driver->setTransform(ETS_WORLD, AbsoluteTransformation);
91    driver->drawMeshBuffer(mesh->getMeshBuffer(0));
92}
93
94void GenericObject::setMesh(IMesh* mesh)
95{
96    this->mesh=mesh;
97    box=mesh->getBoundingBox();
98
99    selector = getSceneManager()->createTriangleSelector(mesh,this);
100    setTriangleSelector(selector);
101}
102
103IMesh* GenericObject::getMesh(void)
104{
105    return mesh;
106}
107
108void GenericObject::setPosition(irr::core::vector3df pos)
109{
110    ISceneNode::setPosition(ToIrrlichtCoordinates(pos));
111}
112
113void GenericObject::setRotation(irr::core::vector3df rotation)
114{
115    Euler eulerA(rotation.X,rotation.Y,rotation.Z);
116    Euler eulerB;
117    Quaternion quatA,quatB;
118    eulerA.ToQuaternion(quatA);
119    quatB=ToIrrlichtOrientation(quatA);
120    quatB.ToEuler(eulerB);
121
122    ISceneNode::setRotation(Euler::ToDegree(1)*vector3df(eulerB.roll,eulerB.pitch,eulerB.yaw));
123}
124
125} // end namespace simulator
126} // end namespace flair
127#endif
Note: See TracBrowser for help on using the repository browser.