Class FirstPersonViewComponent
First-person camera control component for entities.
Constructors
| Name | Description |
|---|---|
this
(eventManager, hostEntity)
|
Constructs a first-person view component for the given entity. |
Fields
| Name | Type | Description |
|---|---|---|
axisDeadzone
|
float | Lower threshold of controller axis value. |
axisSensitivity
|
float | Sensitivity for virtual axes (controlled via keyboard or gamepad). |
baseOrientation
|
dlib | Base orientation quaternion. |
direction
|
dlib | Current forward direction vector. |
directionHorizontal
|
dlib | Forward direction ignoring pitch. |
mouseActive
|
bool | True if mouse input is active. |
mouseSensitivity
|
float | Mouse sensitivity factor. |
orientationH
|
dlib | Horizontal orientation quaternion. |
orientationV
|
dlib | Vertical orientation quaternion. |
pitch
|
float | Camera pitch angle (degrees). |
pitchLimitMax
|
float | Maximum pitch angle (degrees). |
pitchLimitMin
|
float | Minimum pitch angle (degrees). |
prevMouseX
|
int | Previous mouse X coordinate. |
prevMouseY
|
int | Previous mouse Y coordinate. |
right
|
dlib | Right direction vector. |
roll
|
float | Camera roll angle (degrees). |
turn
|
float | Camera turn angle (degrees). |
up
|
dlib | Up direction vector. |
address
|
string | Address of this dispatcher. |
enabled
|
bool | If false, disables event processing. |
entity
|
Entity | The entity this component is attached to. |
eventManager
|
EventManager | The event manager used for polling events. |
inputManager
|
InputManager | The input manager for input state queries. |
visible
|
bool | If false, the component is not rendered. |
domain
|
int | Addressing domain of this dispatcher. |
Properties
| Name | Type | Description |
|---|---|---|
active[set]
|
bool | Enables or disables the component. |
active[get]
|
bool | Returns whether the component is active. |
useRelativeMouseMode[set]
|
bool | Enables or disables relative mouse mode. |
useRelativeMouseMode[get]
|
bool | Returns whether relative mouse mode is enabled. |
Methods
| Name | Description |
|---|---|
moveBack
(speed)
|
Moves the entity backward by the given speed. |
moveForward
(speed)
|
Moves the entity forward by the given speed. |
onFocusGain
()
|
Called when the application gains focus. |
onFocusLoss
()
|
Called when the application loses focus. |
reset
()
|
Resets pitch, turn, and mouse state. |
strafeLeft
(speed)
|
Strafes the entity left by the given speed. |
strafeRight
(speed)
|
Strafes the entity right by the given speed. |
update
(time)
|
Updates the component each frame (handles input and orientation). |
onControllerAdd
(deviceIndex, deviceType)
|
Called when a controller is added. |
onControllerAxisMotion
(deviceIndex, axis, value)
|
Called when a controller axis is moved. |
onControllerButtonDown
(deviceIndex, button)
|
Called when a controller button is pressed. |
onControllerButtonUp
(deviceIndex, button)
|
Called when a controller button is released. |
onControllerRemove
(deviceIndex)
|
Called when a controller is removed. |
onCustomResize
(x, y, width, height)
|
|
onDropFile
(filename)
|
Called when a file is dropped onto the window. |
onFileChange
(filename)
|
Called when a file change is detected. |
onHardwareSpecificEvent
(deviceIndex, code, payload)
|
Called when a hardware specific event is received from a custom InputDevice. |
onJoystickAxisMotion
(deviceIndex, axis, value)
|
Called when a joystick axis is moved. |
onJoystickButtonDown
(deviceIndex, button)
|
Called when a joystick button is pressed. |
onJoystickButtonUp
(deviceIndex, button)
|
Called when a joystick button is released. |
onKeyboardLayoutChange
()
|
Called when the user switches system keyboard layout. |
onKeyDown
(key)
|
Called when a key is pressed. |
onKeyUp
(key)
|
Called when a key is released. |
onLocaleChange
()
|
Called when a user locale preferences have changed. |
onMessage
(domain, sender, message, payload)
|
Called when a message event is received. |
onMouseButtonDown
(button)
|
Called when a mouse button is pressed. |
onMouseButtonUp
(button)
|
Called when a mouse button is released. |
onMouseWheel
(x, y)
|
Called when the mouse wheel is scrolled. |
onPenMotion
(x, y, pressure)
|
Called when a pen (stilus) is moved over a graphics tablet. |
onQuit
()
|
Called when a quit event is received. |
onResize
(width, height)
|
Called when the window is resized. |
onTask
(domain, sender, callback, payload)
|
Called when a task event is received. |
onTextInput
(code)
|
Called when text input is received. |
onTimerEvent
(timerID, userCode)
|
Called when a timer event is received. |
onUserEvent
(code, payload)
|
Called when a user event is received. |
processEvent
(e, enableInputEvents)
|
Processes a single event, dispatching it to the appropriate handler. |
processEvents
(enableInputEvents)
|
Processes all pending events, dispatching them to handler methods. |
render
(state)
|
Override to implement rendering logic. |
generateUserEvent
(code, payload)
|
Queues a user event with the given code and payload pointer. |
queueLog
(level, message)
|
Queues a log event. |
queueMessage
(recipient, message, payload, domain)
|
Queues a message event. |
queueTask
(callback, payload, domain)
|
Queues a task event. |
Description
Enables mouse and keyboard-based camera orientation and movement, supporting both relative and absolute mouse modes. Handles pitch and turn limits and configurable sensitivities.