Photon Editor Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ObjectTransform.h
Go to the documentation of this file.
1#pragma once
2
3#include <Math/TVector3.h>
4#include <Math/TQuaternion.h>
5#include <Math/Transform/TDecomposedTransform.h>
6#include <Common/primitive_type.h>
7#include <SDL/sdl_interface.h>
8
9namespace ph::math { class StaticAffineTransform; }
10namespace ph::math { class StaticRigidTransform; }
11
12namespace ph::editor
13{
14
15class ObjectTransform final
16{
17public:
18 ObjectTransform& setPos(real x, real y, real z);
19 ObjectTransform& setPos(const math::Vector3R& pos);
20 ObjectTransform& setRot(const math::Vector3R& axis, real degrees);
21 ObjectTransform& setRot(const math::QuaternionR& rot);
22 ObjectTransform& setScale(real uniformScale);
23 ObjectTransform& setScale(real x, real y, real z);
24 ObjectTransform& setScale(const math::Vector3R& scale);
25
26 ObjectTransform& translate(real amountX, real amountY, real amountZ);
27 ObjectTransform& translate(const math::Vector3R& amount);
28 ObjectTransform& rotate(const math::Vector3R& axis, real additionalDegrees);
29 ObjectTransform& rotate(const math::QuaternionR& additionalRotation);
30 ObjectTransform& scale(real uniformAmount);
31 ObjectTransform& scale(real amountX, real amountY, real amountZ);
32 ObjectTransform& scale(const math::Vector3R& amount);
33
34 math::Vector3R getPos() const;
35 math::QuaternionR getRot() const;
36 math::Vector3R getScale() const;
37
38 math::TDecomposedTransform<real> getDecomposed() const;
39 math::StaticAffineTransform getForwardStaticAffine() const;
40 math::StaticAffineTransform getInverseStaticAffine() const;
41 math::StaticRigidTransform getForwardStaticRigid() const;
42 math::StaticRigidTransform getInverseStaticRigid() const;
43 ObjectTransform& set(const math::TDecomposedTransform<real>& decomposed);
44
45private:
46 math::Vector3R m_pos;
47 math::QuaternionR m_rot;
48 math::Vector3R m_scale;
49
50public:
51 PH_DEFINE_SDL_STRUCT(TSdlOwnerStruct<ObjectTransform>)
52 {
53 StructType ztruct("obj-transform");
54 ztruct.description("Data structure describing placement of an object in the virtual world.");
55
56 TSdlVector3<OwnerType> pos("pos", &OwnerType::m_pos);
57 pos.description("Position of the object.");
58 pos.optional();
59 pos.defaultTo({0, 0, 0});
60 ztruct.addField(pos);
61
62 TSdlQuaternion<OwnerType> rot("rot", &OwnerType::m_rot);
63 rot.description("Rotation of the object");
64 rot.optional();
65 rot.defaultTo(math::QuaternionR::makeNoRotation());
66 ztruct.addField(rot);
67
68 TSdlVector3<OwnerType> scale("scale", &OwnerType::m_scale);
69 scale.description("Scale of the object.");
70 scale.optional();
71 scale.defaultTo({1, 1, 1});
72 ztruct.addField(scale);
73
74 return ztruct;
75 }
76};
77
78}// end namespace ph::editor
Definition ObjectTransform.h:16
ObjectTransform & scale(real uniformAmount)
Definition ObjectTransform.cpp:72
ObjectTransform & rotate(const math::Vector3R &axis, real additionalDegrees)
Definition ObjectTransform.cpp:61
PH_DEFINE_SDL_STRUCT(TSdlOwnerStruct< ObjectTransform >)
Definition ObjectTransform.h:51
math::TDecomposedTransform< real > getDecomposed() const
Definition ObjectTransform.cpp:102
math::StaticAffineTransform getForwardStaticAffine() const
Definition ObjectTransform.cpp:110
math::StaticRigidTransform getInverseStaticRigid() const
Definition ObjectTransform.cpp:125
ObjectTransform & setScale(real uniformScale)
Definition ObjectTransform.cpp:34
ObjectTransform & setRot(const math::Vector3R &axis, real degrees)
Definition ObjectTransform.cpp:21
math::QuaternionR getRot() const
Definition ObjectTransform.cpp:92
ObjectTransform & set(const math::TDecomposedTransform< real > &decomposed)
Definition ObjectTransform.cpp:130
math::Vector3R getScale() const
Definition ObjectTransform.cpp:97
math::StaticAffineTransform getInverseStaticAffine() const
Definition ObjectTransform.cpp:115
math::StaticRigidTransform getForwardStaticRigid() const
Definition ObjectTransform.cpp:120
math::Vector3R getPos() const
Definition ObjectTransform.cpp:87
ObjectTransform & translate(real amountX, real amountY, real amountZ)
Definition ObjectTransform.cpp:51
ObjectTransform & setPos(real x, real y, real z)
Definition ObjectTransform.cpp:9
Definition ph_editor.h:10
Definition ObjectTransform.h:9