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