Minetest 5.10.0-dev
 
Loading...
Searching...
No Matches
Camera Class Reference

#include <camera.h>

+ Collaboration diagram for Camera:

Public Member Functions

 Camera (MapDrawControl &draw_control, Client *client, RenderingEngine *rendering_engine)
 
 ~Camera ()
 
scene::ICameraSceneNode * getCameraNode () const
 
v3f getPosition () const
 
v3f getHeadPosition () const
 
v3f getDirection () const
 
v3s16 getOffset () const
 
f32 getFovX () const
 
f32 getFovY () const
 
f32 getFovMax () const
 
auto getFrustumCuller () const
 
void notifyFovChange ()
 
void step (f32 dtime)
 
void update (LocalPlayer *player, f32 frametime, f32 tool_reload_ratio)
 
void updateViewingRange ()
 
void setDigging (s32 button)
 
void wield (const ItemStack &item)
 
void drawWieldedTool (irr::core::matrix4 *translation=NULL)
 
void toggleCameraMode ()
 
void setCameraMode (CameraMode mode)
 
CameraMode getCameraMode ()
 
NametagaddNametag (scene::ISceneNode *parent_node, const std::string &text, video::SColor textcolor, std::optional< video::SColor > bgcolor, const v3f &pos)
 
void removeNametag (Nametag *nametag)
 
void drawNametags ()
 
void addArmInertia (f32 player_yaw)
 

Private Member Functions

std::array< core::plane3d< f32 >, 4 > getFrustumCullPlanes () const
 

Private Attributes

scene::ISceneNode * m_playernode = nullptr
 
scene::ISceneNode * m_headnode = nullptr
 
scene::ICameraSceneNode * m_cameranode = nullptr
 
scene::ISceneManager * m_wieldmgr = nullptr
 
WieldMeshSceneNodem_wieldnode = nullptr
 
MapDrawControlm_draw_control
 
Clientm_client
 
f32 m_cache_fov
 
v3f m_camera_position
 
v3f m_camera_direction
 
v3s16 m_camera_offset
 
bool m_stepheight_smooth_active = false
 
bool m_server_sent_fov = false
 
f32 m_curr_fov_degrees
 
f32 m_target_fov_degrees
 
bool m_fov_transition_active = false
 
f32 m_fov_diff
 
f32 m_transition_time
 
v2f m_wieldmesh_offset = v2f(55.0f, -35.0f)
 
v2f m_arm_dir
 
v2f m_cam_vel
 
v2f m_cam_vel_old
 
v2f m_last_cam_pos
 
f32 m_aspect = 1.0f
 
f32 m_fov_x = 1.0f
 
f32 m_fov_y = 1.0f
 
f32 m_view_bobbing_anim = 0.0f
 
s32 m_view_bobbing_state = 0
 
f32 m_view_bobbing_speed = 0.0f
 
f32 m_view_bobbing_fall = 0.0f
 
f32 m_digging_anim = 0.0f
 
s32 m_digging_button = -1
 
f32 m_wield_change_timer = 0.125f
 
ItemStack m_wield_item_next
 
CameraMode m_camera_mode = CAMERA_MODE_FIRST
 
f32 m_cache_fall_bobbing_amount
 
f32 m_cache_view_bobbing_amount
 
bool m_arm_inertia
 
std::list< Nametag * > m_nametags
 
bool m_show_nametag_backgrounds
 
video::SColor m_player_light_color
 

Constructor & Destructor Documentation

◆ Camera()

Camera::Camera ( MapDrawControl & draw_control,
Client * client,
RenderingEngine * rendering_engine )

◆ ~Camera()

Camera::~Camera ( )

References m_wieldmgr.

Member Function Documentation

◆ addArmInertia()

void Camera::addArmInertia ( f32 player_yaw)
inline

References dir(), m_arm_dir, m_cam_vel, m_cam_vel_old, m_camera_direction, m_last_cam_pos, m_wieldmesh_offset, rangelim, WIELDMESH_AMPLITUDE_X, WIELDMESH_AMPLITUDE_Y, WIELDMESH_OFFSET_X, and WIELDMESH_OFFSET_Y.

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addNametag()

Nametag * Camera::addNametag ( scene::ISceneNode * parent_node,
const std::string & text,
video::SColor textcolor,
std::optional< video::SColor > bgcolor,
const v3f & pos )

References m_nametags.

Referenced by GenericCAO::updateNametag().

+ Here is the caller graph for this function:

◆ drawNametags()

void Camera::drawNametags ( )

References BS, g_fontengine, RenderingEngine::get_video_driver(), FontEngine::getFont(), m_cameranode, m_nametags, m_show_nametag_backgrounds, translate_string(), unescape_translate(), and utf8_to_wide().

Referenced by DrawHUD::run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ drawWieldedTool()

void Camera::drawWieldedTool ( irr::core::matrix4 * translation = NULL)

References m_cameranode, and m_wieldmgr.

Referenced by DrawWield::run().

+ Here is the caller graph for this function:

◆ getCameraMode()

◆ getCameraNode()

scene::ICameraSceneNode * Camera::getCameraNode ( ) const
inline

References m_cameranode.

Referenced by DirectionalLight::createSplitMatrices(), LuaCamera::l_get_aspect_ratio(), LuaCamera::l_get_fov(), GameGlobalShaderConstantSetter::onSetConstants(), OffsetCameraStep::reset(), OffsetCameraStep::run(), DirectionalLight::update_frustum(), Game::updateClouds(), and Game::updateSound().

+ Here is the caller graph for this function:

◆ getDirection()

v3f Camera::getDirection ( ) const
inline

References m_camera_direction.

Referenced by DirectionalLight::createSplitMatrices(), LuaCamera::l_get_look_dir(), Game::processPlayerInteraction(), Game::updateCamera(), Game::updateFrame(), and Game::updateSound().

+ Here is the caller graph for this function:

◆ getFovMax()

f32 Camera::getFovMax ( ) const
inline

References m_fov_x, m_fov_y, and MYMAX.

Referenced by LuaCamera::l_get_fov(), Game::updateCamera(), and updateViewingRange().

+ Here is the caller graph for this function:

◆ getFovX()

f32 Camera::getFovX ( ) const
inline

References m_fov_x.

Referenced by DirectionalLight::createSplitMatrices(), and LuaCamera::l_get_fov().

+ Here is the caller graph for this function:

◆ getFovY()

f32 Camera::getFovY ( ) const
inline

References m_fov_y.

Referenced by DirectionalLight::createSplitMatrices(), and LuaCamera::l_get_fov().

+ Here is the caller graph for this function:

◆ getFrustumCuller()

auto Camera::getFrustumCuller ( ) const
inline

References BS, getFrustumCullPlanes(), intToFloat(), and m_camera_offset.

Referenced by ClientMap::renderMap(), and ClientMap::updateDrawList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFrustumCullPlanes()

std::array< core::plane3d< f32 >, 4 > Camera::getFrustumCullPlanes ( ) const
private

References m_cameranode.

Referenced by getFrustumCuller().

+ Here is the caller graph for this function:

◆ getHeadPosition()

v3f Camera::getHeadPosition ( ) const
inline

References m_headnode.

Referenced by Game::processPlayerInteraction().

+ Here is the caller graph for this function:

◆ getOffset()

v3s16 Camera::getOffset ( ) const
inline

References m_camera_offset.

Referenced by DirectionalLight::createSplitMatrices(), GameGlobalShaderConstantSetter::onSetConstants(), Game::processPlayerInteraction(), DrawHUD::run(), DirectionalLight::update_frustum(), Game::updateCamera(), Game::updateClouds(), and Game::updateSound().

+ Here is the caller graph for this function:

◆ getPosition()

v3f Camera::getPosition ( ) const
inline

References m_camera_position.

Referenced by DirectionalLight::createSplitMatrices(), LuaCamera::l_get_pos(), GameGlobalShaderConstantSetter::onSetConstants(), Game::processPlayerInteraction(), and Game::updateCamera().

+ Here is the caller graph for this function:

◆ notifyFovChange()

void Camera::notifyFovChange ( )

References PlayerFovSpec::fov, Client::getEnv(), Player::getFov(), ClientEnvironment::getLocalPlayer(), PlayerFovSpec::is_multiplier, m_cache_fov, m_client, m_curr_fov_degrees, m_fov_diff, m_fov_transition_active, m_server_sent_fov, m_target_fov_degrees, m_transition_time, and PlayerFovSpec::transition_time.

Referenced by Client::handleCommand_Fov().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeNametag()

void Camera::removeNametag ( Nametag * nametag)

References m_nametags.

Referenced by GenericCAO::removeFromScene(), and GenericCAO::updateNametag().

+ Here is the caller graph for this function:

◆ setCameraMode()

void Camera::setCameraMode ( CameraMode mode)
inline

References m_camera_mode.

Referenced by LuaCamera::l_set_camera_mode().

+ Here is the caller graph for this function:

◆ setDigging()

void Camera::setDigging ( s32 button)

References m_digging_button.

Referenced by Game::handleDigging(), Game::handlePointingAtNode(), and Game::processPlayerInteraction().

+ Here is the caller graph for this function:

◆ step()

void Camera::step ( f32 dtime)

References MtEvent::CAMERA_PUNCH_LEFT, MtEvent::CAMERA_PUNCH_RIGHT, Client::getEventManager(), m_client, m_digging_anim, m_digging_button, m_player_light_color, m_view_bobbing_anim, m_view_bobbing_fall, m_view_bobbing_speed, m_view_bobbing_state, m_wield_change_timer, m_wield_item_next, m_wieldnode, my_modf(), MYMIN, MtEventManager::put(), WieldMeshSceneNode::setItem(), WieldMeshSceneNode::setNodeLightColor(), step(), and MtEvent::VIEW_BOBBING_STEP.

Referenced by step(), and Game::updateCamera().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toggleCameraMode()

void Camera::toggleCameraMode ( )
inline

References CAMERA_MODE_FIRST, CAMERA_MODE_THIRD, CAMERA_MODE_THIRD_FRONT, and m_camera_mode.

Referenced by Game::updateCamera().

+ Here is the caller graph for this function:

◆ update()

void Camera::update ( LocalPlayer * player,
f32 frametime,
f32 tool_reload_ratio )

References addArmInertia(), BS, LocalPlayer::camera_impact, CAMERA_MODE_FIRST, CAMERA_MODE_THIRD, CAMERA_MODE_THIRD_FRONT, CAMERA_OFFSET_STEP, Client::checkLocalPrivilege(), easeCurve(), Player::eye_offset_first, Player::eye_offset_third, Player::eye_offset_third_front, floatToInt(), g_settings, NodeDefManager::get(), Settings::getBool(), LocalPlayer::getCAO(), ClientEnvironment::getClientMap(), Client::getEnv(), LocalPlayer::getEyeOffset(), Map::getNode(), LocalPlayer::getParent(), LocalPlayer::getPitch(), Player::getPlayerControl(), ClientActiveObject::getPosition(), LocalPlayer::getPosition(), Player::getSpeed(), GenericCAO::getStepHeight(), RenderingEngine::getWindowSize(), LocalPlayer::getYaw(), LocalPlayer::getZoomFOV(), LocalPlayer::hurt_tilt_strength, LocalPlayer::hurt_tilt_timer, LocalPlayer::in_liquid, intToFloat(), LocalPlayer::is_climbing, LocalPlayer::light_color, m_arm_inertia, m_aspect, m_cache_fall_bobbing_amount, m_cache_fov, m_cache_view_bobbing_amount, m_camera_direction, m_camera_mode, m_camera_offset, m_camera_position, m_cameranode, m_client, m_curr_fov_degrees, m_digging_anim, m_digging_button, m_fov_diff, m_fov_transition_active, m_fov_x, m_fov_y, m_headnode, m_player_light_color, m_playernode, m_server_sent_fov, m_stepheight_smooth_active, m_target_fov_degrees, m_transition_time, m_view_bobbing_anim, m_view_bobbing_fall, m_view_bobbing_speed, m_view_bobbing_state, m_wield_change_timer, m_wieldmesh_offset, m_wieldnode, my_modf(), MYMIN, IGameDef::ndef(), rangelim, WieldMeshSceneNode::setNodeLightColor(), LocalPlayer::swimming_vertical, LocalPlayer::touching_ground, updateViewingRange(), ContentFeatures::walkable, and PlayerControl::zoom.

Referenced by Game::updateCamera().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateViewingRange()

void Camera::updateViewingRange ( )

References adjustDist(), BS, g_settings, Settings::getFloat(), getFovMax(), m_cameranode, m_draw_control, MapDrawControl::range_all, and MapDrawControl::wanted_range.

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wield()

void Camera::wield ( const ItemStack & item)

References m_wield_change_timer, m_wield_item_next, ItemStack::metadata, and ItemStack::name.

Referenced by Game::updateFrame().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_arm_dir

v2f Camera::m_arm_dir
private

Referenced by addArmInertia().

◆ m_arm_inertia

bool Camera::m_arm_inertia
private

Referenced by Camera(), and update().

◆ m_aspect

f32 Camera::m_aspect = 1.0f
private

Referenced by update().

◆ m_cache_fall_bobbing_amount

f32 Camera::m_cache_fall_bobbing_amount
private

Referenced by Camera(), and update().

◆ m_cache_fov

f32 Camera::m_cache_fov
private

Referenced by Camera(), notifyFovChange(), and update().

◆ m_cache_view_bobbing_amount

f32 Camera::m_cache_view_bobbing_amount
private

Referenced by Camera(), and update().

◆ m_cam_vel

v2f Camera::m_cam_vel
private

Referenced by addArmInertia().

◆ m_cam_vel_old

v2f Camera::m_cam_vel_old
private

Referenced by addArmInertia().

◆ m_camera_direction

v3f Camera::m_camera_direction
private

Referenced by addArmInertia(), getDirection(), and update().

◆ m_camera_mode

CameraMode Camera::m_camera_mode = CAMERA_MODE_FIRST
private

◆ m_camera_offset

v3s16 Camera::m_camera_offset
private

Referenced by getFrustumCuller(), getOffset(), and update().

◆ m_camera_position

v3f Camera::m_camera_position
private

Referenced by getPosition(), and update().

◆ m_cameranode

scene::ICameraSceneNode* Camera::m_cameranode = nullptr
private

◆ m_client

Client* Camera::m_client
private

Referenced by Camera(), notifyFovChange(), step(), and update().

◆ m_curr_fov_degrees

f32 Camera::m_curr_fov_degrees
private

Referenced by notifyFovChange(), and update().

◆ m_digging_anim

f32 Camera::m_digging_anim = 0.0f
private

Referenced by step(), and update().

◆ m_digging_button

s32 Camera::m_digging_button = -1
private

Referenced by setDigging(), step(), and update().

◆ m_draw_control

MapDrawControl& Camera::m_draw_control
private

Referenced by updateViewingRange().

◆ m_fov_diff

f32 Camera::m_fov_diff
private

Referenced by notifyFovChange(), and update().

◆ m_fov_transition_active

bool Camera::m_fov_transition_active = false
private

Referenced by notifyFovChange(), and update().

◆ m_fov_x

f32 Camera::m_fov_x = 1.0f
private

Referenced by getFovMax(), getFovX(), and update().

◆ m_fov_y

f32 Camera::m_fov_y = 1.0f
private

Referenced by getFovMax(), getFovY(), and update().

◆ m_headnode

scene::ISceneNode* Camera::m_headnode = nullptr
private

Referenced by Camera(), getHeadPosition(), and update().

◆ m_last_cam_pos

v2f Camera::m_last_cam_pos
private

Referenced by addArmInertia().

◆ m_nametags

std::list<Nametag *> Camera::m_nametags
private

◆ m_player_light_color

video::SColor Camera::m_player_light_color
private

Referenced by step(), and update().

◆ m_playernode

scene::ISceneNode* Camera::m_playernode = nullptr
private

Referenced by Camera(), and update().

◆ m_server_sent_fov

bool Camera::m_server_sent_fov = false
private

Referenced by notifyFovChange(), and update().

◆ m_show_nametag_backgrounds

bool Camera::m_show_nametag_backgrounds
private

Referenced by Camera(), and drawNametags().

◆ m_stepheight_smooth_active

bool Camera::m_stepheight_smooth_active = false
private

Referenced by update().

◆ m_target_fov_degrees

f32 Camera::m_target_fov_degrees
private

Referenced by notifyFovChange(), and update().

◆ m_transition_time

f32 Camera::m_transition_time
private

Referenced by notifyFovChange(), and update().

◆ m_view_bobbing_anim

f32 Camera::m_view_bobbing_anim = 0.0f
private

Referenced by step(), and update().

◆ m_view_bobbing_fall

f32 Camera::m_view_bobbing_fall = 0.0f
private

Referenced by step(), and update().

◆ m_view_bobbing_speed

f32 Camera::m_view_bobbing_speed = 0.0f
private

Referenced by step(), and update().

◆ m_view_bobbing_state

s32 Camera::m_view_bobbing_state = 0
private

Referenced by step(), and update().

◆ m_wield_change_timer

f32 Camera::m_wield_change_timer = 0.125f
private

Referenced by step(), update(), and wield().

◆ m_wield_item_next

ItemStack Camera::m_wield_item_next
private

Referenced by step(), and wield().

◆ m_wieldmesh_offset

v2f Camera::m_wieldmesh_offset = v2f(55.0f, -35.0f)
private

Referenced by addArmInertia(), and update().

◆ m_wieldmgr

scene::ISceneManager* Camera::m_wieldmgr = nullptr
private

Referenced by Camera(), ~Camera(), and drawWieldedTool().

◆ m_wieldnode

WieldMeshSceneNode* Camera::m_wieldnode = nullptr
private

Referenced by Camera(), step(), and update().


The documentation for this class was generated from the following files: