PathEngine home previous: Parameter Type Mappingsnext: Java Native Interface
Contents, Programmers Guide, Using PathEngine with Other Languages, Microsoft CLR, Running the Examples

Running the Examples

Example applications

Two console applications examples are provided, 'QuickStart' and 'LinkageDetails'.

The QuickStart application shows you how to get up and running with in CLR languages with the most commonly used API calls for loading a ground mesh and performing some pathfinding.

The LinkageDetails application is then designed to demonstrate some detail issues relating to the CLR language mapping (such as error handling, interface object comparison, and lifetime management), and also demonstrates how to set up an callback class implementation. (A SquareMesh class deriving from the iFaceVertexMesh callback interface is shown, and used with the PathEngine content processing method, to generate a ground mesh programmatically.)

Both Visual Basic and C# code is provided for each example applications, and this can be found in 'SDKRoot/samples/Interop'.

Setting up projects

Visual Studio project configuration files are not currently provided for the example applications (which avoids complicating the PathEngine release process with Visual Studio versioning issues), but it's pretty straightforward to create the relevant projects in Visual Studio based on standard project templates. (The steps described on this page are based on Visual Studio 2019, but it should be easy to adapt these steps, if necessary, for other Visual Studio versions.)

Console application project setup for C#

Create a new project with the 'Console Application' template, for language C#, platform Windows. (Certain Visual Studio installation components such as .NET development may need to be present in order for this to be available.) Go into the project properties.

Change the 'Platform target' (under 'Build') to x86. (This needs to match the C++/CLR wrapper project's target architecture. Both projects can also be set to x64 if required.)

Remove the 'Program.cs' source code item added by the project template, add the relevant example code file from 'SDKRoot/samples/Interop', instead.

Add a reference to the C++/CLR wrapper class library project (created here), from this new project.

You should now be able to build the project.

Set the project working directory to 'SDKRoot/bin'. You will also need to copy the PathEngine dll into this directory before running.

Console application project setup for Visual Basic

Create a new project with the 'Console Application' template, for language Visual Basic, platform Windows. (Certain Visual Studio installation components such as .NET development may need to be present in order for this to be available.) Go into the project properties.

Change the 'Target CPU' (under 'Compile') to x86. (This needs to match the C++/CLR wrapper project's target architecture. Both projects can also be set to x64 if required.)

Remove the 'Module1.vb' source code item added by the project template, add the relevant example code file from 'SDKRoot/samples/Interop', instead.

Add a reference to the C++/CLR wrapper class library project (created here), from this new project.

You should now be able to build the project.

Set the project working directory to 'SDKRoot/bin'. You will also need to copy the PathEngine dll into this directory (if not already there), before running.

Expected output

When you run the QuickStart project, you should see something like the following:

start: 56:1070,270
goal: 0:630,491
Path found with 4 points:
56:1070,270
15:977,270
62:785,377
0:630,491
(completed, press enter)
        

Check the example project source code and comments for more details!


Documentation for PathEngine release 6.04 - Copyright © 2002-2024 PathEnginenext: Java Native Interface