Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
GSphere.h
Go to the documentation of this file.
1#pragma once
2
4#include "Math/TVector3.h"
5#include "SDL/sdl_interface.h"
6
7#include <Common/primitive_type.h>
8
9#include <vector>
10
11namespace ph
12{
13
14class GTriangleMesh;
15
16class GSphere : public Geometry
17{
18public:
19 void storeCooked(
20 CookedGeometry& out_geometry,
21 const CookingContext& ctx) const override;
22
23 void genPrimitive(
24 const PrimitiveBuildingMaterial& data,
25 std::vector<std::unique_ptr<Primitive>>& out_primitives) const override;
26
27 std::shared_ptr<Geometry> genTransformed(
28 const math::StaticAffineTransform& transform) const override;
29
30 GSphere& setRadius(real radius);
31
32private:
33 real m_radius;
34
35 std::size_t addVertex(const math::Vector3R& vertex, std::vector<math::Vector3R>* const out_vertices) const;
36 std::size_t addMidpointVertex(const std::size_t iA, const std::size_t iB, std::vector<math::Vector3R>* const out_vertices) const;
37 std::shared_ptr<GTriangleMesh> genTriangleMesh() const;
38
39public:
41 {
42 ClassType clazz("sphere");
43 clazz.docName("Spherical Geometry");
44 clazz.description("A perfectly round shape centering around origin.");
45 clazz.baseOn<Geometry>();
46
47 TSdlReal<OwnerType> radius("radius", &OwnerType::m_radius);
48 radius.description("Size of the sphere.");
49 radius.defaultTo(1);
50 clazz.addField(radius);
51
52 return clazz;
53 }
54};
55
56}// end namespace ph
Definition CookedGeometry.h:13
Information about the world being cooked.
Definition CookingContext.h:24
Definition GSphere.h:17
void storeCooked(CookedGeometry &out_geometry, const CookingContext &ctx) const override
Store data suitable for rendering into out_geometry.
Definition GSphere.cpp:32
GSphere & setRadius(real radius)
Definition GSphere.cpp:69
PH_DEFINE_SDL_CLASS(TSdlOwnerClass< GSphere >)
Definition GSphere.h:40
std::shared_ptr< Geometry > genTransformed(const math::StaticAffineTransform &transform) const override
Definition GSphere.cpp:63
void genPrimitive(const PrimitiveBuildingMaterial &data, std::vector< std::unique_ptr< Primitive > > &out_primitives) const override
Definition GSphere.cpp:47
Definition Geometry.h:21
Definition PrimitiveBuildingMaterial.h:11
SDL binding type for a canonical SDL resource class.
Definition TSdlOwnerClass.h:23
A field class that binds a floating point member variable.
Definition TSdlReal.h:21
Definition StaticAffineTransform.h:14
The root for all renderer implementations.
Definition EEngineProject.h:6