Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
OrientedRasterObserver.h
Go to the documentation of this file.
1#pragma once
2
4#include "SDL/sdl_interface.h"
5#include "Math/TVector2.h"
6#include "Math/TVector3.h"
7#include "Math/TQuaternion.h"
9
10#include <Common/assertion.h>
11#include <Common/primitive_type.h>
12
13#include <optional>
14
15namespace ph
16{
17
19{
20public:
21 inline OrientedRasterObserver() = default;
22
23 void cook(const CoreCookingContext& ctx, CoreCookedUnit& cooked) override = 0;
24
25protected:
27 math::Vector3D makePos() const;
29 math::Vector3D makeDir() const;
30
31private:
32 math::Vector3R m_pos;
33 math::Vector3R m_yawPitchRollDegrees;
34
35 std::optional<math::Vector3R> m_dir;
36 std::optional<math::Vector3R> m_upAxis;
37
38 static math::QuaternionD makeRotFromVectors(const math::Vector3R& direction, const math::Vector3R& upAxis);
39 static math::QuaternionD makeRotFromYawPitchRoll(real yawDegrees, real pitchDegrees, real rollDegrees);
40
41public:
43 {
44 ClassType clazz("oriented-raster");
45 clazz.docName("Oriented Raster Observer");
46 clazz.description(
47 "Observers that work by projecting incoming energy in certain ways. "
48 "Projective observers face the -z axis (+y up) and reside on (0, 0, 0) by default.");
49 clazz.baseOn<Observer>();
50
51 TSdlVector3<OwnerType> pos("pos", &OwnerType::m_pos);
52 pos.description("Position of the observer.");
53 pos.defaultTo({0, 0, 0});
54 clazz.addField(pos);
55
56 TSdlVector3<OwnerType> yawPitchRollDegrees("yaw-pitch-row-degrees", &OwnerType::m_yawPitchRollDegrees);
57 yawPitchRollDegrees.description(
58 "Direction that this observer is looking at in yaw pitch form. "
59 "yaw: Rotation around +y axis in [-180, 180]; "
60 "pitch: Declination from the horizon in [-90, 90]; "
61 "row: Rotation around +z axis in [-180, 180].");
62 yawPitchRollDegrees.defaultTo({0, 0, 0});
63 yawPitchRollDegrees.optional();
64 clazz.addField(yawPitchRollDegrees);
65
66 TSdlOptionalVector3<OwnerType> dir("dir", &OwnerType::m_dir);
67 dir.description("Direction vector that this observer is looking at. No need to be normalized.");
68 clazz.addField(dir);
69
70 TSdlOptionalVector3<OwnerType> upAxis("up-axis", &OwnerType::m_upAxis);
71 upAxis.description("The direction vector that this observer consider as upward. No need to be normalized.");
72 clazz.addField(upAxis);
73
74 return clazz;
75 }
76};
77
78}// end namespace ph
Definition CoreCookedUnit.h:19
Definition CoreCookingContext.h:15
Definition Observer.h:12
Definition OrientedRasterObserver.h:19
math::TDecomposedTransform< float64 > makeObserverPose() const
Definition OrientedRasterObserver.cpp:12
math::QuaternionD makeRot() const
Definition OrientedRasterObserver.cpp:25
void cook(const CoreCookingContext &ctx, CoreCookedUnit &cooked) override=0
PH_DEFINE_SDL_CLASS(TSdlOwnerClass< OrientedRasterObserver >)
Definition OrientedRasterObserver.h:42
math::Vector3D makeDir() const
Definition OrientedRasterObserver.cpp:43
math::Vector3D makePos() const
Definition OrientedRasterObserver.cpp:20
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 TSdlVector3.h:19
Perform affine transformations in decomposed form.
Definition TDecomposedTransform.h:24
Represents a quaternion.
Definition TQuaternion.h:17
Represents a 3-D vector.
Definition TVector3.h:17
The root for all renderer implementations.
Definition EEngineProject.h:6