Update comments.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5497 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
d476cbe3e9
commit
0c8a5f8700
|
@ -1,6 +1,6 @@
|
||||||
/** Example 001 HelloWorld
|
/** Example 001 HelloWorld
|
||||||
|
|
||||||
This Tutorial shows how to set up the IDE for using the Irrlicht Engine and how
|
This tutorial shows how to set up the IDE for using the Irrlicht Engine and how
|
||||||
to write a simple HelloWorld program with it. The program will show how to use
|
to write a simple HelloWorld program with it. The program will show how to use
|
||||||
the basics of the VideoDriver, the GUIEnvironment, and the SceneManager.
|
the basics of the VideoDriver, the GUIEnvironment, and the SceneManager.
|
||||||
Microsoft Visual Studio is used as an IDE, but you will also be able to
|
Microsoft Visual Studio is used as an IDE, but you will also be able to
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/** Example 002 Quake3Map
|
/** Example 002 Quake3Map
|
||||||
|
|
||||||
This Tutorial shows how to load a Quake 3 map into the engine, create a
|
This tutorial shows how to load a Quake 3 map into the engine, create a
|
||||||
SceneNode for optimizing the speed of rendering, and how to create a user
|
SceneNode for optimizing the speed of rendering, and how to create a user
|
||||||
controlled camera.
|
controlled camera.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/** Example 003 Custom SceneNode
|
/** Example 003 Custom SceneNode
|
||||||
|
|
||||||
This Tutorial is more advanced than the previous ones.
|
This tutorial is more advanced than the previous ones.
|
||||||
If you are currently just playing around with the Irrlicht
|
If you are currently just playing around with the Irrlicht
|
||||||
engine, you may want to look at other examples first.
|
engine, you may want to look at other examples first.
|
||||||
This tutorials shows how to create a custom scene node and
|
This tutorials shows how to create a custom scene node and
|
||||||
|
@ -9,12 +9,11 @@ if you want to implement a render technique the Irrlicht
|
||||||
Engine currently does not support. For example, you can write
|
Engine currently does not support. For example, you can write
|
||||||
an indoor portal based renderer or an advanced terrain scene
|
an indoor portal based renderer or an advanced terrain scene
|
||||||
node with it. By creating custom scene nodes, you can
|
node with it. By creating custom scene nodes, you can
|
||||||
easily extend the Irrlicht Engine and adapt it to your own
|
easily extend the Irrlicht Engine and adapt it to your needs.
|
||||||
needs.
|
|
||||||
|
|
||||||
I will keep the tutorial simple: Keep everything very
|
I will keep the tutorial simple: Keep everything very short
|
||||||
short, everything in one .cpp file, and I'll use the engine
|
and everything in one .cpp file. This is the style which
|
||||||
here as in all other tutorials.
|
will also be used in most of the following tutorials.
|
||||||
|
|
||||||
To start, I include the header files, use the irr namespace,
|
To start, I include the header files, use the irr namespace,
|
||||||
and tell the linker to link with the .lib file.
|
and tell the linker to link with the .lib file.
|
||||||
|
@ -32,14 +31,14 @@ using namespace irr;
|
||||||
Here comes the more sophisticated part of this tutorial:
|
Here comes the more sophisticated part of this tutorial:
|
||||||
The class of our very own custom scene node. To keep it simple,
|
The class of our very own custom scene node. To keep it simple,
|
||||||
our scene node will not be an indoor portal renderer nor a terrain
|
our scene node will not be an indoor portal renderer nor a terrain
|
||||||
scene node, but a simple tetraeder, a 3d object consisting of 4
|
scene node, but a simple tetrahedron, a 3D object consisting of 4
|
||||||
connected vertices, which only draws itself and does nothing more.
|
connected vertices, which only draws itself and does nothing more.
|
||||||
Note that this scenario does not require a custom scene node in Irrlicht.
|
Note that this scenario does not require a custom scene node in Irrlicht.
|
||||||
Instead one would create a mesh from the geometry and pass it to a
|
Instead one would create a mesh from the geometry and pass it to a
|
||||||
irr::scene::IMeshSceneNode. This example just illustrates creation of a custom
|
irr::scene::IMeshSceneNode. This example just illustrates creation of a custom
|
||||||
scene node in a very simple setting.
|
scene node in a simple setting.
|
||||||
|
|
||||||
To let our scene node be able to be inserted into the Irrlicht
|
To allow our scene node to be inserted into the Irrlicht
|
||||||
Engine scene, the class we create needs to be derived from the
|
Engine scene, the class we create needs to be derived from the
|
||||||
irr::scene::ISceneNode class and has to override some methods.
|
irr::scene::ISceneNode class and has to override some methods.
|
||||||
*/
|
*/
|
||||||
|
@ -49,22 +48,22 @@ class CSampleSceneNode : public scene::ISceneNode
|
||||||
|
|
||||||
/*
|
/*
|
||||||
First, we declare some member variables:
|
First, we declare some member variables:
|
||||||
The bounding box, 4 vertices, and the material of the tetraeder.
|
The bounding box, 4 vertices, and the material of the tetrahedron.
|
||||||
*/
|
*/
|
||||||
core::aabbox3d<f32> Box;
|
core::aabbox3d<f32> Box;
|
||||||
video::S3DVertex Vertices[4];
|
video::S3DVertex Vertices[4];
|
||||||
video::SMaterial Material;
|
video::SMaterial Material;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The parameters of the constructor specify the parent of the scene node,
|
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.
|
a pointer to the scene manager, and an id of the scene node.
|
||||||
In the constructor we call the parent class' constructor,
|
In the constructor we call the parent class' constructor,
|
||||||
set some properties of the material, and
|
set some properties of the material, and create the 4 vertices of
|
||||||
create the 4 vertices of the tetraeder we will draw later.
|
the tetrahedron.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
CSampleSceneNode(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id)
|
CSampleSceneNode(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id)
|
||||||
: scene::ISceneNode(parent, mgr, id)
|
: scene::ISceneNode(parent, mgr, id)
|
||||||
{
|
{
|
||||||
|
@ -106,10 +105,9 @@ public:
|
||||||
scene node to render normally. If we would like to let it be rendered
|
scene node to render normally. If we would like to let it be rendered
|
||||||
like cameras or light, we would have to call
|
like cameras or light, we would have to call
|
||||||
SceneManager->registerNodeForRendering(this, SNRT_LIGHT_AND_CAMERA);
|
SceneManager->registerNodeForRendering(this, SNRT_LIGHT_AND_CAMERA);
|
||||||
After this, we call the actual
|
After this, we call the actual irr::scene::ISceneNode::OnRegisterSceneNode()
|
||||||
irr::scene::ISceneNode::OnRegisterSceneNode() method of the base class,
|
method of the base class, which lets all the child scene nodes of this node
|
||||||
which simply lets also all the child scene nodes of this node register
|
register themselves.
|
||||||
themselves.
|
|
||||||
*/
|
*/
|
||||||
virtual void OnRegisterSceneNode()
|
virtual void OnRegisterSceneNode()
|
||||||
{
|
{
|
||||||
|
@ -122,7 +120,7 @@ public:
|
||||||
/*
|
/*
|
||||||
In the render() method most of the interesting stuff happens: The
|
In the render() method most of the interesting stuff happens: The
|
||||||
Scene node renders itself. We override this method and draw the
|
Scene node renders itself. We override this method and draw the
|
||||||
tetraeder.
|
tetrahedron.
|
||||||
*/
|
*/
|
||||||
virtual void render()
|
virtual void render()
|
||||||
{
|
{
|
||||||
|
@ -141,11 +139,11 @@ public:
|
||||||
And finally we create three small additional methods.
|
And finally we create three small additional methods.
|
||||||
irr::scene::ISceneNode::getBoundingBox() returns the bounding box of
|
irr::scene::ISceneNode::getBoundingBox() returns the bounding box of
|
||||||
this scene node, irr::scene::ISceneNode::getMaterialCount() returns the
|
this scene node, irr::scene::ISceneNode::getMaterialCount() returns the
|
||||||
amount of materials in this scene node (our tetraeder only has one
|
amount of materials in this scene node (our tetrahedron only has one
|
||||||
material), and irr::scene::ISceneNode::getMaterial() returns the
|
material), and irr::scene::ISceneNode::getMaterial() returns the
|
||||||
material at an index. Because we have only one material here, we can
|
material at an index. Because we have only one material, we can
|
||||||
return the only one material, assuming that no one ever calls
|
return that and assume that no one ever calls getMaterial() with an index
|
||||||
getMaterial() with an index greater than 0.
|
greater than 0.
|
||||||
*/
|
*/
|
||||||
virtual const core::aabbox3d<f32>& getBoundingBox() const
|
virtual const core::aabbox3d<f32>& getBoundingBox() const
|
||||||
{
|
{
|
||||||
|
@ -164,8 +162,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
That's it. The Scene node is done. Now we simply have to start
|
That's it. The Scene node is done. Now we start the engine,
|
||||||
the engine, create the scene node and a camera, and look at the result.
|
create the scene node and a camera, and look at the result.
|
||||||
*/
|
*/
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
@ -175,14 +173,13 @@ int main()
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// create device
|
// create device
|
||||||
|
|
||||||
IrrlichtDevice *device = createDevice(driverType,
|
IrrlichtDevice *device = createDevice(driverType,
|
||||||
core::dimension2d<u32>(640, 480), 16, false);
|
core::dimension2d<u32>(640, 480), 16, false);
|
||||||
|
|
||||||
if (device == 0)
|
if (device == 0)
|
||||||
return 1; // could not create selected driver.
|
return 1; // could not create selected driver.
|
||||||
|
|
||||||
// create engine and camera
|
// set window caption, get some pointers, create a camera
|
||||||
|
|
||||||
device->setWindowCaption(L"Custom Scene Node - Irrlicht Engine Demo");
|
device->setWindowCaption(L"Custom Scene Node - Irrlicht Engine Demo");
|
||||||
|
|
||||||
|
@ -205,7 +202,7 @@ int main()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
To animate something in this boring scene consisting only of one
|
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
|
tetrahedron, 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,
|
other scene node in the engine, we add an animator to the scene node,
|
||||||
which rotates the node a little bit.
|
which rotates the node a little bit.
|
||||||
irr::scene::ISceneManager::createRotationAnimator() could return 0, so
|
irr::scene::ISceneManager::createRotationAnimator() could return 0, so
|
||||||
|
@ -248,7 +245,7 @@ int main()
|
||||||
smgr->drawAll();
|
smgr->drawAll();
|
||||||
|
|
||||||
driver->endScene();
|
driver->endScene();
|
||||||
if (++frames==100)
|
if (++frames==100) // don't update more often, setWindowCaption can be expensive
|
||||||
{
|
{
|
||||||
core::stringw str = L"Irrlicht Engine [";
|
core::stringw str = L"Irrlicht Engine [";
|
||||||
str += driver->getName();
|
str += driver->getName();
|
||||||
|
|
Loading…
Reference in New Issue