|PathEngine home||previous: ||next: |
Angles are not used extensively by PathEngine.
The PathEngine 'movement model' is based on agent translation and agents advance along path vectors without the need for an explicit orientation.
In some cases where PathEngine does represent orientation an integer angle representation is used.
This integer representation is based on 1048576 (2 to the power of 20) graduations.
When representing agent orientation a value of 0 indicates the agent facing along the positive y axis, 262144 indicates the agent facing along the positive x axis, 524288 indicates the agent facing along the negative y axis and angles increase to a value of 1048575 just before reaching 0.
The integer representation is used
in situations where it is important that
execution is deterministic.
Using integers ensures that the execution sequence is not affected by things like differences between the amount of processor internal precision on different platforms.
This value is fairly arbitrary, but is chosen so that angles can be converted to floats without loss of precision.
The following code snippet can be used for converting a vector to a PathEngine angle:
double orientationAtan2 = atan2(y, x); const double multiplier = 1048576.0f / 6.283185307f; int32_t orientationL = static_cast<int32_t>(orientationAtan2 * multiplier); int32_t orientationPathEngine = ((262144 - orientationL) & 1048575);
Code to convert from a PathEngine angle to a floating point representation in radians will look something like the following:
int32_t orientationL; cPosition p = mesh->retrieveAnchorWithOrientation(contentName.c_str(), orientationL); float orientation = static_cast<float>(orientationL); orientation *= 6.283185f; orientation /= 1048576;
|Documentation for PathEngine release 6.00 - Copyright © 2002-2016 PathEngine||next: |