#define CAMERA_HEADER
#include "common_irrlicht.h"
+#include "inventory.h"
+#include "mesh.h"
+#include "tile.h"
#include "utility.h"
+#include <ICameraSceneNode.h>
class LocalPlayer;
-class MapDrawControl;
+struct MapDrawControl;
+class IGameDef;
/*
Client camera class, manages the player and camera scene nodes, the viewing distance
- and performs view bobbing etc.
+ and performs view bobbing etc. It also displays the wielded tool in front of the
+ first-person camera.
*/
class Camera
{
// Get player scene node.
// This node is positioned at the player's torso (without any view bobbing),
- // as given by Player::m_position, Player::m_pitch and Player::m_yaw.
- // Things like wielded tools should be positioned relative to this node.
+ // as given by Player::m_position. Yaw is applied but not pitch.
inline scene::ISceneNode* getPlayerNode() const
{
return m_playernode;
}
+ // Get head scene node.
+ // It has the eye transformation and pitch applied,
+ // but no view bobbing.
+ inline scene::ISceneNode* getHeadNode() const
+ {
+ return m_headnode;
+ }
+
// Get camera scene node.
- // The camera node is a child of the player node.
- // It has the eye transformation and view bobbing applied.
+ // It has the eye transformation, pitch and view bobbing applied.
inline scene::ICameraSceneNode* getCameraNode() const
{
return m_cameranode;
return MYMAX(m_fov_x, m_fov_y);
}
+ // Checks if the constructor was able to create the scene nodes
+ bool successfullyCreated(std::wstring& error_message);
+
// Step the camera: updates the viewing range and view bobbing.
void step(f32 dtime);
// Update settings from g_settings
void updateSettings();
+ // Start digging animation
+ // Pass 0 for left click, 1 for right click
+ void setDigging(s32 button);
+
+ // Replace the wielded item mesh
+ void wield(const ItemStack &item, IGameDef *gamedef);
+
+ // Draw the wielded tool.
+ // This has to happen *after* the main scene is drawn.
+ // Warning: This clears the Z buffer.
+ void drawWieldedTool();
+
private:
// Scene manager and nodes
scene::ISceneManager* m_smgr;
scene::ISceneNode* m_playernode;
+ scene::ISceneNode* m_headnode;
scene::ICameraSceneNode* m_cameranode;
+ scene::ISceneManager* m_wieldmgr;
+ scene::IMeshSceneNode* m_wieldnode;
+ u8 m_wieldlight;
+
// draw control
MapDrawControl& m_draw_control;
f32 m_frametime_counter;
f32 m_time_per_range;
- // View bobbing animation frame (0 <= m_view_bobbing < 0x10000)
- u32 m_view_bobbing_anim;
- // Number of frames to continue the view bobbing animation.
- u32 m_view_bobbing_anim_left;
+ // View bobbing animation frame (0 <= m_view_bobbing_anim < 1)
+ f32 m_view_bobbing_anim;
+ // If 0, view bobbing is off (e.g. player is standing).
+ // If 1, view bobbing is on (player is walking).
+ // If 2, view bobbing is getting switched off.
+ s32 m_view_bobbing_state;
+ // Speed of view bobbing animation
+ f32 m_view_bobbing_speed;
+
+ // Digging animation frame (0 <= m_digging_anim < 1)
+ f32 m_digging_anim;
+ // If -1, no digging animation
+ // If 0, left-click digging animation
+ // If 1, right-click digging animation
+ s32 m_digging_button;
};
#endif
-