PathEngine home | previous: | next: |
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:
unique_ptr<iShape> agent_shape; unique_ptr<iShape> obstruction_shape1; unique_ptr<iShape> obstruction_shape2; { int32_t array[]= { 8,20, 20,8, 20,-8, 8,-20, -8,-20, -20,-8, -20,8, -8,20, }; agent_shape = pathengine->newShape(array, sizeof(array) / sizeof(*array)); } { int32_t array[]= { 30,30, 30,-30, -30,-30, -30,30, }; obstruction_shape1 = pathengine->newShape(array, sizeof(array) / sizeof(*array)); } { int32_t array[]= { 10,35, 20,-20, -10,-30, -15,32, }; obstruction_shape2 = pathengine->newShape(array, sizeof(array) / sizeof(*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 6.04 - Copyright © 2002-2024 PathEngine | next: |