Untitled Game engine no.5  1.0
Mesh.hpp
1 #ifndef MESH_H
2 #define MESH_H
3 #include "pch.hpp"
4 #include "Texture.hpp"
5 
6 namespace Engine {
7  struct Vertex {
9  glm::vec3 pos;
11  glm::vec4 color{1, 1, 1, 1};
13  glm::vec2 tex_pos{};
15  glm::vec2 tex_size{};
17  float tex_id{};
19  glm::mat4 trans{};
20 
21  void print() {
22  std::cout << glm::to_string(pos) << " " << glm::to_string(color)
23  << " " << glm::to_string(tex_pos) << " " << glm::to_string(tex_size)
24  << " " << tex_id << " " << glm::to_string(trans) << std::endl;
25  }
26  };
27  enum Primative {
28  QUAD, CUBE, // SPHERE
29  };
30 
32  struct Mesh {
34  std::vector<Vertex> verts;
35 
36  Mesh() = default;
37  Mesh(std::vector<Vertex> verts);
38 
39  static std::unordered_map<Primative, Ref<Mesh>> primatives;
40  static Ref<Mesh> getPrimative(Primative p);
41 
42  static std::vector<glm::vec3> quadVerts(glm::mat4 tf);
43  static std::vector<Vertex> quad(glm::mat4 tf);
44 
45  static Mesh Quad();
46  static Mesh Cube();
47  };
48 
49 
50 
51 }
52 
53 #endif
Engine::Vertex::color
glm::vec4 color
Color of the vertex.
Definition: Mesh.hpp:11
Engine::Vertex
Definition: Mesh.hpp:7
Engine::Mesh::verts
std::vector< Vertex > verts
Vertices for this mesh.
Definition: Mesh.hpp:34
Engine::Ref
std::shared_ptr< T > Ref
Has stuff for making references a lot more easily shared smart pointer.
Definition: Base.hpp:21
Engine::Vertex::tex_pos
glm::vec2 tex_pos
Texture pos of this vertex.
Definition: Mesh.hpp:13
Engine::Vertex::pos
glm::vec3 pos
Position of the vertex in clip space.
Definition: Mesh.hpp:9
Engine::Vertex::tex_size
glm::vec2 tex_size
Texture size of this vertex.
Definition: Mesh.hpp:15
Engine::Mesh
A set of vertices used for drawing.
Definition: Mesh.hpp:32
Engine
Definition: Animation.hpp:14
Engine::Vertex::trans
glm::mat4 trans
Transform of the mesh.
Definition: Mesh.hpp:19
Engine::Vertex::tex_id
float tex_id
Which texture this uses, 0 is reserved for none.
Definition: Mesh.hpp:17