Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
plane.h
1#ifndef OE_SCENE_PRIMITIVE_PLANE_H
2#define OE_SCENE_PRIMITIVE_PLANE_H
3
4#include "../mesh.h"
5
7{
13 template <typename VertexType = Vertex>
14 struct Plane : public Mesh<VertexType>
15 {
20 {
21 /*
22 Vertices are layed like this :
23 (view from above)
24
25 ^
26 X
27 0 1
28 2 3
29 O Z >
30
31 We will draw the plane as 2 triangles 021 and 123
32 */
33
34 auto& vertices = Mesh<VertexType>::vertices;
35 auto& indices = Mesh<VertexType>::indices;
36 auto& primitives = Mesh<VertexType>::primitives;
37
38 vertices =
39 {
40 {.position = glm::vec3( 0.5f, 0.f, -0.5f), .tex_coords_0 = glm::vec2(0.f, 0.f), .normal = glm::vec3( 0.f, 1.f, 0.f)},
41 {.position = glm::vec3( 0.5f, 0.f, 0.5f), .tex_coords_0 = glm::vec2(1.f, 0.f), .normal = glm::vec3( 0.f, 1.f, 0.f)},
42 {.position = glm::vec3(-0.5f, 0.f, -0.5f), .tex_coords_0 = glm::vec2(0.f, 1.f), .normal = glm::vec3( 0.f, 1.f, 0.f)},
43 {.position = glm::vec3(-0.5f, 0.f, 0.5f), .tex_coords_0 = glm::vec2(1.f, 1.f), .normal = glm::vec3( 0.f, 1.f, 0.f)},
44 };
45
46 indices = {{
47 0, 2, 1, // Up-left triangle
48 1, 2, 3 // lower-right triangle
49 }};
50
51 primitives = {{0, indices.size()}};
52
53 if constexpr (IsVertexWithTangents<Vertex>)
54 {
56 }
57 }
58 };
59}
60
61#endif
Definition vertex.h:39
Standard mesh primitives (Cube, Plane, Teapot, etc...)
Definition cube.h:7
Definition mesh.h:61
constexpr void generateTangents()
Compute Tangents using mikkTSpace.
Definition mesh.h:340
A plane mesh from (-0.5f, -0.5f) to (0.5f, 0.5f) facing Y upward so you can use it as a simple floor.
Definition plane.h:15
Plane()
Definition plane.h:19