WiP for geometry handling

This commit is contained in:
Hartmut Seichter 2024-07-23 23:52:22 +02:00
parent a4bb53ce8f
commit 9cb55edbb4
2 changed files with 22 additions and 12 deletions

View file

@ -20,8 +20,8 @@
* SOFTWARE.
*
*/
#ifndef PW_CORE_GEOMETRY_HPP
#define PW_CORE_GEOMETRY_HPP
#ifndef PW_CORE_PRIMITIVES_HPP
#define PW_CORE_PRIMITIVES_HPP
#include <pw/core/aabb.hpp>
#include <pw/core/globals.hpp>
@ -31,13 +31,13 @@
namespace pw {
struct geometry {
struct primitives {
enum struct topology_type {
point_list,
line_list,
line_strip,
triange_list,
triangle_list,
triangle_strip,
triangle_fan,
line_list_with_adjacency,

View file

@ -1,7 +1,6 @@
#include <cstdint>
#include <pw/core/axisangle.hpp>
#include <pw/core/geometry.hpp>
#include <pw/core/matrix_transform.hpp>
#include <pw/core/primitives.hpp>
#include <pw/core/serialize.hpp>
#include <pw/core/vector.hpp>
@ -29,21 +28,32 @@ struct attribute final {
texture_coordinates,
};
using data_type = std::tuple<attribute_type,attribute_data>;
attribute_type type{};
attribute_data data{};
};
struct mesh_n {
geometry data{};
primitives geometry{};
std::vector<attribute> attributes;
};
} // namespace pw
auto main() -> int {
auto geom = pw::geometry{.vertices = {{1.2f, 2.4f, 4.8f},
{2.4f, 1.2f, 4.8f},
{1.2f, 4.8f, 2.4f}},
.indices = {0, 1, 2}};
auto geom = pw::primitives{
.vertices = {{1.2f, 2.4f, 4.8f},
{2.4f, 1.2f, 4.8f},
{1.2f, 4.8f, 2.4f}},
.indices = {0, 1, 2},
.topology = pw::primitives::topology_type::triangle_list};
auto mesh = pw::mesh_n{.geometry = geom};
mesh.attributes.emplace_back(
pw::attribute{.type = pw::attribute::normals,
.data = std::vector{
pw::vector{1.2f, 2.4f, 4.8f}}});
for (auto i : geom.indices) {
std::print("({}) ", pw::serialize::to_string(geom.vertices[i]));