Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > 58828b263d8f56d90ac336dea07a4586 > files > 738

irrlicht-doc-1.6.1-1mdv2010.1.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Irrlicht Engine: Tutorial 7: Collision</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<table class="irrlicht" >
  <tr valign="middle"> 
    <td><font size="2"><a class="qindex" href="index.html"><font color="#FFFFFF">Home</font></a> 
      | <a class="qindex" href="namespaces.html"><font color="#FFFFFF">Namespaces</font></a> 
      | <a class="qindex" href="hierarchy.html"><font color="#FFFFFF">Hierarchy</font></a> 
      | <a class="qindex" href="classes.html"><font color="#FFFFFF">Alphabetical 
      List</font></a> | <a class="qindex" href="annotated.html"><font color="#FFFFFF"> 
      Class list</font></a> | <a class="qindex" href="files.html"><font color="#FFFFFF">Files</font></a> 
      | <a class="qindex" href="namespacemembers.html"><font color="#FFFFFF"> 
      Namespace&nbsp;Members</font></a> | <a class="qindex" href="functions.html"><font color="#FFFFFF">Class 
      members</font></a> | <a class="qindex" href="globals.html"><font color="#FFFFFF">File 
      members</font></a> | <a class="qindex" href="pages.html"><font color="#FFFFFF">Tutorials</font></a></font> </td>
  </tr>
</table>
<!-- Generated by Doxygen 1.5.6 -->
<div class="contents">
<h1><a class="anchor" name="example007">Tutorial 7: Collision </a></h1><div align="center">
<img src="007shot.jpg" alt="007shot.jpg">
</div>
 <p>
We will describe 2 methods: Automatic collision detection for moving through 3d worlds with stair climbing and sliding, and manual scene node and triangle picking using a ray. In this case, we will use a ray coming out from the camera, but you can use any ray.<p>
To start, we take the program from tutorial 2, which loads and displays a quake 3 level. We will use the level to walk in it and to pick triangles from. In addition we'll place 3 animated models into it for triangle picking. The following code starts up the engine and loads a quake 3 level, as per tutorial 2. <div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;<a class="code" href="irrlicht_8h.html" title="Main header file of the irrlicht, the only file needed to include.">irrlicht.h</a>&gt;</span>
<span class="preprocessor">#include &lt;iostream&gt;</span>

<span class="keyword">using namespace </span>irr;

<span class="preprocessor">#ifdef _MSC_VER</span>
<span class="preprocessor"></span><span class="preprocessor">#pragma comment(lib, "Irrlicht.lib")</span>
<span class="preprocessor"></span><span class="preprocessor">#endif</span>
<span class="preprocessor"></span>
<span class="keyword">enum</span>
{
        <span class="comment">// I use this ISceneNode ID to indicate a scene node that is</span>
        <span class="comment">// not pickable by getSceneNodeAndCollisionPointFromRay()</span>
        ID_IsNotPickable = 0,

        <span class="comment">// I use this flag in ISceneNode IDs to indicate that the</span>
        <span class="comment">// scene node can be picked by ray selection.</span>
        IDFlag_IsPickable = 1 &lt;&lt; 0,

        <span class="comment">// I use this flag in ISceneNode IDs to indicate that the</span>
        <span class="comment">// scene node can be highlighted.  In this example, the</span>
        <span class="comment">// homonids can be highlighted, but the level mesh can't.</span>
        IDFlag_IsHighlightable = 1 &lt;&lt; 1
};

<span class="keywordtype">int</span> main()
{
        <span class="comment">// let user select driver type</span>

        <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d0" title="An enum for all types of drivers the Irrlicht Engine supports.">video::E_DRIVER_TYPE</a> driverType;

        printf(<span class="stringliteral">"Please select the driver you want for this example:\n"</span>\
                <span class="stringliteral">" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"</span>\
                <span class="stringliteral">" (d) Software Renderer\n (e) Burning's Software Renderer\n"</span>\
                <span class="stringliteral">" (f) NullDevice\n (otherKey) exit\n\n"</span>);

        <span class="keywordtype">char</span> i;
        std::cin &gt;&gt; i;

        <span class="keywordflow">switch</span>(i)
        {
                <span class="keywordflow">case</span> <span class="charliteral">'a'</span>: driverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d04691ca314f9018f508dcf2c57dcaacec" title="Direct3D 9 device, only available on Win32 platforms.">video::EDT_DIRECT3D9</a>;<span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> <span class="charliteral">'b'</span>: driverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d08cc3807f6f28404f3424ad7e31b3142f" title="Direct3D8 device, only available on Win32 platforms.">video::EDT_DIRECT3D8</a>;<span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> <span class="charliteral">'c'</span>: driverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d02715182a79f1cb8e2826fd68a8150a53" title="OpenGL device, available on most platforms.">video::EDT_OPENGL</a>;   <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> <span class="charliteral">'d'</span>: driverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d01598cd235a1a6bd052e2011b559e8995" title="The Irrlicht Engine Software renderer.">video::EDT_SOFTWARE</a>; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> <span class="charliteral">'e'</span>: driverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d0e85481da26159b967191ccc6de1e4a05" title="The Burning&amp;#39;s Software Renderer, an alternative software renderer.">video::EDT_BURNINGSVIDEO</a>;<span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> <span class="charliteral">'f'</span>: driverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d0cfdbd476cbfd4d05e72f9adffcc42210" title="Null driver, useful for applications to run the engine without visualisation.">video::EDT_NULL</a>;     <span class="keywordflow">break</span>;
                <span class="keywordflow">default</span>: <span class="keywordflow">return</span> 0;
        }

        <span class="comment">// create device</span>

        IrrlichtDevice *device =
                <a class="code" href="namespaceirr.html#baf4d8719cc26b0d30813abf85e47c76" title="Creates an Irrlicht device. The Irrlicht device is the root object for using the...">createDevice</a>(driverType, core::dimension2d&lt;u32&gt;(640, 480), 16, <span class="keyword">false</span>);

        <span class="keywordflow">if</span> (device == 0)
                <span class="keywordflow">return</span> 1; <span class="comment">// could not create selected driver.</span>

        video::IVideoDriver* driver = device-&gt;getVideoDriver();
        scene::ISceneManager* smgr = device-&gt;getSceneManager();

        device-&gt;getFileSystem()-&gt;addZipFileArchive(<span class="stringliteral">"../../media/map-20kdm2.pk3"</span>);

        scene::IAnimatedMesh* q3levelmesh = smgr-&gt;getMesh(<span class="stringliteral">"20kdm2.bsp"</span>);
        scene::IMeshSceneNode* q3node = 0;

        <span class="comment">// The Quake mesh is pickable, but doesn't get highlighted.</span>
        <span class="keywordflow">if</span> (q3levelmesh)
                q3node = smgr-&gt;addOctTreeSceneNode(q3levelmesh-&gt;getMesh(0), 0, IDFlag_IsPickable);
</pre></div><p>
So far so good, we've loaded the quake 3 level like in tutorial 2. Now, here comes something different: We create a triangle selector. A triangle selector is a class which can fetch the triangles from scene nodes for doing different things with them, for example collision detection. There are different triangle selectors, and all can be created with the ISceneManager. In this example, we create an OctTreeTriangleSelector, which optimizes the triangle output a little bit by reducing it like an octree. This is very useful for huge meshes like quake 3 levels. After we created the triangle selector, we attach it to the q3node. This is not necessary, but in this way, we do not need to care for the selector, for example dropping it after we do not need it anymore. <div class="fragment"><pre class="fragment">        scene::ITriangleSelector* selector = 0;

        <span class="keywordflow">if</span> (q3node)
        {
                q3node-&gt;setPosition(<a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(-1350,-130,-1400));

                selector = smgr-&gt;createOctTreeTriangleSelector(
                                q3node-&gt;getMesh(), q3node, 128);
                q3node-&gt;setTriangleSelector(selector);
                <span class="comment">// We're not done with this selector yet, so don't drop it.</span>
        }
</pre></div><p>
We add a first person shooter camera to the scene so that we can see and move in the quake 3 level like in tutorial 2. But this, time, we add a special animator to the camera: A Collision Response animator. This animator modifies the scene node to which it is attached to in order to prevent it moving through walls, and to add gravity to it. The only thing we have to tell the animator is how the world looks like, how big the scene node is, how much gravity to apply and so on. After the collision response animator is attached to the camera, we do not have to do anything more for collision detection, anything is done automatically. The rest of the collision detection code below is for picking. And please note another cool feature: The collision response animator can be attached also to all other scene nodes, not only to cameras. And it can be mixed with other scene node animators. In this way, collision detection and response in the Irrlicht engine is really easy.<p>
Now we'll take a closer look on the parameters of createCollisionResponseAnimator(). The first parameter is the TriangleSelector, which specifies how the world, against collision detection is done looks like. The second parameter is the scene node, which is the object, which is affected by collision detection, in our case it is the camera. The third defines how big the object is, it is the radius of an ellipsoid. Try it out and change the radius to smaller values, the camera will be able to move closer to walls after this. The next parameter is the direction and speed of gravity. We'll set it to (0, -10, 0), which approximates to realistic gravity, assuming that our units are metres. You could set it to (0,0,0) to disable gravity. And the last value is just a translation: Without this, the ellipsoid with which collision detection is done would be around the camera, and the camera would be in the middle of the ellipsoid. But as human beings, we are used to have our eyes on top of the body, with which we collide with our world, not in the middle of it. So we place the scene node 50 units over the center of the ellipsoid with this parameter. And that's it, collision detection works now. <div class="fragment"><pre class="fragment">        <span class="comment">// Set a jump speed of 3 units per second, which gives a fairly realistic jump</span>
        <span class="comment">// when used with the gravity of (0, -10, 0) in the collision response animator.</span>
        scene::ICameraSceneNode* camera =
                smgr-&gt;addCameraSceneNodeFPS(0, 100.0f, .3f, ID_IsNotPickable, 0, 0, <span class="keyword">true</span>, 3.f);
        camera-&gt;setPosition(<a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(50,50,-60));
        camera-&gt;setTarget(<a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(-70,30,-60));

        <span class="keywordflow">if</span> (selector)
        {
                scene::ISceneNodeAnimator* anim = smgr-&gt;createCollisionResponseAnimator(
                        selector, camera, <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(30,50,30),
                        <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0,-10,0), <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0,30,0));
                selector-&gt;drop(); <span class="comment">// As soon as we're done with the selector, drop it.</span>
                camera-&gt;addAnimator(anim);
                anim-&gt;drop();  <span class="comment">// And likewise, drop the animator when we're done referring to it.</span>
        }

        <span class="comment">// Now I create three animated characters which we can pick, a dynamic light for</span>
        <span class="comment">// lighting them, and a billboard for drawing where we found an intersection.</span>

        <span class="comment">// First, let's get rid of the mouse cursor.  We'll use a billboard to show</span>
        <span class="comment">// what we're looking at.</span>
        device-&gt;getCursorControl()-&gt;setVisible(<span class="keyword">false</span>);

        <span class="comment">// Add the billboard.</span>
        scene::IBillboardSceneNode * bill = smgr-&gt;addBillboardSceneNode();
        bill-&gt;setMaterialType(<a class="code" href="namespaceirr_1_1video.html#c8e9b6c66f7cebabd1a6d30cbc5430f11b5a814c4466aca2943ff056003a50d1" title="A transparent material.">video::EMT_TRANSPARENT_ADD_COLOR</a> );
        bill-&gt;setMaterialTexture(0, driver-&gt;getTexture(<span class="stringliteral">"../../media/particle.bmp"</span>));
        bill-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#8a3bc00ae8137535b9fbc5f40add70d3cea597a2692b8415486a464a7f954d34" title="Will this material be lighted? Default: true.">video::EMF_LIGHTING</a>, <span class="keyword">false</span>);
        bill-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#8a3bc00ae8137535b9fbc5f40add70d3493bb44efafebb48adab96e31eb029e5" title="Is the ZBuffer enabled? Default: true.">video::EMF_ZBUFFER</a>, <span class="keyword">false</span>);
        bill-&gt;setSize(core::dimension2d&lt;f32&gt;(20.0f, 20.0f));
        bill-&gt;setID(ID_IsNotPickable); <span class="comment">// This ensures that we don't accidentally ray-pick it</span>
</pre></div> Add 3 animated hominids, which we can pick using a ray-triangle intersection. They all animate quite slowly, to make it easier to see that accurate triangle selection is being performed. <div class="fragment"><pre class="fragment">        scene::IAnimatedMeshSceneNode* node = 0;

        <span class="comment">// Add an MD2 node, which uses vertex-based animation.</span>
        node = smgr-&gt;addAnimatedMeshSceneNode(smgr-&gt;getMesh(<span class="stringliteral">"../../media/faerie.md2"</span>),
                                                0, IDFlag_IsPickable | IDFlag_IsHighlightable);
        node-&gt;setPosition(<a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(-70,-15,-120)); <span class="comment">// Put its feet on the floor.</span>
        node-&gt;setScale(<a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(2, 2, 2)); <span class="comment">// Make it appear realistically scaled</span>
        node-&gt;setMD2Animation(<a class="code" href="namespaceirr_1_1scene.html#08d4a84966e1d2886d0d57e4acbb4f19ac114a5c69f38d4f943145dd98929d95">scene::EMAT_POINT</a>);
        node-&gt;setAnimationSpeed(20.f);
        video::SMaterial material;
        material.setTexture(0, driver-&gt;getTexture(<span class="stringliteral">"../../media/faerie2.bmp"</span>));
        material.Lighting = <span class="keyword">true</span>;
        material.NormalizeNormals = <span class="keyword">true</span>;
        node-&gt;getMaterial(0) = material;

        <span class="comment">// Now create a triangle selector for it.  The selector will know that it</span>
        <span class="comment">// is associated with an animated node, and will update itself as necessary.</span>
        selector = smgr-&gt;createTriangleSelector(node);
        node-&gt;setTriangleSelector(selector);
        selector-&gt;drop(); <span class="comment">// We're done with this selector, so drop it now.</span>

        <span class="comment">// This X files uses skeletal animation, but without skinning.</span>
        node = smgr-&gt;addAnimatedMeshSceneNode(smgr-&gt;getMesh(<span class="stringliteral">"../../media/dwarf.x"</span>),
                                                0, IDFlag_IsPickable | IDFlag_IsHighlightable);
        node-&gt;setPosition(<a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(-70,-66,0)); <span class="comment">// Put its feet on the floor.</span>
        node-&gt;setRotation(<a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0,-90,0)); <span class="comment">// And turn it towards the camera.</span>
        node-&gt;setAnimationSpeed(20.f);
        selector = smgr-&gt;createTriangleSelector(node);
        node-&gt;setTriangleSelector(selector);
        selector-&gt;drop();

        <span class="comment">// And this B3D file uses skinned skeletal animation.</span>
        node = smgr-&gt;addAnimatedMeshSceneNode(smgr-&gt;getMesh(<span class="stringliteral">"../../media/ninja.b3d"</span>),
                                                0, IDFlag_IsPickable | IDFlag_IsHighlightable);
        node-&gt;setScale(<a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(10, 10, 10));
        node-&gt;setPosition(<a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(-70,-66,-60));
        node-&gt;setRotation(<a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0,90,0));
        node-&gt;setAnimationSpeed(10.f);
        node-&gt;getMaterial(0).NormalizeNormals = <span class="keyword">true</span>;
        <span class="comment">// Just do the same as we did above.</span>
        selector = smgr-&gt;createTriangleSelector(node);
        node-&gt;setTriangleSelector(selector);
        selector-&gt;drop();

        material.setTexture(0, 0);
        material.Lighting = <span class="keyword">false</span>;

        <span class="comment">// Add a light, so that the unselected nodes aren't completely dark.</span>
        scene::ILightSceneNode * light = smgr-&gt;addLightSceneNode(0, <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(-60,100,400),
                video::SColorf(1.0f,1.0f,1.0f,1.0f), 600.0f);
        light-&gt;setID(ID_IsNotPickable); <span class="comment">// Make it an invalid target for selection.</span>

        <span class="comment">// Remember which scene node is highlighted</span>
        scene::ISceneNode* highlightedSceneNode = 0;
        scene::ISceneCollisionManager* collMan = smgr-&gt;getSceneCollisionManager();
        <span class="keywordtype">int</span> lastFPS = -1;

        <span class="keywordflow">while</span>(device-&gt;run())
        <span class="keywordflow">if</span> (device-&gt;isWindowActive())
        {
                driver-&gt;beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, 0);
                smgr-&gt;drawAll();

                <span class="comment">// Unlight any currently highlighted scene node</span>
                <span class="keywordflow">if</span> (highlightedSceneNode)
                {
                        highlightedSceneNode-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#8a3bc00ae8137535b9fbc5f40add70d3cea597a2692b8415486a464a7f954d34" title="Will this material be lighted? Default: true.">video::EMF_LIGHTING</a>, <span class="keyword">true</span>);
                        highlightedSceneNode = 0;
                }

                <span class="comment">// All intersections in this example are done with a ray cast out from the camera to</span>
                <span class="comment">// a distance of 1000.  You can easily modify this to check (e.g.) a bullet</span>
                <span class="comment">// trajectory or a sword's position, or create a ray from a mouse click position using</span>
                <span class="comment">// ISceneCollisionManager::getRayFromScreenCoordinates()</span>
                core::line3d&lt;f32&gt; ray;
                ray.start = camera-&gt;getPosition();
                ray.end = ray.start + (camera-&gt;getTarget() - ray.start).normalize() * 1000.0f;

                <span class="comment">// Tracks the current intersection point with the level or a mesh</span>
                <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> intersection;
                <span class="comment">// Used to show with triangle has been hit</span>
                <a class="code" href="namespaceirr_1_1core.html#1112835405bbec5dadf031dc7934e7d0" title="Typedef for a f32 3d triangle.">core::triangle3df</a> hitTriangle;

                <span class="comment">// This call is all you need to perform ray/triangle collision on every scene node</span>
                <span class="comment">// that has a triangle selector, including the Quake level mesh.  It finds the nearest</span>
                <span class="comment">// collision point/triangle, and returns the scene node containing that point.</span>
                <span class="comment">// Irrlicht provides other types of selection, including ray/triangle selector,</span>
                <span class="comment">// ray/box and ellipse/triangle selector, plus associated helpers.</span>
                <span class="comment">// See the methods of ISceneCollisionManager</span>
                scene::ISceneNode * selectedSceneNode =
                        collMan-&gt;getSceneNodeAndCollisionPointFromRay(
                                        ray,
                                        intersection, <span class="comment">// This will be the position of the collision</span>
                                        hitTriangle, <span class="comment">// This will be the triangle hit in the collision</span>
                                        IDFlag_IsPickable, <span class="comment">// This ensures that only nodes that we have</span>
                                                        <span class="comment">// set up to be pickable are considered</span>
                                        0); <span class="comment">// Check the entire scene (this is actually the implicit default)</span>

                <span class="comment">// If the ray hit anything, move the billboard to the collision position</span>
                <span class="comment">// and draw the triangle that was hit.</span>
                <span class="keywordflow">if</span>(selectedSceneNode)
                {
                        bill-&gt;setPosition(intersection);

                        <span class="comment">// We need to reset the transform before doing our own rendering.</span>
                        driver-&gt;setTransform(<a class="code" href="namespaceirr_1_1video.html#15b57657a320243be03ae6f66fcff43d843cf42adb3fa9caf61c9e228cf14e85" title="World transformation.">video::ETS_WORLD</a>, <a class="code" href="namespaceirr_1_1core.html#73fa92e638c5ca97efd72da307cc9b65" title="Typedef for f32 matrix.">core::matrix4</a>());
                        driver-&gt;setMaterial(material);
                        driver-&gt;draw3DTriangle(hitTriangle, video::SColor(0,255,0,0));

                        <span class="comment">// We can check the flags for the scene node that was hit to see if it should be</span>
                        <span class="comment">// highlighted. The animated nodes can be highlighted, but not the Quake level mesh</span>
                        <span class="keywordflow">if</span>((selectedSceneNode-&gt;getID() &amp; IDFlag_IsHighlightable) == IDFlag_IsHighlightable)
                        {
                                highlightedSceneNode = selectedSceneNode;

                                <span class="comment">// Highlighting in this case means turning lighting OFF for this node,</span>
                                <span class="comment">// which means that it will be drawn with full brightness.</span>
                                highlightedSceneNode-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#8a3bc00ae8137535b9fbc5f40add70d3cea597a2692b8415486a464a7f954d34" title="Will this material be lighted? Default: true.">video::EMF_LIGHTING</a>, <span class="keyword">false</span>);
                        }
                }

                <span class="comment">// We're all done drawing, so end the scene.</span>
                driver-&gt;endScene();

                <span class="keywordtype">int</span> fps = driver-&gt;getFPS();

                <span class="keywordflow">if</span> (lastFPS != fps)
                {
                        <a class="code" href="namespaceirr_1_1core.html#ef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a> str = L<span class="stringliteral">"Collision detection example - Irrlicht Engine ["</span>;
                        str += driver-&gt;getName();
                        str += <span class="stringliteral">"] FPS:"</span>;
                        str += fps;

                        device-&gt;setWindowCaption(str.c_str());
                        lastFPS = fps;
                }
        }

        device-&gt;drop();

        <span class="keywordflow">return</span> 0;
}
</pre></div> </div>
<hr size="1">
<address style="align: right;">
<small> </small>
</address>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
  <tr> 
    <td width="0"> <div align="left"><small><a href="http://irrlicht.sourceforge.net" target="_blank"><img src="irrlicht.png" alt="The Irrlicht Engine" align="middle" border=0 width=88 height=31></a></small></div></td>
    <td> <div align="left"><small><em><font size="2">The <a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht 
        Engine</a> Documentation &copy; 2003-2009 by Nikolaus Gebhardt. Generated 
        on Sun Jan 10 09:24:06 2010 by <a href="http://www.doxygen.org" target="_blank">Doxygen</a> 
        (1.5.6)</font></em></small></div></td>
  </tr>
</table>
<address style="align: right;">
</address>
</body>
</html>