PathEngine home previous: Defining an entry pointnext: The update loop
Contents, Programmers Guide, Example Projects, 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;
    uint32_t size;
    buffer = testbed->loadBinary("..\\resource\\meshes\\mesh1.xml", size);
    mesh = pathengine->loadMeshFromBuffer("xml", buffer, size, 0);

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.


Documentation for PathEngine release 6.00 - Copyright © 2002-2016 PathEnginenext: The update loop