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

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

refonte camera simu

File size: 2.8 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: 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 "Quaternion.h"
22#include <ISceneManager.h>
[69]23
[8]24using namespace irr;
25using namespace video;
26using namespace scene;
27using namespace core;
28
29using namespace flair::core;
30using namespace flair::simulator;
31
[15]32namespace flair {
33namespace simulator {
[8]34
[15]35GenericObject::GenericObject(Simulator *parent, std::string name,
36 ISceneManager *sceneManager)
37 : IMeshSceneNode(sceneManager->getRootSceneNode(), sceneManager,
38 -1) //, IODevice(parent,name)
[8]39{
[15]40 setMaterialFlag(EMF_LIGHTING, false);
41 Material = getMaterial(0);
42 // setMaterialTexture(0,sceneManager->getVideoDriver()->getTexture("/home/cesar/igep/uav_dev_svn/trunk/media/nskinbl.jpg"));
43 Material.NormalizeNormals = true;
44 Material.Wireframe = false;
45 Material.Lighting = false;
[8]46
[15]47 parent->pimpl_->objects.push_back(this);
[8]48}
49
[15]50GenericObject::~GenericObject() {}
[8]51
[15]52void GenericObject::setScale(float value) {
53 ISceneNode::setScale(vector3df(value, value, value));
[8]54}
55
[15]56void GenericObject::setScale(vector3df scale) { ISceneNode::setScale(scale); }
[8]57
[15]58ITriangleSelector *GenericObject::TriangleSelector(void) { return selector; }
[8]59
[15]60void GenericObject::OnRegisterSceneNode(void) {
61 if (IsVisible)
62 SceneManager->registerNodeForRendering(this);
[8]63
[15]64 ISceneNode::OnRegisterSceneNode();
[8]65}
66
[15]67void GenericObject::render(void) {
68 IVideoDriver *driver = SceneManager->getVideoDriver();
[8]69
[15]70 driver->setMaterial(Material);
[8]71
[15]72 driver->setTransform(ETS_WORLD, AbsoluteTransformation);
73 driver->drawMeshBuffer(mesh->getMeshBuffer(0));
[8]74}
75
[15]76void GenericObject::setMesh(IMesh *mesh) {
77 this->mesh = mesh;
78 box = mesh->getBoundingBox();
[8]79
[15]80 selector = getSceneManager()->createTriangleSelector(mesh, this);
81 setTriangleSelector(selector);
[8]82}
83
[15]84IMesh *GenericObject::getMesh(void) { return mesh; }
[8]85
[15]86void GenericObject::setPosition(irr::core::vector3df pos) {
87 ISceneNode::setPosition(ToIrrlichtCoordinates(pos));
[8]88}
89
[15]90void GenericObject::setRotation(irr::core::vector3df rotation) {
91 Euler eulerA(rotation.X, rotation.Y, rotation.Z);
92 Euler eulerB;
93 Quaternion quatA, quatB;
94 eulerA.ToQuaternion(quatA);
95 quatB = ToIrrlichtOrientation(quatA);
96 quatB.ToEuler(eulerB);
[8]97
[15]98 ISceneNode::setRotation(Euler::ToDegree(1) *
99 vector3df(eulerB.roll, eulerB.pitch, eulerB.yaw));
[8]100}
101
102} // end namespace simulator
103} // end namespace flair
104#endif
Note: See TracBrowser for help on using the repository browser.