t
Loading...
Searching...
No Matches
Plane.hpp
1#include "geometries/Geometry.hpp"
2
3#ifndef PLANE_HPP
4#define PLANE_HPP
5
6namespace t {
7
16#define halfWidth width / 2
17#define halfHeight height / 2
18
19#define vertexBuffer \
20 { \
21 halfWidth, halfHeight, 0, /* v0 */ \
22 -halfWidth, halfHeight, 0, /* v1 */ \
23 -halfWidth, -halfHeight, 0, /* v2 */ \
24 halfWidth, -halfHeight, 0, /* v3 */ \
25 }
26
27#define indexBuffer {0, 1, 3, 3, 1, 2}
28#define normalBuffer {0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1}
29
38class Plane : public Geometry {
39public:
50 Plane(double width, double height)
51 : Geometry(BufferAttribute<double>(vertexBuffer, 3),
52 BufferAttribute<double>(normalBuffer, 3)) {
53 setIndices(BufferAttribute<int>(indexBuffer, 3));
54 }
55};
56
57#undef vertexBuffer
58#undef indexBuffer
59#undef normalBuffer
60#undef halfWidth
61#undef halfHeight
62
63} // namespace t
64
65#endif // PLANE_HPP
A class representing attributes, such as vertex positions, face indices, and vertex normals.
Definition BufferAttribute.hpp:27
The base 3D geometry class.
Definition Geometry.hpp:37
void setIndices(BufferAttribute< int > _faceIndices)
Sets the index buffer of this geometry.
Definition Geometry.hpp:93
The geometry of a flat, depth-less plane.
Definition Plane.hpp:38
Plane(double width, double height)
Creates a new plane geometry with the specified width and height centered on the origin and faces tow...
Definition Plane.hpp:50
The t software 3D graphics library namespace.
Definition algorithms.hpp:12