9#include "math/matrix_4.h"
10#include "math/vector_3.h"
11#include "sound/soundsource.h"
46 AudioCmp(
const std::string& name,
const SoundBuffer& buffer,
47 float gain = 1.0f,
float pitch = 1.0f)
48 :
src(name, buffer,
coma::Vec3{0.f,0.f,0.f},
coma::Vec3{0.f,0.f,0.f},
55const std::array kAttenuationTable{
74 for (
int next = 0; next < kAttenuationTable.size(); ++next) {
78 (kAttenuationTable[next].x - kAttenuationTable[next - 1].x);
80 kAttenuationTable[next].y, alpha);
82 kAttenuationTable[next].z, alpha);
86 linear_value_ = kAttenuationTable[kAttenuationTable.size() - 1].y;
137 const float max_distance)
151 const float cutoff_angle,
float falloff_start)
191 const float fov = 60.0f,
const float z_near = 0.01f,
192 const float z_far = 1000.0f)
206 const float z_near = 0.01f,
const float z_far = 1000.0f)
211struct RenderTreeCmp {
217 RenderTreeCmp(
const unsigned parent,
const unsigned id,
218 const std::string& editor_name,
219 const std::vector<unsigned>& children = {})
220 : editor_name_(editor_name),
223 children_(children) {}
226 std::string editor_name_ =
"Object";
227 unsigned parent_ = 0;
229 std::vector<unsigned> children_;
265 bool castShadows =
true,
float roughness = 0.5f,
266 float shininess = 32.0f)
273 if (mesh ==
nullptr) {
274 Log::newLog(
"Mesh is Null on Render Component Creation", LogColor::Red);
276 if (texture ==
nullptr) {
277 Log::newLog(
"Texture is Null on Render Component Creation",
319 const coma::Vec3& rotation = {0.0f,180.0f,0.0f},
Handles anything related to entities and components in the engine.
Definition: component_manager.hpp:29
Display and allows to modify entity information in real time.
Definition: editor.hpp:14
Intiliazes the ComponentManager and the ResourceManager and ofers functions to retrieve them.
Definition: engine.hpp:12
static void newLog(std::string text, LogColor textcolor=LogColor::White)
Add a new log entry.
Class used to render the scene.
Definition: renderer.hpp:49
Stores and offers access to all meshes, textures, and sounds of the engine.
Definition: resource_manager.hpp:27
Creates and updates a window.
Definition: window.hpp:20
represents mathematical matrix with 4 cols and 4 rows
Definition: matrix_4.h:11
static Mat4 GetTransform(const Vec3 &translate, const Vec3 &scale, const Vec3 &rotation)
Definition: matrix_4.h:432
static Mat4 Identity()
Definition: matrix_4.h:254
represents mathematical vector with 3 components
Definition: vector_3.h:12
static const Vec3 up
Vec3(0, 1, 0)
Definition: vector_3.h:117
static Vec3 eulerToForward(const Vec3 &a)
Definition: vector_3.h:187
static const Vec3 zero
Vec3(0, 0, 0)
Definition: vector_3.h:129
static Vec3 CrossProduct(const Vec3 &a, const Vec3 &b)
Definition: vector_3.h:155
Vec3 Normalized() const
Definition: vector_3.h:145
CameraProjection
Camera projection modes.
Definition: default_components.hpp:25
@ kOrtho
Renders a 3D scene as 2D without depth.
@ kPerspective
Renders regular 3D using depth.
LightType
Kinds of lights that can be casted.
Definition: default_components.hpp:31
@ kSpot
Emits light in a cone.
Definition of logging functionality.
copperdielf Math Library
Definition: buffer.hpp:5
Component used for audio reproduction.
Definition: default_components.hpp:40
AudioCmp(const std::string &name, const SoundBuffer &buffer, float gain=1.0f, float pitch=1.0f)
Construct an audio component.
Definition: default_components.hpp:46
SoundSource src
Object used to reproduce the audio.
Definition: default_components.hpp:52
Component used to detect collisions.
Definition: default_components.hpp:337
coma::Vec3 size_
Size of the box not affected by the TransformCmp scale.
Definition: default_components.hpp:343
coma::Vec3 position_
Position of the box relative to the TransformCmp position.
Definition: default_components.hpp:340
BoxCmp(const coma::Vec3 &position, const coma::Vec3 &size={1.0f, 1.0f, 1.0f})
Creates a BoxCmp.
Definition: default_components.hpp:348
Component used to render the scene. There must be one and only one of this component on the scene.
Definition: default_components.hpp:161
coma::Vec3 target_
Defines the position the camera will look at if rotate_towards_target_ is set to true.
Definition: default_components.hpp:177
CameraCmp(const CameraProjection projection, const coma::Vec3 &target, const float fov=60.0f, const float z_near=0.01f, const float z_far=1000.0f)
Creates a CameraCmp with rotate_towards_target_ set to true.
Definition: default_components.hpp:190
CameraProjection projection_
Defines the CameraProjection to use.
Definition: default_components.hpp:163
float z_far_
Maximum distance to render.
Definition: default_components.hpp:173
float z_near_
Minimum distance to render.
Definition: default_components.hpp:170
bool rotate_towards_target_
Defines how the rotation of the camera should behave:
Definition: default_components.hpp:182
float fov_
Angular extent of the observable world that is seen at any given moment.
Definition: default_components.hpp:167
CameraCmp(const CameraProjection projection, const float fov=60.0f, const float z_near=0.01f, const float z_far=1000.0f)
Creates a CameraCmp with rotate_towards_target_ set to false.
Definition: default_components.hpp:205
Component used to simulate different types of lights.
Definition: default_components.hpp:69
float quadratic_value_
Can be handled with max_distance_.
Definition: default_components.hpp:109
bool show_shadows_
Define if the light shows shadows.
Definition: default_components.hpp:120
float max_distance_
Distance at which the light intensity will become 0 due to attenuation.
Definition: default_components.hpp:103
LightType type_
Define the light type.
Definition: default_components.hpp:93
void calculateAttenuation()
After modifying max_distance_, this function should be called to update the rest of the parameters re...
Definition: default_components.hpp:73
coma::Vec3 light_color_
Define the color of the light.
Definition: default_components.hpp:95
LightCmp(const LightType type, const coma::Vec3 &color, const float intensity)
Creates a LightCmp of the specified LightType.
Definition: default_components.hpp:129
float falloff_start_
Percentage of the cutoff_angle_ at which the light starts to attenuate.
Definition: default_components.hpp:117
float cutoff_angle_
Radius of the spot light.
Definition: default_components.hpp:114
LightCmp(const coma::Vec3 &color, const float intensity, const float cutoff_angle, float falloff_start)
Creates a kSpot.
Definition: default_components.hpp:150
LightCmp(const coma::Vec3 &color, const float intensity, const float max_distance)
Creates a kPoint.
Definition: default_components.hpp:136
float linear_value_
Can be handled with max_distance_.
Definition: default_components.hpp:107
float intensity_
Define the power of the light.
Definition: default_components.hpp:97
float constant_value_
Can be handled with max_distance_.
Definition: default_components.hpp:105
Component used to render an object.
Definition: default_components.hpp:237
Mesh const * mesh_
Mesh of the object you want to render. Must have a value.
Definition: default_components.hpp:239
RenderCmp(const Mesh *mesh, const Texture *texture, const coma::Vec3 &color={1.0f, 1.0f, 1.0f}, bool castShadows=true, float roughness=0.5f, float shininess=32.0f)
Creates a RenderCmp allowing setting its parameters.
Definition: default_components.hpp:263
Texture const * texture_
Texture of the object. Must have a value.
Definition: default_components.hpp:242
float shininess_
Affects the size and definition of the reflections it receives.
Definition: default_components.hpp:251
coma::Vec3 color_
Color of the object; it will get mixed with the texture.
Definition: default_components.hpp:245
bool cast_shadows_
Defines if the object projects shadows.
Definition: default_components.hpp:254
float roughness_
Affects the intensity of the reflections it receives.
Definition: default_components.hpp:248