15 #ifndef CORGI_COMPONENT_LIBRARY_RENDERMESH_H_
16 #define CORGI_COMPONENT_LIBRARY_RENDERMESH_H_
21 #include "fplbase/asset_manager.h"
22 #include "fplbase/mesh.h"
23 #include "fplbase/renderer.h"
24 #include "fplbase/shader.h"
25 #include "library_components_generated.h"
26 #include "mathfu/constants.h"
27 #include "mathfu/glsl_mappings.h"
28 #include "mathfu/matrix_4x4.h"
31 namespace component_library {
45 tint(mathfu::kOnes4f),
79 mesh = std::move(other.mesh);
80 shaders = std::move(other.shaders);
81 tint = std::move(other.tint);
84 z_depth = std::move(other.z_depth);
87 visible = std::move(other.visible);
92 other.shader_transforms =
nullptr;
93 other.num_shader_transforms = 0;
197 : asset_manager_(nullptr),
252 fplbase::Renderer& renderer);
266 fplbase::Renderer& renderer,
267 size_t shader_index);
316 culling_distance_squared_ = distance * distance;
336 void FinalizeRenderMeshDataIfRequired(
RenderMeshData* rendermesh_data);
342 mathfu::vec3 light_position_;
343 fplbase::AssetManager* asset_manager_;
344 float culling_distance_squared_;
347 std::vector<RenderlistEntry> pass_render_list_[RenderPass_Count];
358 #endif // CORGI_COMPONENT_LIBRARY_RENDERMESH_H_
std::unique_ptr< uint8_t, std::function< void(uint8_t *)> > RawDataUniquePtr
A pointer type for exported raw data.
Definition: component_interface.h:63
float z_depth
The z distance corresponding to the depth of where the Entity should be rendered. ...
Definition: rendermesh.h:115
mathfu::AffineTransform * shader_transforms
A mathfu::AffineTransform array that contains the shader transforms.
Definition: rendermesh.h:141
std::vector< fplbase::Shader * > shaders
A vector of fplbase::Shader for this Entity.
Definition: rendermesh.h:102
static const int kDefaultCullDist
The default distance to start culling.
Definition: rendermesh.h:193
virtual ~RenderMeshComponent()
Destructor for RenderMeshComponent.
Definition: rendermesh.h:201
A Component is an object that encapsulates all data and logic for Entities of a particular type...
Definition: component.h:43
The per-Entity mesh and shader data.
Definition: rendermesh.h:40
RenderlistEntry(EntityRef entity_, RenderMeshData *data_)
Constructor for RenderlistEntry.
Definition: rendermesh.h:155
bool operator<(const RenderlistEntry &other) const
The greater than operator for RenderlistEntry.
Definition: rendermesh.h:172
virtual void UpdateAllEntities(WorldTime)
Nothing happens per frame for these Entities.
Definition: rendermesh.h:228
RenderMeshData & operator=(RenderMeshData &&other)
The move assignment operator for RenderMeshData to avoid reallocating shader transforms.
Definition: rendermesh.h:78
EntityRef entity
The Entity associated with this RenderlistEntry.
Definition: rendermesh.h:159
virtual RawDataUniquePtr ExportRawData(const EntityRef &entity) const
Serializes a RenderMeshComponent's data for a given Entity.
int WorldTime
A typedef that represents time in the game.
Definition: entity_common.h:49
Struct used for keeping track of and sorting our render lists.
Definition: rendermesh.h:153
RenderMeshData()
Default constructor for RenderMeshData.
Definition: rendermesh.h:43
RenderMeshComponent()
Default constructor for RenderMeshComponent.
Definition: rendermesh.h:196
bool operator>(const RenderlistEntry &other) const
The less than operator for RenderlistEntry.
Definition: rendermesh.h:183
virtual void Init()
Initialize the RenderMeshComponent with the AssetManager from the EntityManager.
float culling_distance_squared() const
Get the culling distance squared.
Definition: rendermesh.h:322
bool default_pose
A bool determining if the Entity should be rendered in the default pose.
Definition: rendermesh.h:133
A Component that handles the rendering of each Entities mesh that is registered with this Component...
Definition: rendermesh.h:190
void set_light_position(const mathfu::vec3 &light_position)
Set the light position uniform.
Definition: rendermesh.h:308
virtual void InitEntity(EntityRef &)
Initialize an Entity by also adding it to the TransformComponent.
mathfu::vec3 light_position()
Get the light position uniform.
Definition: rendermesh.h:299
void RenderPrep(const CameraInterface &camera)
Prepares to do rendering.
uint8_t num_shader_transforms
The number of shader transforms in the shader_transforms array.
Definition: rendermesh.h:137
std::vector< std::string > shader_filenames
A std::string of the filenames for the shaders, used for exporting.
Definition: rendermesh.h:111
virtual void AddFromRawData(EntityRef &entity, const void *raw_data)
Deserialize a flat binary buffer to create and populate an Entity from raw data.
~RenderMeshData()
Destructor for RenderMeshData.
Definition: rendermesh.h:58
std::string debug_name
The debug name of this mesh.
Definition: rendermesh.h:144
A reference object for pointing into the vector pool. It acts as a pointer for vector pool elements a...
Definition: vector_pool.h:72
void RenderPass(int pass_id, const CameraInterface &camera, fplbase::Renderer &renderer)
Renders all Entities that are marked as being part of a given render pass to the current output buffe...
void SetCullDistance(float distance)
Set the culling distance.
Definition: rendermesh.h:315
unsigned char pass_mask
A bit field determining during which render passes to render this Entity.
Definition: rendermesh.h:123
void SetVisibilityRecursively(const EntityRef &entity, bool visible)
Recursively sets the visibility of the Entity and all of its children.
An interface for 3D cameras, allowing them to have position, facing field of view, etc. Libraries can use this to pass around generic cameras that the game itself can implement the logic for.
Definition: camera_interface.h:31
std::string mesh_filename
A std::string of the filename for the mesh, used for exporting.
Definition: rendermesh.h:108
void RenderAllEntities(fplbase::Renderer &renderer, const CameraInterface &camera)
Goes through and renders every Entity that is visible from the camera, in pass order.
RenderMeshData(RenderMeshData &&other)
The move constructor for RenderMeshData to avoid reallocating shader transforms.
Definition: rendermesh.h:68
fplbase::Mesh * mesh
The fplbase::Mesh for this Entity.
Definition: rendermesh.h:99
#define CORGI_REGISTER_COMPONENT(ComponentType, DataType)
Definition: component_id_lookup.h:48
unsigned char culling_mask
A bit field determining which types of culling are applied to the Entity.
Definition: rendermesh.h:119
bool visible
A bool determining if this Entity should be rendered.
Definition: rendermesh.h:126
mathfu::vec4 tint
A mathfu::vec4 specifying the tinting for the Entity in RGBA.
Definition: rendermesh.h:105
void set_culling_distance_squared(float culling_distance_squared)
Set the square of the culling distance.
Definition: rendermesh.h:328
RenderMeshData * data
The RenderMeshData associated with the entity in this RenderlistEntry.
Definition: rendermesh.h:163
bool initialized
A bool indicating if this RenderMesh is initialized.
Definition: rendermesh.h:129