Isle
Loading...
Searching...
No Matches
legopovcontroller.cpp
Go to the documentation of this file.
2#include "legoentity.h"
3#include "legomain.h"
4#include "legonavcontroller.h"
6#include "legosoundmanager.h"
7#include "misc.h"
8#include "mxmisc.h"
9#include "mxticklemanager.h"
10#include "mxtimer.h"
11#include "realtime/realtime.h"
12#include "roi/legoroi.h"
13
16
17// GLOBAL: LEGO1 0x100f75ac
19
21
22// FUNCTION: LEGO1 0x10065550
24{
25 m_isButtonDown = FALSE;
26}
27
28// FUNCTION: LEGO1 0x100655d0
30{
31}
32
33// FUNCTION: LEGO1 0x10065620
34void LegoMouseController::LeftDown(int p_x, int p_y)
35{
36 m_isButtonDown = TRUE;
37 m_buttonX = p_x;
38 m_buttonY = p_y;
39}
40
41// FUNCTION: LEGO1 0x10065640
42void LegoMouseController::LeftUp(int p_x, int p_y)
43{
44 m_isButtonDown = FALSE;
45 m_buttonX = p_x;
46 m_buttonY = p_y;
47}
48
49// FUNCTION: LEGO1 0x10065660
50void LegoMouseController::LeftDrag(int p_x, int p_y)
51{
52 m_buttonX = p_x;
53 m_buttonY = p_y;
54}
55
56// FUNCTION: LEGO1 0x10065680
57void LegoMouseController::RightDown(int p_x, int p_y)
58{
59 m_isButtonDown = TRUE;
60 m_buttonX = p_x;
61 m_buttonY = p_y;
62}
63
64// FUNCTION: LEGO1 0x100656a0
65void LegoMouseController::RightUp(int p_x, int p_y)
66{
67 m_isButtonDown = FALSE;
68 m_buttonX = p_x;
69 m_buttonY = p_y;
70}
71
72// FUNCTION: LEGO1 0x100656c0
73void LegoMouseController::RightDrag(int p_x, int p_y)
74{
75 m_buttonX = p_x;
76 m_buttonY = p_y;
77}
78
80
81// FUNCTION: LEGO1 0x100656e0
83{
85 m_entity = NULL;
86 m_nav = NULL;
87 // m_entityOffsetUp is a temporary kludge. It should be replaced
88 // by 3D camera offset and position stored in the entity since each
89 // entity may have a different best viewpoint.
90 m_entityOffsetUp = 0.0;
91}
92
93// FUNCTION: LEGO1 0x10065770
95{
97 if (m_nav) {
98 delete m_nav;
99 m_nav = NULL;
100 }
101}
102
103// FUNCTION: LEGO1 0x100657f0
105{
106 m_lego3DView = p_lego3DView;
107 m_nav = new LegoNavController();
110 TickleManager()->RegisterClient(this, 10);
111 return SUCCESS;
112}
113
114// FUNCTION: LEGO1 0x100658a0
115void LegoPointOfViewController::OnViewSize(int p_width, int p_height)
116{
117 m_nav->SetControlMax(p_width, p_height);
118}
119
120// FUNCTION: LEGO1 0x100658c0
122{
125}
126
127// FUNCTION: LEGO1 0x100658e0
129{
132}
133
134// FUNCTION: LEGO1 0x10065900
136{
138}
139
140// FUNCTION: LEGO1 0x10065930
141// FUNCTION: BETA10 0x100c724d
143{
145
146 if (pov != NULL && m_nav != NULL && m_entity == NULL) {
147 Mx3DPointFloat newDir, newPos;
148
149 Vector3 pos(pov->GetWorldPosition());
150 Vector3 dir(pov->GetWorldDirection());
151
152 if (m_nav->CalculateNewPosDir(pos, dir, newPos, newDir, NULL)) {
153 MxMatrix mat;
154
155 CalcLocalTransform(newPos, newDir, pov->GetWorldUp(), mat);
156 ((TimeROI*) pov)->FUN_100a9b40(mat, Timer()->GetTime());
157 pov->WrappedSetLocalTransform(mat);
158 m_lego3DView->Moved(*pov);
159
161 pov->GetWorldPosition(),
162 pov->GetWorldDirection(),
163 pov->GetWorldUp(),
164 pov->GetWorldVelocity()
165 );
166
168 }
169 else {
170 if (g_unk0x100f75ac == FALSE) {
171 Mx3DPointFloat vel;
172
173 vel.Clear();
174 pov->FUN_100a5a30(vel);
175
177 pov->GetWorldPosition(),
178 pov->GetWorldDirection(),
179 pov->GetWorldUp(),
180 pov->GetWorldVelocity()
181 );
182
184 }
185 }
186 }
187
188 return SUCCESS;
189}
190
191// FUNCTION: LEGO1 0x10065ae0
193{
195 m_entity = p_entity;
196
198
199 if (m_entity != NULL && pov != NULL) {
200 MxMatrix mat;
201
207 ),
210 mat
211 );
212
213 pov->WrappedSetLocalTransform(mat);
214 }
215 else {
216 TickleManager()->RegisterClient(this, 10);
217 }
218}
[AI] Represents a 3D view for rendering and managing LEGO game objects in a 3D scene.
Definition: lego3dview.h:20
ViewROI * GetPointOfView()
[AI] Returns the current point-of-view object (the ViewROI the camera is following).
Definition: lego3dview.h:162
BOOL Moved(ViewROI &rROI)
[AI] Notifies the view that a ViewROI has moved.
Definition: lego3dview.cpp:126
[AI] Represents an entity that can be placed and managed in the LEGO Island world.
Definition: legoentity.h:16
Mx3DPointFloat GetWorldDirection()
[AI] Gets the normalized world-space direction vector, optionally updating from ROI....
Definition: legoentity.cpp:202
Mx3DPointFloat GetWorldUp()
[AI] Gets the normalized world-space up vector, optionally updating from ROI. [AI]
Definition: legoentity.cpp:213
Mx3DPointFloat GetWorldPosition()
[AI] Gets the world-space position vector, optionally updating from ROI. [AI]
Definition: legoentity.cpp:224
[AI] Handles mouse input relevant to camera or entity control.
virtual void RightUp(int, int)
[AI] Invoked when the right mouse button is released.
MxDouble GetButtonY()
[AI] Returns the Y coordinate where the last mouse button event occurred.
virtual void LeftUp(int, int)
[AI] Invoked when the left mouse button is released.
virtual void LeftDrag(int, int)
[AI] Invoked as the mouse drags while the left button is held.
BOOL GetIsButtonDown()
[AI] Returns whether any mouse button is currently in the 'down' state.
virtual void RightDrag(int, int)
[AI] Invoked as the mouse drags while the right button is held.
virtual void RightDown(int, int)
[AI] Invoked when the right mouse button is pressed.
virtual void LeftDown(int, int)
[AI] Invoked when the left mouse button is pressed.
MxDouble GetButtonX()
[AI] Returns the X coordinate where the last mouse button event occurred.
~LegoMouseController() override
[AI] Destructor for mouse controller. [AI]
[AI] Handles user navigation input (keyboard and joystick) and determines avatar movement and directi...
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 SetControlMax(int p_hMax, int p_vMax)
[AI] Set limits for horizontal and vertical input controls, typically reflecting window/screen size.
void SetTrackDefault(MxS32 p_trackDefault)
[AI] Marks the controller to track global/default navigation parameters rather than custom overrides.
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,...
void SetNavController(LegoNavController *p_navController)
[AI] Sets the navigation controller.
Definition: legomain.h:443
static LegoOmni * GetInstance()
[AI] Returns the current LegoOmni singleton pointer, cast from MxOmni.
Definition: legomain.cpp:305
[AI] Controller that links mouse actions to manipulation of the user's point of view in the 3D scene.
virtual void SetEntity(LegoEntity *p_entity)
[AI] Assign the entity which this controller operates on, typically to associate the point of view wi...
LegoPointOfViewController()
[AI] Initializes state for coordinating mouse and point-of-view. [AI]
~LegoPointOfViewController() override
[AI] Destructor; cleans up any owned references. [AI]
void LeftDrag(int p_x, int p_y) override
[AI] Called when cursor moves with left mouse button held; typically drags the point of view.
LegoNavController * m_nav
[AI] Navigation controller used to translate input to navigation/camera changes. [AI]
LegoEntity * m_entity
[AI] The entity whose point of view this controller manipulates. [AI]
void AffectPointOfView()
[AI] Internal method to compute and apply the effect of user mouse input on the current point of view...
void LeftDown(int p_x, int p_y) override
[AI] Called when left mouse button is pressed; may start point-of-view manipulation.
MxResult Tickle() override
[AI] Called each frame (tick) to update the state of the point of view, potentially responding to inp...
MxDouble m_entityOffsetUp
[AI] Offset along the entity's upward vector (for perspective/camera alignment). [AI]
MxResult Create(Lego3DView *p_lego3DView)
[AI] Initializes the controller with a specific 3D view.
Lego3DView * m_lego3DView
[AI] The active 3D view that input actions are translated into. [AI]
void OnViewSize(int p_width, int p_height)
[AI] Updates the controller's internal state for a view size change, such as resizing the 3D viewport...
void UpdateListener(const float *p_position, const float *p_direction, const float *p_up, const float *p_velocity)
[AI] Updates the 3D sound listener properties in DirectSound, reflecting player/world changes.
[AI] Represents a 3D point with floating-point precision, inheriting from Vector3.
Definition: mxgeometry3d.h:14
[AI] Represents a 4x4 transformation matrix, specialized for the LEGO Island engine and derived from ...
Definition: mxmatrix.h:16
virtual void UnregisterClient(MxCore *p_client)
[AI] Unregisters (marks for destruction) a previously registered client.
virtual void RegisterClient(MxCore *p_client, MxTime p_interval)
[AI] Registers an MxCore object to receive periodic tickles.
MxLong GetTime()
Returns the current timer value in ms, depending on running state.
Definition: mxtimer.h:50
const float * GetWorldUp() const
Returns a pointer to the world up vector from the transformation matrix.
const float * GetWorldPosition() const
Returns a pointer to the world position from the transformation matrix (translation row).
const float * GetWorldDirection() const
Returns a pointer to the world direction vector (forward axis) from the transformation matrix.
void WrappedSetLocalTransform(const Matrix4 &p_transform)
Wraps SetLocalTransform, for possible override or interface uniformity.
void FUN_100a5a30(const Vector3 &p_world_velocity)
Sets the world velocity to the provided vector.
const float * GetWorldVelocity() const override
Returns a pointer to the object's velocity vector in world space.
[AI] An extension of LegoROI that adds support for keeping and applying a base time reference (used f...
Definition: legoroi.h:342
[AI] 3D vector class, providing vector and cross-product operations in 3D space.
Definition: vector.h:249
void Clear() override
[AI] Sets every coordinate (x, y, z) to zero.
[AI] ViewROI objects represent viewable and placeable objects in the scene, each holding their own tr...
Definition: viewroi.h:13
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
MxBool g_unk0x100f75ac
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
LegoSoundManager * SoundManager()
[AI] Accessor for the game's LegoSoundManager subsystem from the global LegoOmni instance....
Definition: misc.cpp:22
MxTimer * Timer()
[AI] Returns the global simulation timer.
Definition: mxmisc.cpp:33
MxTickleManager * TickleManager()
[AI] Provides access to the global tickle manager.
Definition: mxmisc.cpp:25
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
void CalcLocalTransform(const Vector3 &p_posVec, const Vector3 &p_dirVec, const Vector3 &p_upVec, Matrix4 &p_outMatrix)
[AI] Computes a transformation matrix based on a position, direction, and up vector.
Definition: realtime.cpp:7