PathEngine home previous: Defining an entry pointnext: The update loop
Contents, Programmers Guide, Tutorials, A basic application, Loading a mesh

Loading a mesh

To avoid the need for platform specific code inside PathEngine data is loaded into memory buffers.
The testbed provides a function that does the platform specific job of loading that buffer from disk.

iMesh* mesh;
{
    char* buffer;
    tUnsigned32 size;
    buffer = testbed->loadBinary("..\\resource\\meshes\\mesh1.xml", size);
    mesh = pathengine->loadMeshFromBuffer("xml", buffer, size, 0);
    testbed->freeBuffer(buffer);
}

tUnsigned32 is a typedef supplied by PathEngine's API headers to enable 32 bit unsigned integers to be specified in a compiler independant manner.
Refer to this page for more information about PathEngine's integer typedefs.

iTestBed::loadBinary() simply loads a complete file into memory, allocating the buffer as required.
'size' is set to the size of the buffer created.
We then pass the resulting buffer and size into iPathEngine::loadMeshFromBuffer().

The first argument to loadMeshFromBuffer() specifies how PathEngine should interpret the buffer.
See XML Ground Meshes for details about XML meshes.

The last argument to loadMeshFromBuffer() enables a set of arbitrary attributes to be passed in to control aspects of the mesh loading process.
(Refer to Handling Attributes for details about this attribute passing mechanism.)
In this case we simply pass a null pointer to indicate no attributes, since we just want the default mesh loading behaviour.

Setting the current mesh for the testbed

The following code sets the testbed current mesh to the mesh we have just loaded.
iTestBed::zoomExtents() tells the testbed to set up the camera so that the mesh fits nicely in the view.

testbed->setMesh(mesh);
testbed->zoomExtents();

Documentation for PathEngine release 5.29 - Copyright © 2002-2012 PathEnginenext: The update loop