]> git.lizzy.rs Git - minetest.git/blobdiff - src/camera.h
Create node metadata when placing nodes again
[minetest.git] / src / camera.h
index 88f03e66d303a47675beb671928c153793821b5d..56c99d1014881a8ed1498d74ac7320ab196b039a 100644 (file)
@@ -21,14 +21,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #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
 {
@@ -38,16 +44,22 @@ 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;
@@ -85,6 +97,9 @@ class Camera
                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);
 
@@ -98,12 +113,29 @@ class Camera
        // 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;
 
@@ -131,11 +163,21 @@ class Camera
        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
-