Isle
Loading...
Searching...
No Matches
legocameracontroller.cpp
Go to the documentation of this file.
2
4#include "legoinputmanager.h"
5#include "legosoundmanager.h"
6#include "legovideomanager.h"
7#include "misc.h"
8#include "mxmisc.h"
9#include "mxtimer.h"
10#include "realtime/realtime.h"
11#include "roi/legoroi.h"
12
13#include <vec.h>
14
16
17// FUNCTION: LEGO1 0x10011d50
19{
20 SetWorldTransform(Mx3DPointFloat(0, 0, 0), Mx3DPointFloat(0, 0, 1), Mx3DPointFloat(0, 1, 0));
21}
22
23// FUNCTION: LEGO1 0x10011f70
25{
26 if (InputManager()) {
27 if (InputManager()->GetCamera() == this) {
29 }
30 }
31}
32
33// FUNCTION: LEGO1 0x10011ff0
35{
36 InputManager()->SetCamera(this);
37 return LegoPointOfViewController::Create(VideoManager()->Get3DManager()->GetLego3DView());
38}
39
40// FUNCTION: LEGO1 0x10012020
41// FUNCTION: BETA10 0x10067852
43{
44 switch (((MxNotificationParam&) p_param).GetNotification()) {
47 0) {
49 ((LegoEventNotificationParam&) p_param).GetX(),
50 ((LegoEventNotificationParam&) p_param).GetY()
51 ));
52 }
53 else if (((((LegoEventNotificationParam&) p_param).GetModifier()) & LegoEventNotificationParam::c_rButtonState) == 0) {
55 ((LegoEventNotificationParam&) p_param).GetX(),
56 ((LegoEventNotificationParam&) p_param).GetY()
57 ));
58 }
59 } break;
63 ((LegoEventNotificationParam&) p_param).GetX(),
64 ((LegoEventNotificationParam&) p_param).GetY()
65 ));
66 }
67 else if ((((LegoEventNotificationParam&) p_param).GetModifier()) & LegoEventNotificationParam::c_rButtonState) {
69 ((LegoEventNotificationParam&) p_param).GetX(),
70 ((LegoEventNotificationParam&) p_param).GetY()
71 ));
72 }
73 } break;
74 case c_notificationDrag: {
76 ((LegoEventNotificationParam&) p_param).GetModifier(),
77 MxPoint32(((LegoEventNotificationParam&) p_param).GetX(), ((LegoEventNotificationParam&) p_param).GetY())
78 );
79 } break;
80 }
81
82 return SUCCESS;
83}
84
85// FUNCTION: LEGO1 0x100121b0
87{
88 LeftDown(p_point.GetX(), p_point.GetY());
89}
90
91// FUNCTION: LEGO1 0x100121d0
93{
94 LeftUp(p_point.GetX(), p_point.GetY());
95}
96
97// FUNCTION: LEGO1 0x100121f0
99{
100 RightDown(p_point.GetX(), p_point.GetY());
101}
102
103// FUNCTION: LEGO1 0x10012210
105{
106 RightUp(p_point.GetX(), p_point.GetY());
107}
108
109// FUNCTION: LEGO1 0x10012230
111{
113 LeftDrag(p_point.GetX(), p_point.GetY());
114 }
115 else if (p_modifier & LegoEventNotificationParam::c_rButtonState) {
116 RightDrag(p_point.GetX(), p_point.GetY());
117 }
118}
119
120// FUNCTION: LEGO1 0x10012260
121void LegoCameraController::SetWorldTransform(const Vector3& p_at, const Vector3& p_dir, const Vector3& p_up)
122{
123 CalcLocalTransform(p_at, p_dir, p_up, m_matrix1);
124 m_matrix2 = m_matrix1;
125}
126
127// FUNCTION: LEGO1 0x10012290
128// FUNCTION: BETA10 0x10068c34
130{
131 m_matrix1 = m_matrix2;
132 m_matrix1.RotateZ(p_angle);
133}
134
135// FUNCTION: LEGO1 0x10012320
136// FUNCTION: BETA10 0x10068c73
138{
139 m_matrix1 = m_matrix2;
140 m_matrix1.RotateY(p_angle);
141}
142
143// FUNCTION: LEGO1 0x100123b0
145{
146 if (m_lego3DView) {
148 if (pov) {
149 p_matrix = pov->GetLocal2World();
150 return SUCCESS;
151 }
152 }
153
154 return FAILURE;
155}
156
157// FUNCTION: LEGO1 0x100123e0
158// FUNCTION: BETA10 0x10068cb2
159void LegoCameraController::FUN_100123e0(const Matrix4& p_transform, MxU32 p_und)
160{
161 if (m_lego3DView != NULL) {
163
164 if (pov != NULL) {
165 MxMatrix mat;
166
167 if (p_und) {
168 MXM4(mat, m_matrix1, p_transform);
169 }
170 else {
171 mat = p_transform;
172 }
173
174 ((TimeROI*) pov)->FUN_100a9b40(mat, Timer()->GetTime());
175 pov->WrappedSetLocalTransform(mat);
176 m_lego3DView->Moved(*pov);
177
179 pov->GetWorldPosition(),
180 pov->GetWorldDirection(),
181 pov->GetWorldUp(),
182 pov->GetWorldVelocity()
183 );
184 }
185 }
186}
187
188// FUNCTION: LEGO1 0x10012740
190{
192 Mx3DPointFloat vec;
194 return Mx3DPointFloat(vec[0], vec[1], vec[2]);
195 }
196 else {
197 return Mx3DPointFloat(0, 0, 0);
198 }
199}
200
201// FUNCTION: LEGO1 0x100127f0
203{
205 Mx3DPointFloat vec;
207 return Mx3DPointFloat(vec[0], vec[1] - m_entityOffsetUp, vec[2]);
208 }
209 else {
210 return Mx3DPointFloat(0, 0, 0);
211 }
212}
213
214// FUNCTION: LEGO1 0x100128a0
216{
218 Mx3DPointFloat vec;
220 return Mx3DPointFloat(vec[0], vec[1], vec[2]);
221 }
222 else {
223 return Mx3DPointFloat(0, 0, 0);
224 }
225}
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
Camera controller for 3D scenes, handles interactive camera manipulation and view transformation.
void SetWorldTransform(const Vector3 &p_at, const Vector3 &p_dir, const Vector3 &p_up)
Updates the camera's world transformation matrix using view reference parameters.
Mx3DPointFloat GetWorldUp()
Gets the camera's current world-space up vector.
virtual void OnLButtonDown(MxPoint32 p_point)
Called when the left mouse button is pressed at a screen point.
void FUN_10012290(float p_angle)
Rotates the current camera transformation by a given angle around the Z axis.
Mx3DPointFloat GetWorldDirection()
Gets the camera's world-space forward direction vector.
void FUN_10012320(float p_angle)
Rotates the current camera transformation by a given angle around the Y axis.
virtual MxResult Create()
Registers the camera controller with input manager and initializes state with current view.
MxResult FUN_100123b0(Matrix4 &p_matrix)
Retrieves the current point-of-view transformation into a matrix if it exists.
virtual void OnRButtonUp(MxPoint32 p_point)
Called when the right mouse button is released at a screen point.
virtual void OnLButtonUp(MxPoint32 p_point)
Called when the left mouse button is released at a screen point.
void FUN_100123e0(const Matrix4 &p_transform, MxU32 p_und)
Sets the camera's transformation matrix in the 3D view, optionally applying a blend with the internal...
virtual void OnMouseMove(MxU8 p_modifier, MxPoint32 p_point)
Called when the mouse is moved.
virtual void OnRButtonDown(MxPoint32 p_point)
Called when the right mouse button is pressed at a screen point.
MxLong Notify(MxParam &p_param) override
Handles notifications for camera-relevant events (like mouse drag and mouse clicks).
~LegoCameraController() override
Destructor.
Mx3DPointFloat GetWorldLocation()
Gets the camera's current world-space location.
Notification parameter class for LEGO event notifications such as mouse events and modifier keys.
void ClearCamera()
[AI] Remove any assigned camera controller, disabling camera navigation responses....
void SetCamera(LegoCameraController *p_camera)
[AI] Assigns a new camera controller for mouse/look operations.
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.
void RightDrag(int p_x, int p_y) override
[AI] Called when right button is held and cursor is moved, e.g., for rotational camera movement.
void LeftDown(int p_x, int p_y) override
[AI] Called when left mouse button is pressed; may start point-of-view manipulation.
void LeftUp(int p_x, int p_y) override
[AI] Called when the left button is released, possibly to end the manipulation and update the camera/...
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 RightDown(int p_x, int p_y) override
[AI] Called when the right mouse button is pressed; often used for alternative camera controls.
void RightUp(int p_x, int p_y) override
[AI] Called when the right mouse button is released, possibly to finalize alternative camera/entity a...
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.
4x4 Matrix class with virtual interface for manipulation and transformation.
Definition: matrix.h:24
void RotateY(const float &p_angle)
Applies a rotation (in radians or degrees, depending on implementation) about the Y axis.
void RotateZ(const float &p_angle)
Applies a rotation (in radians or degrees) about the Z axis.
[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
[AI] Parameter object representing a single notification or event, carrying an identifier and sender ...
[AI] MxParam serves as a polymorphic base class for parameter passing in event and notification syste...
Definition: mxparam.h:7
[AI] 2D point with 32-bit signed integer coordinates.
Definition: mxgeometry.h:487
T GetY() const
[AI] Get Y coordinate.
Definition: mxgeometry.h:53
T GetX() const
[AI] Get X coordinate.
Definition: mxgeometry.h:48
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.
const Matrix4 & GetLocal2World() const
Accessor for the current local-to-world transformation matrix.
void WrappedSetLocalTransform(const Matrix4 &p_transform)
Wraps SetLocalTransform, for possible override or interface uniformity.
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
[AI] ViewROI objects represent viewable and placeable objects in the scene, each holding their own tr...
Definition: viewroi.h:13
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
Definition: legotypes.h:34
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
LegoVideoManager * VideoManager()
[AI] Accessor for the game's LegoVideoManager subsystem. Used for managing 3D/video hardware....
Definition: misc.cpp:29
LegoSoundManager * SoundManager()
[AI] Accessor for the game's LegoSoundManager subsystem from the global LegoOmni instance....
Definition: misc.cpp:22
LegoInputManager * InputManager()
[AI] Accessor for the input manager, which handles keyboard, mouse, and controller input....
Definition: misc.cpp:45
MxTimer * Timer()
[AI] Returns the global simulation timer.
Definition: mxmisc.cpp:33
@ c_notificationDragEnd
[AI] End of drag event [AI]
@ c_notificationDragStart
[AI] Start of a drag event (mouse/touch) [AI]
@ c_notificationDrag
[AI] Ongoing drag/move event [AI]
MxLong MxResult
[AI]
Definition: mxtypes.h:106
int MxLong
[AI]
Definition: mxtypes.h:83
unsigned char MxU8
[AI]
Definition: mxtypes.h:8
unsigned int MxU32
[AI]
Definition: mxtypes.h:32
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
#define MXM4(to, m1, m2)
Definition: vec.h:677