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: 2012/08/22
|
---|
6 | // filename: MeshSceneNode.cpp
|
---|
7 | //
|
---|
8 | // author: Guillaume Sanahuja
|
---|
9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
10 | //
|
---|
11 | // version: $Id: $
|
---|
12 | //
|
---|
13 | // purpose: classe definissant un IMeshSceneNode
|
---|
14 | //
|
---|
15 | /*********************************************************************/
|
---|
16 | #ifdef GL
|
---|
17 |
|
---|
18 | #include "MeshSceneNode.h"
|
---|
19 | #include "Gui.h"
|
---|
20 | #include "Model.h"
|
---|
21 | #include <ISceneManager.h>
|
---|
22 | #include <IVideoDriver.h>
|
---|
23 |
|
---|
24 | using namespace irr;
|
---|
25 | using namespace irr::video;
|
---|
26 | using namespace irr::scene;
|
---|
27 | using namespace irr::core;
|
---|
28 | using namespace flair::core;
|
---|
29 |
|
---|
30 | namespace flair {
|
---|
31 | namespace simulator {
|
---|
32 |
|
---|
33 | MeshSceneNode::MeshSceneNode(Model *parent, IMesh *mesh,
|
---|
34 | const vector3df &position,
|
---|
35 | const vector3df &rotation, ITexture *texture,
|
---|
36 | s32 id)
|
---|
37 | : IMeshSceneNode(parent->getSceneNode(), getGui()->getSceneManager(), id,
|
---|
38 | position, rotation) {
|
---|
39 | Material.Wireframe = false;
|
---|
40 | Material.Lighting = false;
|
---|
41 |
|
---|
42 | setMesh(mesh);
|
---|
43 |
|
---|
44 | if (texture != NULL) {
|
---|
45 | setMaterialTexture(0, texture);
|
---|
46 | }
|
---|
47 |
|
---|
48 | parent->Box()->addInternalBox(getTransformedBoundingBox());
|
---|
49 | }
|
---|
50 |
|
---|
51 | void MeshSceneNode::OnRegisterSceneNode(void) {
|
---|
52 | if (IsVisible)
|
---|
53 | SceneManager->registerNodeForRendering(this);
|
---|
54 |
|
---|
55 | ISceneNode::OnRegisterSceneNode();
|
---|
56 | }
|
---|
57 |
|
---|
58 | void MeshSceneNode::render(void) {
|
---|
59 | IVideoDriver *driver = SceneManager->getVideoDriver();
|
---|
60 |
|
---|
61 | driver->setMaterial(Material);
|
---|
62 | driver->setTransform(ETS_WORLD, AbsoluteTransformation);
|
---|
63 | driver->drawMeshBuffer(mesh->getMeshBuffer(0));
|
---|
64 | }
|
---|
65 |
|
---|
66 | SMaterial &MeshSceneNode::getMaterial(u32 i) { return Material; }
|
---|
67 |
|
---|
68 | void MeshSceneNode::setMesh(IMesh *ptr) {
|
---|
69 | mesh = ptr;
|
---|
70 | Box = mesh->getBoundingBox();
|
---|
71 | }
|
---|
72 |
|
---|
73 | IMesh *MeshSceneNode::getMesh(void) { return mesh; }
|
---|
74 |
|
---|
75 | void MeshSceneNode::setReadOnlyMaterials(bool readonly) {}
|
---|
76 |
|
---|
77 | } // end namespace simulator
|
---|
78 | } // end namespace flair
|
---|
79 | #endif // GL
|
---|