PathEngine home previous: Tutorial 1next: Generating shape preprocess
Contents, Programmers Guide, Tutorials, Tutorial 1, Shape creation

Shape creation

iShape objects store a 2d polygon and are used to represent the shape of an agent or a moveable obstruction for the purposes of PathEngine collision.

The following code (in main.cpp) is used to create three iShape objects:

iShape* agent_shape;
iShape* obstruction_shape1;
iShape* obstruction_shape2;
{
	tSigned32 array[]=
	{
		8,20,
		20,8,
		20,-8,
		8,-20,
		-8,-20,
		-20,-8,
		-20,8,
		-8,20,
	};
	agent_shape = pathengine->newShape(sizeof(array)/sizeof(*array)/2, array);
}
{
	tSigned32 array[]=
	{
		30,30,
		30,-30,
		-30,-30,
		-30,30,
	};
	obstruction_shape1 = pathengine->newShape(sizeof(array)/sizeof(*array)/2, array);
}
{
	tSigned32 array[]=
	{
		10,35,
		20,-20,
		-10,-30,
		-15,32,
	};
	obstruction_shape2 = pathengine->newShape(sizeof(array)/sizeof(*array)/2, array);
}

This is what agents created with these shapes might look like rendered in the testbed:

The agent shape is a regular octagon.
The obstruction 1 shape is an axis aligned square.
The obstruction 2 shape is an irregular quadrilateral.

Note: Agents that can rotate will need to be approximated by regular polygon. Irregular shapes should only be used for agent that do not rotate.


Documentation for PathEngine release 5.17 - Copyright © 2002-2008 PathEnginenext: Generating shape preprocess