Isle
Loading...
Searching...
No Matches
legonavcontroller.h
Go to the documentation of this file.
1#ifndef __LEGONAVCONTROLLER_H
2#define __LEGONAVCONTROLLER_H
3
4#include "decomp.h"
5#include "mxcore.h"
6#include "mxtypes.h"
7
8struct LegoLocation;
9class Vector3;
10
12//
13// LegoMouseController
14
15// VTABLE: LEGO1 0x100d85b8
16// VTABLE: BETA10 0x101bcc80
17// SIZE 0x70
18
23class LegoNavController : public MxCore {
24public:
29
33 ~LegoNavController() override;
34
40 MxLong Notify(MxParam& p_param) override; // vtable+0x04
41
46 const char* ClassName() const override // vtable+0x0c
47 {
48 // STRING: LEGO1 0x100f66d8
49 return "LegoNavController";
50 }
51
57 MxBool IsA(const char* p_name) const override // vtable+0x10
58 {
59 return !strcmp(p_name, ClassName()) || MxCore::IsA(p_name);
60 }
61
68 void SetTargets(int p_hPos, int p_vPos, MxBool p_accel);
69
75 void SetControlMax(int p_hMax, int p_vMax);
76
80 void SetToDefaultParams();
81
92 const Vector3& p_curPos,
93 const Vector3& p_curDir,
94 Vector3& p_newPos,
95 Vector3& p_newDir,
96 const Vector3* p_und
97 );
98
113 static void GetDefaults(
114 int* p_dz,
115 float* p_lv,
116 float* p_rv,
117 float* p_la,
118 float* p_ra,
119 float* p_ld,
120 float* p_rd,
121 float* p_lmina,
122 float* p_rmina,
123 float* p_rs,
124 MxBool* p_urs
125 );
126
141 static void SetDefaults(
142 int p_dz,
143 float p_lv,
144 float p_rv,
145 float p_la,
146 float p_ra,
147 float p_ld,
148 float p_rd,
149 float p_lmina,
150 float p_rmina,
151 float p_rs,
152 MxBool p_urs
153 );
154
160 static MxResult UpdateLocation(MxU32 p_location);
161
167 static MxResult UpdateLocation(const char* p_location);
168
173 static MxS32 GetNumLocations();
174
180 static LegoLocation* GetLocation(MxU32 p_location);
181
186 void SetLinearVel(MxFloat p_linearVel) { m_linearVel = p_linearVel; }
187
192 void SetDeadZone(MxS32 p_deadZone) { m_deadZone = p_deadZone; }
193
198 void SetTrackDefault(MxS32 p_trackDefault) { m_trackDefault = p_trackDefault; }
199
203 void Reset()
204 {
207 }
208
213
218
223
228
233
238 void ResetMaxLinearVel(MxFloat p_maxLinearVel)
239 {
240 m_maxLinearVel = p_maxLinearVel;
242 }
243
248 void ResetMaxLinearAccel(MxFloat p_maxLinearAccel)
249 {
250 m_maxLinearAccel = p_maxLinearAccel;
252 }
253
258 void ResetMaxLinearDeccel(MxFloat p_maxLinearDeccel)
259 {
260 m_maxLinearDeccel = p_maxLinearDeccel;
262 }
263
269
270 // SYNTHETIC: LEGO1 0x10054c10
271 // LegoNavController::`scalar deleting destructor'
272
273protected:
282 float CalculateNewVel(float p_targetVel, float p_currentVel, float p_accel, float p_time);
283
291 float CalculateNewTargetVel(int p_pos, int p_center, float p_max);
292
301 float CalculateNewAccel(int p_pos, int p_center, float p_max, int p_min);
302
309
315
319 int m_hMax; // 0x08
320
324 int m_vMax; // 0x0c
325
329 int m_deadZone; // 0x10
330
334 float m_zeroThreshold; // 0x14
335
339 float m_linearVel; // 0x18
340
344 float m_rotationalVel; // 0x1c
345
349 float m_targetLinearVel; // 0x20
350
355
359 float m_maxLinearVel; // 0x28
360
364 float m_maxRotationalVel; // 0x2c
365
369 float m_linearAccel; // 0x30
370
374 float m_rotationalAccel; // 0x34
375
379 float m_maxLinearAccel; // 0x38
380
384 float m_maxRotationalAccel; // 0x3c
385
389 float m_minLinearAccel; // 0x40
390
394 float m_minRotationalAccel; // 0x44
395
399 float m_maxLinearDeccel; // 0x48
400
405
409 float m_rotSensitivity; // 0x50
410
415
420
425
430
434 float m_unk0x60; // 0x60
435
439 float m_unk0x64; // 0x64
440
444 float m_unk0x68; // 0x68
445
450
451 // one copy of defaults (these can be set by App.)
455 static int g_defdeadZone;
456
460 static float g_defzeroThreshold;
461
465 static float g_defmaxLinearVel;
466
471
476
481
486
491
496
501
506
511};
512
513#endif // __LEGOPOVCONTROLLER_H
[AI] Handles user navigation input (keyboard and joystick) and determines avatar movement and directi...
int m_vMax
[AI] Current vertical axis control maximum (e.g., 480 for screen height).
float m_maxRotationalDeccel
[AI] Maximum allowed rotational deceleration.
MxResult ProcessJoystickInput(MxBool &p_und)
[AI] Processes current joystick/gamepad input and updates navigation targets and accelerations.
float m_maxLinearVel
[AI] Maximum allowed linear velocity.
void SetTargets(int p_hPos, int p_vPos, MxBool p_accel)
[AI] Set the horizontal/vertical target positions from input and optionally apply acceleration/dynami...
void ResetMaxLinearVel(MxFloat p_maxLinearVel)
[AI] Resets the maximum allowed linear velocity and marks controller as using custom parameters.
LegoNavController()
[AI] Constructs a navigation controller and registers it for input processing.
MxResult ProcessKeyboardInput()
[AI] Reads and processes keyboard navigation input to update velocity/acceleration targets.
void Reset()
[AI] Resets the internal navigation state and all navigation parameters to current defaults.
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.
static float g_defminLinearAccel
[AI] Application-global default min linear acceleration.
static MxS32 GetNumLocations()
[AI] Static: Retrieves the number of named locations registered in the navigation system.
float m_maxRotationalVel
[AI] Maximum allowed rotational velocity.
static LegoLocation * GetLocation(MxU32 p_location)
[AI] Static: Retrieves the pointer to a LegoLocation struct by its index.
float m_rotationalVel
[AI] Current rotational velocity.
const char * ClassName() const override
[AI] Returns this class's string name: "LegoNavController".
static float g_defminRotationalAccel
[AI] Application-global default min rotational acceleration.
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.
static float g_defmaxLinearDeccel
[AI] Application-global default max linear deceleration.
void ResetMaxLinearDeccel(MxFloat p_maxLinearDeccel)
[AI] Resets the maximum allowed linear deceleration and marks controller as using custom parameters.
void SetLinearVel(MxFloat p_linearVel)
[AI] Sets the current linear velocity for user navigation.
MxBool m_unk0x5d
[AI] Indicates that Notify() should inject a one-time movement/turn based on special debug or event t...
MxFloat GetMaxLinearVel()
[AI] Returns the current maximum linear velocity (units per sec).
static float g_defrotSensitivity
[AI] Application-global default rotation sensitivity.
static float g_defzeroThreshold
[AI] Application-global default zero threshold value.
MxBool m_useRotationalVel
[AI] If TRUE, rotation is determined by velocity (dynamic turning); if FALSE, snaps turn instantly.
static float g_defmaxRotationalVel
[AI] Application-global default max rotational velocity.
MxBool m_isAccelerating
[AI] TRUE if last input was an active movement/acceleration (vs.
void SetControlMax(int p_hMax, int p_vMax)
[AI] Set limits for horizontal and vertical input controls, typically reflecting window/screen size.
void SetDeadZone(MxS32 p_deadZone)
[AI] Sets the deadzone radius for input processing (region within which inputs are ignored).
float m_minRotationalAccel
[AI] Minimum allowed rotational acceleration.
void SetToDefaultParams()
[AI] Resets current navigation parameters to globally set defaults.
static float g_defmaxRotationalAccel
[AI] Application-global default max rotational acceleration.
float m_unk0x68
[AI] [Usage: debug/direct movement] Rotational offset (degrees), to next direction vector after Notif...
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,...
~LegoNavController() override
[AI] Destroys the controller and unregisters it from input processing.
float m_minLinearAccel
[AI] Minimum allowed linear acceleration.
float m_rotationalAccel
[AI] Current rotational acceleration used to interpolate rotational velocity.
static MxResult UpdateLocation(MxU32 p_location)
[AI] Static: Changes the current world/camera location to the specified index in the location registr...
MxBool m_trackDefault
[AI] TRUE if navigation parameters should match the application defaults; FALSE to allow per-instance...
float m_maxLinearDeccel
[AI] Maximum allowed linear deceleration (negative accel).
MxFloat GetMaxLinearAccel()
[AI] Returns the current maximum linear acceleration.
void SetTrackDefault(MxS32 p_trackDefault)
[AI] Marks the controller to track global/default navigation parameters rather than custom overrides.
float m_maxLinearAccel
[AI] Maximum allowed linear acceleration.
static float g_defmaxLinearVel
[AI] Application-global default max linear velocity.
static float g_defmaxRotationalDeccel
[AI] Application-global default max rotational deceleration.
int m_deadZone
[AI] Deadzone value; minimum distance input must be from axis center to register as movement.
float m_targetLinearVel
[AI] Target value for linear velocity, used for acceleration smoothing.
MxFloat GetMaxLinearDeccel()
[AI] Returns the current maximum linear deceleration.
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,...
static int g_defdeadZone
[AI] Application-global default deadzone value.
void ResetMaxLinearAccel(MxFloat p_maxLinearAccel)
[AI] Resets the maximum allowed linear acceleration and marks controller as using custom parameters.
float m_rotSensitivity
[AI] Sensitivity multiplier for rotation (applies if useRotationalVel is FALSE).
MxFloat GetRotationalVel()
[AI] Returns the current rotational velocity (degrees per sec).
MxTime m_lastTime
[AI] Tracks time of the last navigation tick for smooth movement with deltaTime.
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.
MxBool IsA(const char *p_name) const override
[AI] Tests if this object is of type "LegoNavController" or any MxCore ancestor.
int m_hMax
[AI] Current horizontal axis control maximum (e.g., 640 for screen width).
float m_unk0x64
[AI] [Usage: debug/direct movement] Linear velocity applied to next position after Notify key event.
int GetDefaultDeadZone()
[AI] Returns the application-global default deadzone value for navigation input processing.
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...
MxFloat GetLinearVel()
[AI] Returns the current linear velocity (units per sec).
float m_targetRotationalVel
[AI] Target value for rotational velocity, used for smoothing.
float m_maxRotationalAccel
[AI] Maximum allowed rotational acceleration.
float m_linearVel
[AI] Current linear velocity.
static float g_defmaxLinearAccel
[AI] Application-global default max linear acceleration.
float m_zeroThreshold
[AI] Threshold below which movements are considered negligible/zero.
MxLong Notify(MxParam &p_param) override
[AI] Responds to notifications, including keypresses and special debug shortcuts for avatar control,...
float m_unk0x60
[AI] [Usage: debug/direct movement] Y-offset applied to next position after Notify key event.
float m_linearAccel
[AI] Current linear acceleration used to interpolate linear velocity.
static MxBool g_defuseRotationalVel
[AI] Application-global default for useRotationalVel.
[AI] Base virtual class for all Mindscape engine (Mx) objects.
Definition: mxcore.h:15
virtual MxBool IsA(const char *p_name) const
[AI] Checks whether this object's class type or parents match the given name.
Definition: mxcore.h:46
[AI] MxParam serves as a polymorphic base class for parameter passing in event and notification syste...
Definition: mxparam.h:7
[AI] 3D vector class, providing vector and cross-product operations in 3D space.
Definition: vector.h:249
#define override
Definition: compat.h:21
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
int MxLong
[AI]
Definition: mxtypes.h:83
float MxFloat
[AI]
Definition: mxtypes.h:68
signed int MxS32
[AI]
Definition: mxtypes.h:38
MxS32 MxTime
[AI]
Definition: mxtypes.h:100
unsigned int MxU32
[AI]
Definition: mxtypes.h:32
Data structure representing a named spatial location and orientation in the LEGO Island world,...
Definition: legolocations.h:16