- Lets start! |
- ||||||||||||
-
- To start, I include the header files, use the irr namespace, and tell - the linker to link with the .lib file. -
Here comes the most sophisticated part of this tutorial: The class
- of our very own custom scene node. To keep it simple, To let our scene node be able to be inserted into the Irrlicht Engine - scene, the class we create needs only be derived from the ISceneNode - class and has to override some methods. -
First, we declare some member variables, to hold data for our tetraeder:
- The bounding box, 4 vertices, and
The parameters of the constructor specify the parent of the scene node, - a pointer to the scene manager, and an id of the scene node. In the - constructor itself, we call the parent classes constructor, set some - properties of the material we use to draw the scene node and create - the 4 vertices of the tetraeder we will draw later. -
- The Irrlicht Engine needs to know the bounding box of your scene node. - It will use it for doing automatic culling and other things. Hence we - need to create a bounding box from the 4 vertices we use. If you do not - want the engine to use the box for automatic culling, and/or don't want - to create the box, you could also write - AutomaticCullingEnabled = false;. - -
- Before it is drawn, the OnPreRender() method of every scene node in
- the scene is called by the scene manager. If the scene node wishes to
- draw itself, it may register itself in the scene manager to be drawn.
- This is necessary to tell the scene manager when it should call the
- ::render method. For example normal scene nodes render their content
- one after another, while stencil buffer shadows would like to be drawn
- after all other scene nodes. And camera or light scene nodes need to
- be rendered before all other scene nodes (if at all).
In the render() method most of the interresting stuff happenes: The Scene - node renders itself. We override this method and draw the tetraeder. -
At least, we create three small additional methods. GetBoundingBox()
- returns the bounding box of this scene node,
That's it. The Scene node is done. Now we simply have to start the engine, - create the scene node and a camera, and look at the result. -
Create our scene node. Note that it is dropped (->drop()) instantly - after we create it. This is possible because the scene manager now takes - care of it. This is not nessecary, it would also be possible to drop it - at the end of the program. -
To animate something in this boring scene consisting only of one tetraeder, - and to show, that you now can use your scene node like any other scene - node in the engine, we add an animator to the scene node, which rotates - the node a little bit. -
Now draw everything and finish. -
That's it. Compile and play around with the program. |
-
- - + + +
+ Lets start! |
+ ||||||||||||
+
+ To start, I include the header files, use the irr namespace, and tell + the linker to link with the .lib file. +
Here comes the most sophisticated part of this tutorial: The class
+ of our very own custom scene node. To keep it simple, To let our scene node be able to be inserted into the Irrlicht Engine + scene, the class we create needs only be derived from the ISceneNode + class and has to override some methods. +
First, we declare some member variables, to hold data for our tetraeder:
+ The bounding box, 4 vertices, and
The parameters of the constructor specify the parent of the scene node, + a pointer to the scene manager, and an id of the scene node. In the + constructor itself, we call the parent classes constructor, set some + properties of the material we use to draw the scene node and create + the 4 vertices of the tetraeder we will draw later. +
+ The Irrlicht Engine needs to know the bounding box of your scene node. + It will use it for doing automatic culling and other things. Hence we + need to create a bounding box from the 4 vertices we use. If you do not + want the engine to use the box for automatic culling, and/or don't want + to create the box, you could also write + AutomaticCullingEnabled = false;. + +
+ Before it is drawn, the OnPreRender() method of every scene node in
+ the scene is called by the scene manager. If the scene node wishes to
+ draw itself, it may register itself in the scene manager to be drawn.
+ This is necessary to tell the scene manager when it should call the
+ ::render method. For example normal scene nodes render their content
+ one after another, while stencil buffer shadows would like to be drawn
+ after all other scene nodes. And camera or light scene nodes need to
+ be rendered before all other scene nodes (if at all).
In the render() method most of the interresting stuff happenes: The Scene + node renders itself. We override this method and draw the tetraeder. +
At least, we create three small additional methods. GetBoundingBox()
+ returns the bounding box of this scene node,
That's it. The Scene node is done. Now we simply have to start the engine, + create the scene node and a camera, and look at the result. +
Create our scene node. Note that it is dropped (->drop()) instantly + after we create it. This is possible because the scene manager now takes + care of it. This is not nessecary, it would also be possible to drop it + at the end of the program. +
To animate something in this boring scene consisting only of one tetraeder, + and to show, that you now can use your scene node like any other scene + node in the engine, we add an animator to the scene node, which rotates + the node a little bit. +
Now draw everything and finish. +
That's it. Compile and play around with the program. |
+
+ + -- cgit v1.1