Files
RedScarfEngine/graphics/src/mesh_controller.h
T
Piotr Krygier bf31b96a2e Add my own math library
GLM works only for C++ and I plan on moving to back to C. There is
a C port, but it would be good for me to figure out vertex math myself.
Hence, my own library has been created.
2023-08-10 09:43:26 +02:00

63 lines
1.5 KiB
C++

/**
* @file mesh_controller.h
* @author Piotr Krygier (piotr.krygier@meshsystems.com)
* @brief
* @version 0.1
* @date 2023-03-29
*
* @copyright Copyright (c) 2023
*
*/
#ifndef RSE_MESH_CONTROLLER_H
#define RSE_MESH_CONTROLLER_H
#include "vulkan_commons.h"
#include <map>
#include <vector>
#include <cstdint>
#include <memory>
/* Forward declarations */
struct MeshInstance;
struct MeshInstance
{
uint32_t instance_id;
InstanceData instance_data;
};
struct Mesh
{
uint32_t unique_id;
const std::vector<Vertex> vertices;
std::vector<uint16_t> indices;
std::map<uint16_t, std::unique_ptr<MeshInstance>> instances;
};
/**
* @brief Create a new mesh for provided vertices and indices.
*
* @param vertices vector of vertices
* @param indices indices for mesh
* @return uint16_t Mesh identifier. Can be useful for getting vertices, indices and instances
*/
uint16_t create_mesh(std::vector<Vertex> vertices,
std::vector<uint16_t> indices);
/**
* @brief Create a instance for the selected mesh. Instance can have its own location, rotation and scale
*
* @param mesh_id Mesh id
* @param instance_data Transformation info
*/
void create_mesh_instance(uint16_t mesh_id,
InstanceData instance_data);
std::vector<Vertex> get_mesh_vertices(uint16_t mesh_id);
std::vector<uint16_t> get_mesh_indices(uint16_t mesh_id);
std::vector<InstanceData> get_instance_data_for_mesh(uint16_t mesh_id);
#endif /* RSE_MESH_CONTROLLER_H */