Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
FrameVisualizer.h
Go to the documentation of this file.
1#pragma once
2
4#include "Math/TVector2.h"
6#include "SDL/sdl_interface.h"
7
8#include <Common/primitive_type.h>
9
10#include <optional>
11
12namespace ph
13{
14
16{
17public:
18 void cook(const CoreCookingContext& ctx, CoreCookedUnit& cooked) override = 0;
19
20 std::optional<math::TAABB2D<int64>> getCropWindowPx() const;
21
22private:
23 int64 m_cropWindowXPx;
24 int64 m_cropWindowYPx;
25 int64 m_cropWindowWPx;
26 int64 m_cropWindowHPx;
27
28public:
30 {
31 ClassType clazz("frame");
32 clazz.docName("Frame Visualizer");
33 clazz.description("A visualizer that produces frames, a typical example is an image.");
34 clazz.baseOn<Visualizer>();
35
36 TSdlInt64<OwnerType> cropWindowXPx("rect-x", &OwnerType::m_cropWindowXPx);
37 cropWindowXPx.description("X coordinate of the lower-left corner of the film cropping window.");
38 cropWindowXPx.defaultTo(0);
39 cropWindowXPx.optional();
40 clazz.addField(cropWindowXPx);
41
42 TSdlInt64<OwnerType> cropWindowYPx("rect-y", &OwnerType::m_cropWindowYPx);
43 cropWindowYPx.description("Y coordinate of the lower-left corner of the film cropping window.");
44 cropWindowYPx.defaultTo(0);
45 cropWindowYPx.optional();
46 clazz.addField(cropWindowYPx);
47
48 TSdlInt64<OwnerType> cropWindowWPx("rect-w", &OwnerType::m_cropWindowWPx);
49 cropWindowWPx.description("Width of the film cropping window.");
50 cropWindowWPx.defaultTo(0);
51 cropWindowWPx.optional();
52 clazz.addField(cropWindowWPx);
53
54 TSdlInt64<OwnerType> cropWindowHPx("rect-h", &OwnerType::m_cropWindowHPx);
55 cropWindowHPx.description("Height of the film cropping window.");
56 cropWindowHPx.defaultTo(0);
57 cropWindowHPx.optional();
58 clazz.addField(cropWindowHPx);
59
60 return clazz;
61 }
62};
63
64// In-header Implementations:
65
66inline std::optional<math::TAABB2D<int64>> FrameVisualizer::getCropWindowPx() const
67{
68 if(m_cropWindowXPx == 0 && m_cropWindowYPx == 0 &&
69 m_cropWindowWPx == 0 && m_cropWindowHPx == 0)
70 {
71 return std::nullopt;
72 }
73 else
74 {
76 {m_cropWindowXPx, m_cropWindowYPx},
77 {m_cropWindowXPx + m_cropWindowWPx, m_cropWindowYPx + m_cropWindowHPx});
78 }
79}
80
81}// end namespace ph
Definition CoreCookedUnit.h:19
Definition CoreCookingContext.h:15
Definition FrameVisualizer.h:16
void cook(const CoreCookingContext &ctx, CoreCookedUnit &cooked) override=0
std::optional< math::TAABB2D< int64 > > getCropWindowPx() const
Definition FrameVisualizer.h:66
PH_DEFINE_SDL_CLASS(TSdlOwnerClass< FrameVisualizer >)
Definition FrameVisualizer.h:29
A field class that binds a integral member variable.
Definition TSdlInteger.h:21
SDL binding type for a canonical SDL resource class.
Definition TSdlOwnerClass.h:23
TSdlValue & description(std::string descriptionStr)
Definition TSdlValue.ipp:95
TSdlValue & optional()
Definition TSdlValue.ipp:103
TSdlValue & defaultTo(T defaultValue)
Definition TSdlValue.ipp:71
Definition Visualizer.h:10
A 2-D Axis-Aligned Bounding Box (AABB).
Definition TAABB2D.h:26
The root for all renderer implementations.
Definition EEngineProject.h:6