Isle
|
[AI] Handles user navigation input (keyboard and joystick) and determines avatar movement and direction in the world. More...
#include <legonavcontroller.h>
Public Member Functions | |
LegoNavController () | |
[AI] Constructs a navigation controller and registers it for input processing. More... | |
~LegoNavController () override | |
[AI] Destroys the controller and unregisters it from input processing. More... | |
MxLong | Notify (MxParam &p_param) override |
[AI] Responds to notifications, including keypresses and special debug shortcuts for avatar control, animation, and world management. More... | |
const char * | ClassName () const override |
[AI] Returns this class's string name: "LegoNavController". More... | |
MxBool | IsA (const char *p_name) const override |
[AI] Tests if this object is of type "LegoNavController" or any MxCore ancestor. More... | |
void | SetTargets (int p_hPos, int p_vPos, MxBool p_accel) |
[AI] Set the horizontal/vertical target positions from input and optionally apply acceleration/dynamics. More... | |
void | SetControlMax (int p_hMax, int p_vMax) |
[AI] Set limits for horizontal and vertical input controls, typically reflecting window/screen size. More... | |
void | SetToDefaultParams () |
[AI] Resets current navigation parameters to globally set defaults. More... | |
MxBool | CalculateNewPosDir (const Vector3 &p_curPos, const Vector3 &p_curDir, Vector3 &p_newPos, Vector3 &p_newDir, const Vector3 *p_und) |
[AI] Calculates the new position and direction vectors based on input, current velocity, and elapsed time. More... | |
void | SetLinearVel (MxFloat p_linearVel) |
[AI] Sets the current linear velocity for user navigation. More... | |
void | SetDeadZone (MxS32 p_deadZone) |
[AI] Sets the deadzone radius for input processing (region within which inputs are ignored). More... | |
void | SetTrackDefault (MxS32 p_trackDefault) |
[AI] Marks the controller to track global/default navigation parameters rather than custom overrides. More... | |
void | Reset () |
[AI] Resets the internal navigation state and all navigation parameters to current defaults. More... | |
MxFloat | GetLinearVel () |
[AI] Returns the current linear velocity (units per sec). More... | |
MxFloat | GetRotationalVel () |
[AI] Returns the current rotational velocity (degrees per sec). More... | |
MxFloat | GetMaxLinearVel () |
[AI] Returns the current maximum linear velocity (units per sec). More... | |
MxFloat | GetMaxLinearAccel () |
[AI] Returns the current maximum linear acceleration. More... | |
MxFloat | GetMaxLinearDeccel () |
[AI] Returns the current maximum linear deceleration. More... | |
void | ResetMaxLinearVel (MxFloat p_maxLinearVel) |
[AI] Resets the maximum allowed linear velocity and marks controller as using custom parameters. More... | |
void | ResetMaxLinearAccel (MxFloat p_maxLinearAccel) |
[AI] Resets the maximum allowed linear acceleration and marks controller as using custom parameters. More... | |
void | ResetMaxLinearDeccel (MxFloat p_maxLinearDeccel) |
[AI] Resets the maximum allowed linear deceleration and marks controller as using custom parameters. More... | |
int | GetDefaultDeadZone () |
[AI] Returns the application-global default deadzone value for navigation input processing. More... | |
![]() | |
MxCore () | |
[AI] Constructs a new MxCore object and assigns it a unique id. More... | |
virtual | ~MxCore () |
[AI] Virtual destructor. Required for correct polymorphic cleanup in derived classes. More... | |
virtual MxLong | Notify (MxParam &p_param) |
[AI] Virtual callback notification mechanism. More... | |
virtual MxResult | Tickle () |
[AI] Called by tickle managers to allow the object to update itself. More... | |
virtual const char * | ClassName () const |
[AI] Returns the runtime class name of this object. More... | |
virtual MxBool | IsA (const char *p_name) const |
[AI] Checks whether this object's class type or parents match the given name. More... | |
MxU32 | GetId () |
[AI] Gets the unique (per-process) id assigned to this object instance. More... | |
Static Public Member Functions | |
static void | GetDefaults (int *p_dz, float *p_lv, float *p_rv, float *p_la, float *p_ra, float *p_ld, float *p_rd, float *p_lmina, float *p_rmina, float *p_rs, MxBool *p_urs) |
[AI] Static: Retrieves current global default navigation parameter values. More... | |
static void | SetDefaults (int p_dz, float p_lv, float p_rv, float p_la, float p_ra, float p_ld, float p_rd, float p_lmina, float p_rmina, float p_rs, MxBool p_urs) |
[AI] Static: Sets new global defaults for navigation parameters. More... | |
static MxResult | UpdateLocation (MxU32 p_location) |
[AI] Static: Changes the current world/camera location to the specified index in the location registry. More... | |
static MxResult | UpdateLocation (const char *p_location) |
[AI] Static: Sets the world/camera location to a location registered by name. More... | |
static MxS32 | GetNumLocations () |
[AI] Static: Retrieves the number of named locations registered in the navigation system. More... | |
static LegoLocation * | GetLocation (MxU32 p_location) |
[AI] Static: Retrieves the pointer to a LegoLocation struct by its index. More... | |
Protected Member Functions | |
float | CalculateNewVel (float p_targetVel, float p_currentVel, float p_accel, float p_time) |
[AI] Calculates the next velocity given a target velocity, current velocity, acceleration, and elapsed time, clamped as needed. More... | |
float | CalculateNewTargetVel (int p_pos, int p_center, float p_max) |
[AI] Translates control position into a new target velocity, applying deadzone and centering logic. More... | |
float | CalculateNewAccel (int p_pos, int p_center, float p_max, int p_min) |
[AI] Computes new acceleration value based on position, axis center, maximum and minimum acceleration. More... | |
MxResult | ProcessJoystickInput (MxBool &p_und) |
[AI] Processes current joystick/gamepad input and updates navigation targets and accelerations. More... | |
MxResult | ProcessKeyboardInput () |
[AI] Reads and processes keyboard navigation input to update velocity/acceleration targets. More... | |
Protected Attributes | |
int | m_hMax |
[AI] Current horizontal axis control maximum (e.g., 640 for screen width). More... | |
int | m_vMax |
[AI] Current vertical axis control maximum (e.g., 480 for screen height). More... | |
int | m_deadZone |
[AI] Deadzone value; minimum distance input must be from axis center to register as movement. More... | |
float | m_zeroThreshold |
[AI] Threshold below which movements are considered negligible/zero. More... | |
float | m_linearVel |
[AI] Current linear velocity. More... | |
float | m_rotationalVel |
[AI] Current rotational velocity. More... | |
float | m_targetLinearVel |
[AI] Target value for linear velocity, used for acceleration smoothing. More... | |
float | m_targetRotationalVel |
[AI] Target value for rotational velocity, used for smoothing. More... | |
float | m_maxLinearVel |
[AI] Maximum allowed linear velocity. More... | |
float | m_maxRotationalVel |
[AI] Maximum allowed rotational velocity. More... | |
float | m_linearAccel |
[AI] Current linear acceleration used to interpolate linear velocity. More... | |
float | m_rotationalAccel |
[AI] Current rotational acceleration used to interpolate rotational velocity. More... | |
float | m_maxLinearAccel |
[AI] Maximum allowed linear acceleration. More... | |
float | m_maxRotationalAccel |
[AI] Maximum allowed rotational acceleration. More... | |
float | m_minLinearAccel |
[AI] Minimum allowed linear acceleration. More... | |
float | m_minRotationalAccel |
[AI] Minimum allowed rotational acceleration. More... | |
float | m_maxLinearDeccel |
[AI] Maximum allowed linear deceleration (negative accel). More... | |
float | m_maxRotationalDeccel |
[AI] Maximum allowed rotational deceleration. More... | |
float | m_rotSensitivity |
[AI] Sensitivity multiplier for rotation (applies if useRotationalVel is FALSE). More... | |
MxBool | m_useRotationalVel |
[AI] If TRUE, rotation is determined by velocity (dynamic turning); if FALSE, snaps turn instantly. More... | |
MxTime | m_lastTime |
[AI] Tracks time of the last navigation tick for smooth movement with deltaTime. More... | |
MxBool | m_trackDefault |
[AI] TRUE if navigation parameters should match the application defaults; FALSE to allow per-instance override. More... | |
MxBool | m_unk0x5d |
[AI] Indicates that Notify() should inject a one-time movement/turn based on special debug or event triggers. More... | |
float | m_unk0x60 |
[AI] [Usage: debug/direct movement] Y-offset applied to next position after Notify key event. More... | |
float | m_unk0x64 |
[AI] [Usage: debug/direct movement] Linear velocity applied to next position after Notify key event. More... | |
float | m_unk0x68 |
[AI] [Usage: debug/direct movement] Rotational offset (degrees), to next direction vector after Notify event. More... | |
MxBool | m_isAccelerating |
[AI] TRUE if last input was an active movement/acceleration (vs. More... | |
Static Protected Attributes | |
static int | g_defdeadZone = 40 |
[AI] Application-global default deadzone value. More... | |
static float | g_defzeroThreshold = 0.001f |
[AI] Application-global default zero threshold value. More... | |
static float | g_defmaxLinearVel = 40.0f |
[AI] Application-global default max linear velocity. More... | |
static float | g_defmaxRotationalVel = 20.0f |
[AI] Application-global default max rotational velocity. More... | |
static float | g_defmaxLinearAccel = 15.0f |
[AI] Application-global default max linear acceleration. More... | |
static float | g_defmaxRotationalAccel = 30.0f |
[AI] Application-global default max rotational acceleration. More... | |
static float | g_defminLinearAccel = 4.0f |
[AI] Application-global default min linear acceleration. More... | |
static float | g_defminRotationalAccel = 15.0f |
[AI] Application-global default min rotational acceleration. More... | |
static float | g_defmaxLinearDeccel = 50.0f |
[AI] Application-global default max linear deceleration. More... | |
static float | g_defmaxRotationalDeccel = 50.0f |
[AI] Application-global default max rotational deceleration. More... | |
static float | g_defrotSensitivity = 0.4f |
[AI] Application-global default rotation sensitivity. More... | |
static MxBool | g_defuseRotationalVel = FALSE |
[AI] Application-global default for useRotationalVel. More... | |
[AI] Handles user navigation input (keyboard and joystick) and determines avatar movement and direction in the world.
It encapsulates logic for target position/velocity setting, acceleration/deceleration, and navigation parameter defaults for LEGO Island's 3D world.
[AI] LegoNavController centralizes the logic for player-controlled navigation within the LEGO Island engine. It interprets user input (both keyboard and joystick), manages transitions between velocity/acceleration targets, and integrates movement into the engine's control loop. It provides interfaces for updating viewpoints to named "locations" and allows application-based adjustment of navigation dynamics (accel/decel/sensitivity/deadzone).
Definition at line 23 of file legonavcontroller.h.
LegoNavController::LegoNavController | ( | ) |
[AI] Constructs a navigation controller and registers it for input processing.
Definition at line 126 of file legonavcontroller.cpp.
|
override |
[AI] Destroys the controller and unregisters it from input processing.
Definition at line 149 of file legonavcontroller.cpp.
|
protected |
[AI] Computes new acceleration value based on position, axis center, maximum and minimum acceleration.
p_pos | Input axis position. [AI] |
p_center | Center value of the axis. [AI] |
p_max | Maximum allowed acceleration. [AI] |
p_min | Minimum allowed acceleration. [AI] |
Definition at line 281 of file legonavcontroller.cpp.
MxBool LegoNavController::CalculateNewPosDir | ( | const Vector3 & | p_curPos, |
const Vector3 & | p_curDir, | ||
Vector3 & | p_newPos, | ||
Vector3 & | p_newDir, | ||
const Vector3 * | p_und | ||
) |
[AI] Calculates the new position and direction vectors based on input, current velocity, and elapsed time.
p_curPos | Current position in world coordinates. [AI] |
p_curDir | Current view or movement direction. [AI] |
p_newPos | [out] Populated with computed new position vector. [AI] |
p_newDir | [out] Populated with computed new direction vector. [AI] |
p_und | Optional pointer to up-direction vector; affects calculation for inverse navigation/rotation direction. [AI] |
Definition at line 320 of file legonavcontroller.cpp.
|
protected |
[AI] Translates control position into a new target velocity, applying deadzone and centering logic.
p_pos | Current axis position (input region, e.g., mouse/joystick). [AI] |
p_center | Center value of the axis. [AI] |
p_max | Maximum allowed velocity for this axis. [AI] |
Definition at line 262 of file legonavcontroller.cpp.
|
protected |
[AI] Calculates the next velocity given a target velocity, current velocity, acceleration, and elapsed time, clamped as needed.
p_targetVel | The target velocity to approach. [AI] |
p_currentVel | The current velocity. [AI] |
p_accel | The acceleration to use. [AI] |
p_time | Time elapsed since last calculation (seconds). [AI] |
Definition at line 296 of file legonavcontroller.cpp.
|
inlineoverridevirtual |
[AI] Returns this class's string name: "LegoNavController".
Reimplemented from MxCore.
Definition at line 46 of file legonavcontroller.h.
|
inline |
[AI] Returns the application-global default deadzone value for navigation input processing.
Definition at line 268 of file legonavcontroller.h.
|
static |
[AI] Static: Retrieves current global default navigation parameter values.
p_dz | [out] Deadzone threshold. [AI] |
p_lv | [out] Maximum linear velocity. [AI] |
p_rv | [out] Maximum rotational velocity. [AI] |
p_la | [out] Maximum linear acceleration. [AI] |
p_ra | [out] Maximum rotational acceleration. [AI] |
p_ld | [out] Maximum linear deceleration. [AI] |
p_rd | [out] Maximum rotational deceleration. [AI] |
p_lmina | [out] Minimum linear acceleration. [AI] |
p_rmina | [out] Minimum rotational acceleration. [AI] |
p_rs | [out] Rotation sensitivity. [AI] |
p_urs | [out] Use rotational velocity flag. [AI] |
Definition at line 185 of file legonavcontroller.cpp.
|
inline |
[AI] Returns the current linear velocity (units per sec).
Definition at line 212 of file legonavcontroller.h.
|
static |
[AI] Static: Retrieves the pointer to a LegoLocation struct by its index.
p_location | Index into the global location array. [AI] |
Definition at line 502 of file legonavcontroller.cpp.
|
inline |
[AI] Returns the current maximum linear acceleration.
Definition at line 227 of file legonavcontroller.h.
|
inline |
[AI] Returns the current maximum linear deceleration.
Definition at line 232 of file legonavcontroller.h.
|
inline |
[AI] Returns the current maximum linear velocity (units per sec).
Definition at line 222 of file legonavcontroller.h.
|
static |
[AI] Static: Retrieves the number of named locations registered in the navigation system.
Definition at line 512 of file legonavcontroller.cpp.
|
inline |
[AI] Returns the current rotational velocity (degrees per sec).
Definition at line 217 of file legonavcontroller.h.
|
inlineoverridevirtual |
[AI] Tests if this object is of type "LegoNavController" or any MxCore ancestor.
p_name | Class or ancestor class name to test. [AI] |
Reimplemented from MxCore.
Definition at line 57 of file legonavcontroller.h.
[AI] Responds to notifications, including keypresses and special debug shortcuts for avatar control, animation, and world management.
p_param | Notification or event parameter, often a keypress or controller event. [AI] |
Reimplemented from MxCore.
Definition at line 648 of file legonavcontroller.cpp.
[AI] Processes current joystick/gamepad input and updates navigation targets and accelerations.
p_und | [out] Set TRUE if the joystick POV control resulted in freeview rotation (e.g., camera rotation from D-pad hatswitch). [AI] |
Definition at line 518 of file legonavcontroller.cpp.
|
protected |
[AI] Reads and processes keyboard navigation input to update velocity/acceleration targets.
Definition at line 565 of file legonavcontroller.cpp.
|
inline |
[AI] Resets the internal navigation state and all navigation parameters to current defaults.
Definition at line 203 of file legonavcontroller.h.
|
inline |
[AI] Resets the maximum allowed linear acceleration and marks controller as using custom parameters.
p_maxLinearAccel | New value for maximum linear acceleration. [AI] |
Definition at line 248 of file legonavcontroller.h.
|
inline |
[AI] Resets the maximum allowed linear deceleration and marks controller as using custom parameters.
p_maxLinearDeccel | New value for maximum linear deceleration. [AI] |
Definition at line 258 of file legonavcontroller.h.
|
inline |
[AI] Resets the maximum allowed linear velocity and marks controller as using custom parameters.
p_maxLinearVel | New value for maximum linear velocity. [AI] |
Definition at line 238 of file legonavcontroller.h.
void LegoNavController::SetControlMax | ( | int | p_hMax, |
int | p_vMax | ||
) |
[AI] Set limits for horizontal and vertical input controls, typically reflecting window/screen size.
p_hMax | Maximum horizontal value (e.g., 640 for fullscreen). [AI] |
p_vMax | Maximum vertical value (e.g., 480 for fullscreen). [AI] |
Definition at line 155 of file legonavcontroller.cpp.
|
inline |
[AI] Sets the deadzone radius for input processing (region within which inputs are ignored).
p_deadZone | Deadzone value in input units. [AI] |
Definition at line 192 of file legonavcontroller.h.
|
static |
[AI] Static: Sets new global defaults for navigation parameters.
p_dz | Deadzone threshold. [AI] |
p_lv | Maximum linear velocity. [AI] |
p_rv | Maximum rotational velocity. [AI] |
p_la | Maximum linear acceleration. [AI] |
p_ra | Maximum rotational acceleration. [AI] |
p_ld | Maximum linear deceleration. [AI] |
p_rd | Maximum rotational deceleration. [AI] |
p_lmina | Minimum linear acceleration. [AI] |
p_rmina | Minimum rotational acceleration. [AI] |
p_rs | Rotation sensitivity. [AI] |
p_urs | Use rotational velocity flag. [AI] |
Definition at line 213 of file legonavcontroller.cpp.
|
inline |
[AI] Sets the current linear velocity for user navigation.
p_linearVel | New linear velocity value. [AI] |
Definition at line 186 of file legonavcontroller.h.
void LegoNavController::SetTargets | ( | int | p_hPos, |
int | p_vPos, | ||
MxBool | p_accel | ||
) |
[AI] Set the horizontal/vertical target positions from input and optionally apply acceleration/dynamics.
p_hPos | Target X/horizontal position (e.g., joystick, mouse, etc). [AI] |
p_vPos | Target Y/vertical position (e.g., joystick, mouse, etc). [AI] |
p_accel | If TRUE, use acceleration (smooth ramping) toward target, otherwise jumps directly. [AI] |
Definition at line 241 of file legonavcontroller.cpp.
void LegoNavController::SetToDefaultParams | ( | ) |
[AI] Resets current navigation parameters to globally set defaults.
Definition at line 168 of file legonavcontroller.cpp.
|
inline |
[AI] Marks the controller to track global/default navigation parameters rather than custom overrides.
p_trackDefault | If TRUE, controller tracks default params. [AI] |
Definition at line 198 of file legonavcontroller.h.
|
static |
[AI] Static: Sets the world/camera location to a location registered by name.
p_location | Name string as registered in LegoLocation. [AI] |
Definition at line 431 of file legonavcontroller.cpp.
[AI] Static: Changes the current world/camera location to the specified index in the location registry.
p_location | Index into the known locations array. [AI] |
Definition at line 465 of file legonavcontroller.cpp.
|
staticprotected |
[AI] Application-global default deadzone value.
Definition at line 455 of file legonavcontroller.h.
|
staticprotected |
[AI] Application-global default max linear acceleration.
Definition at line 475 of file legonavcontroller.h.
|
staticprotected |
[AI] Application-global default max linear deceleration.
Definition at line 495 of file legonavcontroller.h.
|
staticprotected |
[AI] Application-global default max linear velocity.
Definition at line 465 of file legonavcontroller.h.
|
staticprotected |
[AI] Application-global default max rotational acceleration.
Definition at line 480 of file legonavcontroller.h.
|
staticprotected |
[AI] Application-global default max rotational deceleration.
Definition at line 500 of file legonavcontroller.h.
|
staticprotected |
[AI] Application-global default max rotational velocity.
Definition at line 470 of file legonavcontroller.h.
|
staticprotected |
[AI] Application-global default min linear acceleration.
Definition at line 485 of file legonavcontroller.h.
|
staticprotected |
[AI] Application-global default min rotational acceleration.
Definition at line 490 of file legonavcontroller.h.
|
staticprotected |
[AI] Application-global default rotation sensitivity.
Definition at line 505 of file legonavcontroller.h.
[AI] Application-global default for useRotationalVel.
Definition at line 510 of file legonavcontroller.h.
|
staticprotected |
[AI] Application-global default zero threshold value.
Definition at line 460 of file legonavcontroller.h.
|
protected |
[AI] Deadzone value; minimum distance input must be from axis center to register as movement.
Definition at line 329 of file legonavcontroller.h.
|
protected |
[AI] Current horizontal axis control maximum (e.g., 640 for screen width).
Definition at line 319 of file legonavcontroller.h.
|
protected |
[AI] TRUE if last input was an active movement/acceleration (vs.
at rest).
Definition at line 449 of file legonavcontroller.h.
|
protected |
[AI] Tracks time of the last navigation tick for smooth movement with deltaTime.
Definition at line 419 of file legonavcontroller.h.
|
protected |
[AI] Current linear acceleration used to interpolate linear velocity.
Definition at line 369 of file legonavcontroller.h.
|
protected |
[AI] Current linear velocity.
Definition at line 339 of file legonavcontroller.h.
|
protected |
[AI] Maximum allowed linear acceleration.
Definition at line 379 of file legonavcontroller.h.
|
protected |
[AI] Maximum allowed linear deceleration (negative accel).
Definition at line 399 of file legonavcontroller.h.
|
protected |
[AI] Maximum allowed linear velocity.
Definition at line 359 of file legonavcontroller.h.
|
protected |
[AI] Maximum allowed rotational acceleration.
Definition at line 384 of file legonavcontroller.h.
|
protected |
[AI] Maximum allowed rotational deceleration.
Definition at line 404 of file legonavcontroller.h.
|
protected |
[AI] Maximum allowed rotational velocity.
Definition at line 364 of file legonavcontroller.h.
|
protected |
[AI] Minimum allowed linear acceleration.
Definition at line 389 of file legonavcontroller.h.
|
protected |
[AI] Minimum allowed rotational acceleration.
Definition at line 394 of file legonavcontroller.h.
|
protected |
[AI] Current rotational acceleration used to interpolate rotational velocity.
Definition at line 374 of file legonavcontroller.h.
|
protected |
[AI] Current rotational velocity.
Definition at line 344 of file legonavcontroller.h.
|
protected |
[AI] Sensitivity multiplier for rotation (applies if useRotationalVel is FALSE).
Definition at line 409 of file legonavcontroller.h.
|
protected |
[AI] Target value for linear velocity, used for acceleration smoothing.
Definition at line 349 of file legonavcontroller.h.
|
protected |
[AI] Target value for rotational velocity, used for smoothing.
Definition at line 354 of file legonavcontroller.h.
|
protected |
[AI] TRUE if navigation parameters should match the application defaults; FALSE to allow per-instance override.
Definition at line 424 of file legonavcontroller.h.
|
protected |
[AI] Indicates that Notify() should inject a one-time movement/turn based on special debug or event triggers.
Definition at line 429 of file legonavcontroller.h.
|
protected |
[AI] [Usage: debug/direct movement] Y-offset applied to next position after Notify key event.
Definition at line 434 of file legonavcontroller.h.
|
protected |
[AI] [Usage: debug/direct movement] Linear velocity applied to next position after Notify key event.
Definition at line 439 of file legonavcontroller.h.
|
protected |
[AI] [Usage: debug/direct movement] Rotational offset (degrees), to next direction vector after Notify event.
Definition at line 444 of file legonavcontroller.h.
|
protected |
[AI] If TRUE, rotation is determined by velocity (dynamic turning); if FALSE, snaps turn instantly.
Definition at line 414 of file legonavcontroller.h.
|
protected |
[AI] Current vertical axis control maximum (e.g., 480 for screen height).
Definition at line 324 of file legonavcontroller.h.
|
protected |
[AI] Threshold below which movements are considered negligible/zero.
Definition at line 334 of file legonavcontroller.h.