Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
GRectangle.h
Go to the documentation of this file.
1#pragma once
2
4#include "SDL/sdl_interface.h"
5
6#include <Common/primitive_type.h>
7
8namespace ph
9{
10
11class GTriangleMesh;
12
13class GRectangle : public Geometry
14{
15public:
16 void storeCooked(
17 CookedGeometry& out_geometry,
18 const CookingContext& ctx) const override;
19
20 void genPrimitive(
21 const PrimitiveBuildingMaterial& data,
22 std::vector<std::unique_ptr<Primitive>>& out_primitives) const override;
23
24 std::shared_ptr<Geometry> genTransformed(
25 const math::StaticAffineTransform& transform) const override;
26
27 GRectangle& setWidth(real width);
28 GRectangle& setHeight(real height);
29 GRectangle& setTexCoordScale(const real scale);
30
31private:
32 real m_width;
33 real m_height;
34 real m_texCoordScale;
35
36 std::shared_ptr<GTriangleMesh> genTriangleMesh() const;
37
38 static bool checkData(const PrimitiveBuildingMaterial& data, const real width, const real height);
39 static bool checkData(real width, real height);
40
41public:
43 {
44 ClassType clazz("rectangle");
45 clazz.docName("Rectangular Geometry");
46 clazz.description("A rectangular shape on xy-plane. It is centered around origin.");
47 clazz.baseOn<Geometry>();
48
49 TSdlReal<OwnerType> width("width", &OwnerType::m_width);
50 width.description("Width of the rectangle.");
51 width.defaultTo(1);
52 clazz.addField(width);
53
54 TSdlReal<OwnerType> height("height", &OwnerType::m_height);
55 height.description("Height of the rectangle.");
56 height.defaultTo(1);
57 clazz.addField(height);
58
59 TSdlReal<OwnerType> texCoordScale("texcoord-scale", &OwnerType::m_texCoordScale);
60 texCoordScale.description("A scaling factor that scales the default-generated texture coordinates.");
61 texCoordScale.defaultTo(1);
62 texCoordScale.optional();
63 clazz.addField(texCoordScale);
64
65 return clazz;
66 }
67};
68
69}// end namespace ph
Definition CookedGeometry.h:13
Information about the world being cooked.
Definition CookingContext.h:24
Definition GRectangle.h:14
GRectangle & setTexCoordScale(const real scale)
Definition GRectangle.cpp:60
GRectangle & setWidth(real width)
Definition GRectangle.cpp:46
std::shared_ptr< Geometry > genTransformed(const math::StaticAffineTransform &transform) const override
Definition GRectangle.cpp:40
PH_DEFINE_SDL_CLASS(TSdlOwnerClass< GRectangle >)
Definition GRectangle.h:42
void storeCooked(CookedGeometry &out_geometry, const CookingContext &ctx) const override
Store data suitable for rendering into out_geometry.
Definition GRectangle.cpp:16
GRectangle & setHeight(real height)
Definition GRectangle.cpp:53
void genPrimitive(const PrimitiveBuildingMaterial &data, std::vector< std::unique_ptr< Primitive > > &out_primitives) const override
Definition GRectangle.cpp:28
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
TSdlValue & description(std::string descriptionStr)
Definition TSdlValue.ipp:95
TSdlValue & optional()
Definition TSdlValue.ipp:103
TSdlValue & defaultTo(T defaultValue)
Definition TSdlValue.ipp:71
Definition StaticAffineTransform.h:14
The root for all renderer implementations.
Definition EEngineProject.h:6