Saga
Saga Game Engine
Loading...
Searching...
No Matches
mesh.h
Go to the documentation of this file.
1#pragma once
2#include "Graphics/shape.h"
3#include <glm/vec3.hpp>
4#include <string>
5
6namespace Saga {
11struct Mesh {
12 // these constants need to be in this order, due to how initializing member variables work (since vertexRange depends on attributes)
13 GraphicsEngine::VAOAttrib attributes;
15
20 enum class StandardType {
21 Quad,
22 Cone,
23 Cube,
24 Sphere,
26 };
27
28 std::shared_ptr<GraphicsEngine::Shape> mesh;
29 std::vector<float> data;
30
31 operator const std::shared_ptr<GraphicsEngine::Shape> &() const { return mesh; }
32
37 Mesh();
38
46 Mesh(StandardType type);
47
55 Mesh(const std::string &filepath);
56
62 Mesh(std::vector<float> data, GraphicsEngine::VAOAttrib attributes);
63
64 glm::vec3 getPos(int index);
65 int getTrianglesCnt();
66
71 static auto id_value()
72 -> uint64_t & {
73 static uint64_t the_id;
74 return the_id;
75 }
76
83 static int getVertexRange(GraphicsEngine::VAOAttrib attributes);
84};
85} // namespace Saga
Definition: app.cpp:8
A wrapper around a shared_ptr to a GraphicsEngine's shape.
Definition: mesh.h:11
GraphicsEngine::VAOAttrib attributes
determines what data holds, whether it's position, normal, uv, or color, or any combination of them.
Definition: mesh.h:13
std::vector< float > data
packed vertex data
Definition: mesh.h:29
Mesh()
Construct a new Mesh object.
Definition: mesh.cpp:13
static int getVertexRange(GraphicsEngine::VAOAttrib attributes)
Get the number of floats needed to store a vertex.
Definition: mesh.cpp:60
int vertexRange
how many floats does it take to store 1 vertex. Varies depending on the attributes chosen....
Definition: mesh.h:14
std::shared_ptr< GraphicsEngine::Shape > mesh
Definition: mesh.h:28
int getTrianglesCnt()
Definition: mesh.cpp:56
glm::vec3 getPos(int index)
Definition: mesh.cpp:50
StandardType
Different types of meshes loaded into the graphics engine.
Definition: mesh.h:20
static auto id_value() -> uint64_t &
Used for assigning new shape name in the graphics engine.
Definition: mesh.h:71