X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fcamera.h;h=006f4b3cebadf1a74f9e682d2e1ed74b9bd54198;hb=c26eb87aec7438d167fa2f460a3f412db09c0ac5;hp=0ed5c20d292096833afe890bdfb08f0fc4d302e1;hpb=7cd5eb4c77de9fda4946de7e1c2384d0c2a0253e;p=oweals%2Fminetest.git diff --git a/src/camera.h b/src/camera.h index 0ed5c20d2..006f4b3ce 100644 --- a/src/camera.h +++ b/src/camera.h @@ -23,13 +23,18 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes_extrabloated.h" #include "inventory.h" #include "mesh.h" -#include "tile.h" +#include "client/tile.h" #include "util/numeric.h" #include +#include "client.h" + class LocalPlayer; struct MapDrawControl; class IGameDef; +class WieldMeshSceneNode; + +enum CameraMode {CAMERA_MODE_FIRST, CAMERA_MODE_THIRD, CAMERA_MODE_THIRD_FRONT}; /* Client camera class, manages the player and camera scene nodes, the viewing distance @@ -79,6 +84,12 @@ public: { return m_camera_direction; } + + // Get the camera offset + inline v3s16 getOffset() const + { + return m_camera_offset; + } // Horizontal field of view inline f32 getFovX() const @@ -99,18 +110,18 @@ public: } // Checks if the constructor was able to create the scene nodes - bool successfullyCreated(std::wstring& error_message); + bool successfullyCreated(std::string &error_message); // Step the camera: updates the viewing range and view bobbing. void step(f32 dtime); // Update the camera from the local player's position. - // frametime is used to adjust the viewing range. - void update(LocalPlayer* player, f32 frametime, v2u32 screensize, - f32 tool_reload_ratio); + // busytime is used to adjust the viewing range. + void update(LocalPlayer* player, f32 frametime, f32 busytime, + f32 tool_reload_ratio, ClientEnvironment &c_env); // Render distance feedback loop - void updateViewingRange(f32 frametime_in); + void updateViewingRange(f32 frametime_in, f32 busytime_in); // Start digging animation // Pass 0 for left click, 1 for right click @@ -122,18 +133,32 @@ public: // Draw the wielded tool. // This has to happen *after* the main scene is drawn. // Warning: This clears the Z buffer. - void drawWieldedTool(); + void drawWieldedTool(irr::core::matrix4* translation=NULL); + + // Toggle the current camera mode + void toggleCameraMode() { + if (m_camera_mode == CAMERA_MODE_FIRST) + m_camera_mode = CAMERA_MODE_THIRD; + else if (m_camera_mode == CAMERA_MODE_THIRD) + m_camera_mode = CAMERA_MODE_THIRD_FRONT; + else + m_camera_mode = CAMERA_MODE_FIRST; + } + + //read the current camera mode + inline CameraMode getCameraMode() + { + return m_camera_mode; + } private: - // Scene manager and nodes - scene::ISceneManager* m_smgr; + // Nodes scene::ISceneNode* m_playernode; scene::ISceneNode* m_headnode; scene::ICameraSceneNode* m_cameranode; scene::ISceneManager* m_wieldmgr; - scene::IMeshSceneNode* m_wieldnode; - u8 m_wieldlight; + WieldMeshSceneNode* m_wieldnode; // draw control MapDrawControl& m_draw_control; @@ -144,6 +169,8 @@ private: v3f m_camera_position; // Absolute camera direction v3f m_camera_direction; + // Camera offset + v3s16 m_camera_offset; // Field of view and aspect ratio stuff f32 m_aspect; @@ -151,10 +178,10 @@ private: f32 m_fov_y; // Stuff for viewing range calculations - f32 m_added_frametime; + f32 m_added_busytime; s16 m_added_frames; f32 m_range_old; - f32 m_frametime_old; + f32 m_busytime_old; f32 m_frametime_counter; f32 m_time_per_range; @@ -176,8 +203,17 @@ private: // If 1, right-click digging animation s32 m_digging_button; - //dummymesh for camera - irr::scene::IAnimatedMesh* m_dummymesh; + // Animation when changing wielded item + f32 m_wield_change_timer; + ItemStack m_wield_item_next; + + CameraMode m_camera_mode; + + f32 m_cache_fall_bobbing_amount; + f32 m_cache_view_bobbing_amount; + f32 m_cache_wanted_fps; + f32 m_cache_fov; + bool m_cache_view_bobbing; }; #endif