Files
RedScarfEngine/graphics/src/mesh_controller.hpp
T
Piotr Krygier 6781c1cff1 Remove VulkanState dependency
Passing VulkanState everywhere (including windowLoop) made no sense.
I know that "globals are evil", but this is the best solution for now.
2023-04-04 15:27:42 +02:00

71 lines
1.6 KiB
C++

/**
* @file mesh_controller.hpp
* @author Piotr Krygier (piotr.krygier@meshsystems.com)
* @brief
* @version 0.1
* @date 2023-03-29
*
* @copyright Copyright (c) 2023
*
*/
#ifndef RSE_MESH_CONTROLLER_HPP
#define RSE_MESH_CONTROLLER_HPP
#include <cstdint>
#include <memory>
#include <vector>
#include <map>
#include "vulkan_commons.hpp"
namespace rse::graphics::mesh
{
/* Forward declarations */
struct MeshInstance;
struct MeshInstance
{
uint32_t instance_id;
InstanceData instance_data;
};
struct Mesh
{
uint32_t unique_id;
const std::vector<rse::graphics::vulkanbase::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<rse::graphics::vulkanbase::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<rse::graphics::vulkanbase::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);
} // namespace rse::graphics::mesh
#endif