Elaztek Developer Hub
Blamite Game Engine - blam!  00423.10.27.24.0533.blamite
The core library for the Blamite Game Engine.
director.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Strings/components/classes/events/events.h>
5 
6 #include <vector>
7 #include <map>
8 
9 #ifndef BLAM
10 #define BLAM
11 #endif
12 
27 class BlamDirector : BlamEventListener
28 {
29 private:
30  bool mouse_capture_state_changed = false;
31  int current_speed_index = 0;
32 
38  std::vector<float> camera_speeds = {
39  1.000000f,
40  5.000000f,
41  20.00000f,
42  40.000000f,
43  100.000000f
44  };
45 
46  int viewport_center_x = 0;
47  int viewport_center_y = 0;
48 
49  bool zoom_state_changed = false;
50  float zoom_increment = 0.0f;
51 
55  std::map<BlamDirection, float> move_accelerations = {
56  std::pair<BlamDirection, float>(BlamDirection::Forward, 0.0f),
57  std::pair<BlamDirection, float>(BlamDirection::Backward, 0.0f),
58  std::pair<BlamDirection, float>(BlamDirection::Left, 0.0f),
59  std::pair<BlamDirection, float>(BlamDirection::Right, 0.0f),
60  std::pair<BlamDirection, float>(BlamDirection::Up, 0.0f),
61  std::pair<BlamDirection, float>(BlamDirection::Down, 0.0f)
62  };
63 
64  std::map<BlamDirection, float> look_accelerations = {
65  std::pair<BlamDirection, float>(BlamDirection::Up, 0.0f),
66  std::pair<BlamDirection, float>(BlamDirection::Down, 0.0f),
67  std::pair<BlamDirection, float>(BlamDirection::Left, 0.0f),
68  std::pair<BlamDirection, float>(BlamDirection::Right, 0.0f)
69  };
70 
71  float accel_increment = 0.0f;
72 
73  int move_finished_tick = -1;
74  bool bounce_needed = false;
75  bool currently_bouncing = false;
76  bool bounceback_done = false;
77  bool bounceforward_done = false;
78 
79 public:
80  BlamVector3 camera_pos = BlamVector3();
81  BlamVector3 camera_angle = BlamVector3();
82 
83  bool auto_verify_coords = true;
84  BlamVector3 camera_front = BlamVector3();
85  BlamVector3 camera_right = BlamVector3();
86 
87  bool mouse_capture_ready = false;
89 
90  bool mouse_captured = false;
91  float fov = 70.0f;
92  float fov_normal = 70.0f;
93  float fov_zoomed = 20.0f;
94  float speed = 1.0f;
95  float zoom_increment_count = 30;
96  bool lock_camera = false;
97  bool pancam = true;
98  bool pancam_lock_xy = false;
99  bool move_acceleration = true;
100  bool look_acceleration = false;
102  bool camera_bouncing = false;
103  bool zoomed = false;
106  bool persistent_look_motion = false;
107  bool tick_based_looking = false;
108 
109  bool calculate_angle = true;
110  float horizontal_angle = 0.0f;
111  float vertical_angle = 0.0f;
112 
114  float far_clip_plane_distance = 100.0f;
115 
119  BlamDirector();
120 
124  ~BlamDirector();
125 
126  void OnNewFrameEvent(NewFrameEvent* event);
127  void OnTickEvent(TickEvent* event);
128  void OnMouseMoveEvent(MouseMoveEvent* event);
129  void OnMouseClickEvent(MouseClickEvent* event);
130  void OnKeyPressEvent(KeyPressEvent* event);
131 
144  void MoveCamera(BlamDirection direction, float acceleration);
145 
153  void ValidateCameraCoords();
154 
160  void SetCameraSpeed(float _speed);
161 };
162 
166 namespace Blam::Director
167 {
171  BLAM void PrepareCamera();
172 
176  BLAM void ShutdownCamera();
177 
184 }
Blam::Director::GetCamera
BLAM BlamDirector * GetCamera()
Retrieves the director instance.
Definition: director.cpp:31
tag_block::entry_size
int entry_size
The size of each block entry.
Definition: tags.h:241
BlamDirector::OnTickEvent
void OnTickEvent(TickEvent *event)
Definition: BlamDirectorCamera.cpp:86
tag_io.h
BlamDirector::mouse_captured
bool mouse_captured
Whether or not the mouse is currently being captured by the camera.
Definition: director.h:90
BlamDirector::BlamDirector
BlamDirector()
Initializes the camera.
Definition: BlamDirectorCamera.cpp:17
BLAM
#define BLAM
Definition: director.h:10
SDLK_w
@ SDLK_w
Definition: SdlEmulationLayer.h:453
tag_block::entry_data_address
void * entry_data_address
The address of the blocks' entry data.
Definition: tags.h:243
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:130
BlamDirector::fov
float fov
The camera's current field of view.
Definition: director.h:91
BlamDirector::far_clip_plane_distance
float far_clip_plane_distance
Definition: director.h:114
tag_block< void >
BlamDirector::camera_angle
BlamVector3 camera_angle
The current looking angle of the camera. X is yaw, Y is pitch, Z is roll (unused atm).
Definition: director.h:81
logger.h
ValidateDynamicTagFolders
void ValidateDynamicTagFolders()
Definition: tags.cpp:29
BlamDirector::zoom_increment_count
float zoom_increment_count
The number of steps/increments to use when zooming in and out. Lower numbers will cause the camera to...
Definition: director.h:95
keyboard.h
Blam::Content::Tags::GetLoadedTags
BLAM std::vector< BlamTagData * > * GetLoadedTags()
Retrieves the list of loaded tag data.
Definition: tags.cpp:156
BlamTagData::path
char path[256]
The tag's path.
Definition: tags.h:143
BlamDirector::mouse_capture_ready
bool mouse_capture_ready
Whether or not the mouse is ready to be captured.
Definition: director.h:87
world.h
SDLK_r
@ SDLK_r
Definition: SdlEmulationLayer.h:448
BlamDirector::OnKeyPressEvent
void OnKeyPressEvent(KeyPressEvent *event)
Definition: BlamDirectorCamera.cpp:458
BlamDirector::near_clip_plane_distance
float near_clip_plane_distance
Definition: director.h:113
BlamDirector::OnNewFrameEvent
void OnNewFrameEvent(NewFrameEvent *event)
Definition: BlamDirectorCamera.cpp:32
BlamDirector::fov_normal
float fov_normal
The camera's default field of view.
Definition: director.h:92
Blam::Content::Tags::GetTagClass
BLAM_EXT_API BlamTagClass * GetTagClass(std::string id)
Retrieves a tag class that matches the given string.
Definition: tagclass.cpp:66
director.h
USER_DATA_PATH
#define USER_DATA_PATH(path)
Macro to quickly access a user data folder.
Definition: config.h:41
SDLK_f
@ SDLK_f
Definition: SdlEmulationLayer.h:436
BlamDirector::vertical_angle
float vertical_angle
Definition: director.h:111
Blam::Input::IsMouseButtonDown
BLAM bool IsMouseButtonDown(uint8_t button)
Checks if a given mouse button is down.
Definition: mouse.cpp:69
Blam::Director::PrepareCamera
BLAM void PrepareCamera()
Prepares the director for use.
Definition: director.cpp:5
BlamDirector::camera_right
BlamVector3 camera_right
The calculated point representing the right of the camera.
Definition: director.h:85
Blam::Content::Tags::GetRegisteredTagClasses
BLAM_EXT_API std::vector< BlamTagClass * > * GetRegisteredTagClasses()
Retrieves the list of all registered tag classes.
Definition: tagclass.cpp:84
BlamDirector::calculate_angle
bool calculate_angle
Definition: director.h:109
BlamDirector::accel_increment_count
float accel_increment_count
The number of steps/increments to use when accelerating and decelerating. Lower numbers will cause th...
Definition: director.h:101
Blam::Director
Namespace for things related to the debug camera (director).
Definition: director.h:166
loaded_tags
std::vector< BlamTagData * > loaded_tags
Definition: tags.cpp:14
SDLK_d
@ SDLK_d
Definition: SdlEmulationLayer.h:434
BlamDirector::horizontal_angle
float horizontal_angle
Definition: director.h:110
BlamTagData::SetTagPath
bool SetTagPath(std::string new_path)
Updates the tag path.
Definition: BlamTagData.cpp:31
BlamTagClass::ShowImPropertyEditor
void ShowImPropertyEditor()
Shows a series of ImGUI controls used to modify tag data with a simple UI.
Definition: BlamTagClass.cpp:13
tag_block::entry_count
int entry_count
The number of entries within the tag block.
Definition: tags.h:244
BlamDirector::move_acceleration
bool move_acceleration
Whether or not camera movements should use acceleration.
Definition: director.h:99
SDLK_LSHIFT
@ SDLK_LSHIFT
Definition: SdlEmulationLayer.h:608
tag_reference
Structure representing a tag reference.
Definition: tags.h:277
BlamTagClass::class_name_long
std::string class_name_long
The longer class name. Typically shown alongside short name for user-friendliness.
Definition: tags.h:196
Blam::Director::ShutdownCamera
BLAM void ShutdownCamera()
Destroys the director and cleans up any data related to it.
Definition: director.cpp:26
BlamDirector::auto_verify_coords
bool auto_verify_coords
Whether or not camera_front and camera_right should be automatically calculated.
Definition: director.h:83
BlamDirector::speed
float speed
The camera's current speed.
Definition: director.h:94
Blam::Content::Tags::GetTagData
BLAM BlamTagData * GetTagData(std::string tag_path)
Retrieves information for a given tag.
Definition: tags.cpp:80
Blam::Content::Tags::ResolveAllTagReferences
BLAM void ResolveAllTagReferences()
Attempts to resolve all tag references within all loaded tags.
Definition: tags.cpp:72
BlamDirector::lock_camera
bool lock_camera
Whether or not the camera is locked. If locked, all keyboard/mouse input is ignored.
Definition: director.h:96
ReleaseTagSectionData
void ReleaseTagSectionData(char *address, int size)
Releases a tag data section.
Definition: tags.cpp:106
BlamDirector::look_acceleration
bool look_acceleration
Whether or not camera looking should use acceleration.
Definition: director.h:100
BlamDirector
Class representing the Director.
Definition: director.h:27
BlamDirector::pancam_lock_xy
bool pancam_lock_xy
Whether or not the camera should be locked to X/Y axis when in pan-cam mode.
Definition: director.h:98
TagOrigin::Memory
@ Memory
Indicates the tag originated from the engine's memory.
engine_definitions.h
tag_reference::data_is_tag
bool data_is_tag
Whether or not tagref_address points to tag data, or the tag's path.
Definition: tags.h:284
BlamDirector::zoomed
bool zoomed
Whether or not the camera is currently zoomed in.
Definition: director.h:103
BlamDirector::camera_bouncing
bool camera_bouncing
Whether or not the camera should have a bounce/rubber effect when moving and looking around.
Definition: director.h:102
registered_classes
std::vector< BlamTagClass * > registered_classes
List of all registered tag classes.
Definition: tagclass.cpp:64
Blam::Content::Tags::RegisterCreatedTag
BLAM bool RegisterCreatedTag(void *tag, std::string tag_class)
Registers a tag created in memory, making it available throughout the engine.
Definition: tags.cpp:41
data_reference::data_address
void * data_address
The address of the referenced data.
Definition: tags.h:327
last_created_tag
int last_created_tag
Definition: tags.cpp:15
BlamDirector::tick_based_looking
bool tick_based_looking
Whether or not camera looking should be driven by the game tick.
Definition: director.h:107
Blam::Input::IsKeyDown
BLAM bool IsKeyDown(SDL_Keycode key)
Checks if a given key is down.
Definition: keyboard.cpp:144
Blam::Content::Tags::LoadReferencedTags
BLAM void LoadReferencedTags(std::string tag_path)
Adds an additional folder to search when attempting to load a tag.
Definition: tag_io.cpp:60
Blam::API::v1::Hooking::GetEngineHookState
BLAM_EXT_API bool GetEngineHookState()
Retrieves the engine's hook state.
Definition: hooking.cpp:14
camera
BlamDirector * camera
Definition: director.cpp:3
BlamDirector::persistent_look_motion
bool persistent_look_motion
Whether or not to use persistent camera look motion. Only applies when using tick based looking.
Definition: director.h:106
data_reference
Structure representing a data reference.
Definition: tags.h:323
BlamTagClass::tag_size
int tag_size
The size of the tag's data. Used on loading/writing tag files.
Definition: tags.h:201
Blam::Logger::LogEventForce
BLAM void LogEventForce(std::string message)
Forcibly logs a message to the log and/or console.
Definition: aliases.cpp:262
BlamDirector::SetCameraSpeed
void SetCameraSpeed(float _speed)
Sets the camera's speed, while also sending a log message indicating that the speed has been changed.
Definition: BlamDirectorCamera.cpp:820
Blam::Content::Tags::CleanupTagData
BLAM void CleanupTagData()
Releases all memory used by tags.
Definition: tags.cpp:135
BlamTagData::address
void * address
The address pointing to the start of the tag's data.
Definition: tags.h:130
Blam::Content::Tags::ShowImPropertyEditor
BLAM void ShowImPropertyEditor(void *tag, std::string tag_class)
Shows an ImGUI editor for a given tag.
Definition: tags.cpp:17
tagclass.h
config.h
tags.h
BlamTagData::origin
TagOrigin origin
The origin of the tag.
Definition: tags.h:145
SDLK_a
@ SDLK_a
Definition: SdlEmulationLayer.h:431
TagOrigin::BinaryFile
@ BinaryFile
Indicates the tag originated from a binary file.
BlamTagData
Class used to contain and access tag data.
Definition: tags.h:124
BlamDirector::pancam
bool pancam
Whether or not the camera is currently in pan-cam mode. Pan-cam locks Z movement of the camera when n...
Definition: director.h:97
BlamDirector::OnMouseClickEvent
void OnMouseClickEvent(MouseClickEvent *event)
Definition: BlamDirectorCamera.cpp:443
BlamTagClass::SetMemoryLocation
void SetMemoryLocation(void *address)
Sets the address and size of the tag that this class should be applied to.
Definition: BlamTagClass.cpp:21
BlamDirector::ValidateCameraCoords
void ValidateCameraCoords()
If auto_verify_coords is set to true, this will verify all camera coordinates.
Definition: BlamDirectorCamera.cpp:758
tag_reference::tagref_address
void * tagref_address
The address of the tagref data.
Definition: tags.h:283
BlamUserDataFolder::Tags
@ Tags
Directory storing user-created tags. Defaults to {DataRoot}/tags/.
ImGui::NewFrame
IMGUI_API void NewFrame()
Definition: imgui.cpp:3689
BlamDirector::OnMouseMoveEvent
void OnMouseMoveEvent(MouseMoveEvent *event)
Definition: BlamDirectorCamera.cpp:357
BlamTagData::size
int size
The size of the tag's data in memory.
Definition: tags.h:131
SDLK_s
@ SDLK_s
Definition: SdlEmulationLayer.h:449
BlamDirector::camera_front
BlamVector3 camera_front
The calculated point representing the front of the camera.
Definition: director.h:84
BlamDirector::mouse_capture_delay_ticks
int mouse_capture_delay_ticks
The remaining number of game ticks to wait before truly capturing the mouse.
Definition: director.h:88
BlamDirector::camera_pos
BlamVector3 camera_pos
The current position of the camera.
Definition: director.h:80
BlamDirector::fov_zoomed
float fov_zoomed
The camera's field of view while zoomed in.
Definition: director.h:93
BlamTagClass
Class representing a tag class.
Definition: tags.h:193
BlamDirector::look_sensetivity_vertical
float look_sensetivity_vertical
The camera's vertical look sensetivity.
Definition: director.h:104
BlamDirector::~BlamDirector
~BlamDirector()
Destroys the camera.
Definition: BlamDirectorCamera.cpp:27
BlamDirector::MoveCamera
void MoveCamera(BlamDirection direction, float acceleration)
Moves the camera one "step" in the given direction.
Definition: BlamDirectorCamera.cpp:473
Blam::GetMainWindowHandle
BLAM SDL_Window * GetMainWindowHandle()
Retrieves the main window handle of the application, when using SDL.
Definition: main.cpp:550
api.h
BlamDirector::look_sensetivity_horizontal
float look_sensetivity_horizontal
The camera's horizontal look sensetivity.
Definition: director.h:105
BlamTagData::tag_class
std::string tag_class
The tag's short class name.
Definition: tags.h:144