Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
teapot.h
1#ifndef OE_SCENE_PRIMITIVE_TEAPOT_H
2#define OE_SCENE_PRIMITIVE_TEAPOT_H
3
4#include "../../lib/teapot.h"
5#include "../loader/bezier.h"
6
8{
12 template <typename VertexType = Vertex>
13 struct Teapot : public Mesh<VertexType>
14 {
15 Teapot(const uint16_t lod = 8)
16 {
17 loader::Bezier<VertexType> bezierLoader(loader::BezierPatchType::Bicubic);
18 std::vector<VertexType> control_points;
19 constexpr const auto patch_size = 16;
20
21 for (uint16_t id_patch = 0; id_patch < teapotNumPatches; ++id_patch)
22 {
23 // Debug to fix normal problem
24 //if (id_patch != 23)
25 // continue;
26
27 for (uint16_t i = 0; i<patch_size; ++i)
28 {
29 const uint16_t id_vertex = teapotPatches[id_patch][i]-1; // Indices of teapot control points begins at 1
30
31 auto teapot_vertex = teapotVertices[id_vertex];
32
33 control_points.push_back({
34 // Note : Y and Z swapped in source date (in Newell times, UP was Z axis whereas in Oxygen Engine we use Y)
35 .position = glm::vec3(teapot_vertex[0], teapot_vertex[2], teapot_vertex[1])
36 });
37 }
38 }
39
40 bezierLoader.setControlPoints(control_points);
41
42 bezierLoader.buildMesh({
43 .lod = lod
44 }, *this);
45 }
46 };
47}
48
49#endif
Definition bezier.h:19
void buildMesh(const BuildMeshInfo &params, BezierMeshType &result)
Build a mesh Bezier surface (using De Casteljau's algorithm)
Definition bezier.h:64
Standard mesh primitives (Cube, Plane, Teapot, etc...)
Definition cube.h:7
Definition mesh.h:61
The Utah teapot.
Definition teapot.h:14