Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
GTriangleMesh.h
Go to the documentation of this file.
1#pragma once
2
5#include "SDL/sdl_interface.h"
6
7#include <vector>
8
9namespace ph
10{
11
17class GTriangleMesh : public Geometry
18{
19public:
21
23 std::vector<math::Vector3R> positions,
24 std::vector<math::Vector3R> texCoords,
25 std::vector<math::Vector3R> normals);
26
27 void storeCooked(
28 CookedGeometry& out_geometry,
29 const CookingContext& ctx) const override;
30
31 void genPrimitive(
32 const PrimitiveBuildingMaterial& data,
33 std::vector<std::unique_ptr<Primitive>>& out_primitives) const override;
34
35 std::shared_ptr<Geometry> genTransformed(
36 const math::StaticAffineTransform& transform) const override;
37
38 std::vector<GTriangle> genTriangles() const;
39 void addTriangle(const GTriangle& gTriangle);
40
41private:
42 std::vector<math::Vector3R> m_positions;
43 std::vector<math::Vector3R> m_texCoords;
44 std::vector<math::Vector3R> m_normals;
45
46public:
48 {
49 ClassType clazz("triangle-mesh");
50 clazz.docName("Triangle Mesh");
51 clazz.description("A cluster of triangles forming a singe shape in 3-D space.");
52 clazz.baseOn<Geometry>();
53
54 TSdlVector3Array<OwnerType> positions("positions", &OwnerType::m_positions);
55 positions.description(
56 "Vertex coordinates of all triangles. Every three vector3s in the array represents "
57 "a single triangle. The vertices are expected to be given in counterclockwise order.");
58 positions.required();
59 clazz.addField(positions);
60
61 TSdlVector3Array<OwnerType> texCoords("texture-coordinates", &OwnerType::m_texCoords);
62 texCoords.description(
63 "Similar to positions, except that the array stores texture coordinates for each triangle.");
64 texCoords.optional();
65 clazz.addField(texCoords);
66
67 TSdlVector3Array<OwnerType> normals("normals", &OwnerType::m_normals);
68 normals.description(
69 "Similar to positions, except that the array stores normal vectors for each triangle.");
70 normals.optional();
71 clazz.addField(normals);
72
73 return clazz;
74 }
75};
76
77}// end namespace ph
Definition CookedGeometry.h:13
Information about the world being cooked.
Definition CookingContext.h:24
Definition GTriangle.h:13
Basic triangle mesh.
Definition GTriangleMesh.h:18
void genPrimitive(const PrimitiveBuildingMaterial &data, std::vector< std::unique_ptr< Primitive > > &out_primitives) const override
Definition GTriangleMesh.cpp:39
void storeCooked(CookedGeometry &out_geometry, const CookingContext &ctx) const override
Store data suitable for rendering into out_geometry.
Definition GTriangleMesh.cpp:28
std::vector< GTriangle > genTriangles() const
Definition GTriangleMesh.cpp:50
void addTriangle(const GTriangle &gTriangle)
Definition GTriangleMesh.cpp:116
GTriangleMesh()
Definition GTriangleMesh.cpp:12
PH_DEFINE_SDL_CLASS(TSdlOwnerClass< GTriangleMesh >)
Definition GTriangleMesh.h:47
std::shared_ptr< Geometry > genTransformed(const math::StaticAffineTransform &transform) const override
Definition GTriangleMesh.cpp:102
Definition Geometry.h:21
Definition PrimitiveBuildingMaterial.h:11
SDL binding type for a canonical SDL resource class.
Definition TSdlOwnerClass.h:23
Definition TSdlVector3Array.h:21
Definition StaticAffineTransform.h:14
The root for all renderer implementations.
Definition EEngineProject.h:6