X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fcamera.h;h=b0d190a3afc5710013f45b09d9b185c3932f50c3;hb=972d17baea81ffe6d508b291ef97207a4822e1da;hp=aa9139148e60b6d8cf5ad4e624b3accda12fcceb;hpb=c50c9a10f12fb28724b30ec0db00aee39c4a1414;p=minetest.git diff --git a/src/camera.h b/src/camera.h index aa9139148..b0d190a3a 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 @@ class Camera { 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,7 +110,7 @@ class Camera } // 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); @@ -107,7 +118,7 @@ class Camera // Update the camera from the local player's position. // busytime is used to adjust the viewing range. void update(LocalPlayer* player, f32 frametime, f32 busytime, - v2u32 screensize, f32 tool_reload_ratio); + f32 tool_reload_ratio, ClientEnvironment &c_env); // Render distance feedback loop void updateViewingRange(f32 frametime_in, f32 busytime_in); @@ -117,23 +128,38 @@ class Camera void setDigging(s32 button); // Replace the wielded item mesh - void wield(const ItemStack &item, u16 playeritem); + void wield(const ItemStack &item); // 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; + scene::ILightSceneNode* m_wieldlightnode; // draw control MapDrawControl& m_draw_control; @@ -144,6 +170,8 @@ class Camera 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; @@ -176,14 +204,17 @@ class Camera // 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; - scene::IMesh *m_wield_mesh_next; - u16 m_previous_playeritem; - std::string m_previous_itemname; + 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