Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
TransformInterface.inl
Go to the documentation of this file.
1/*
2Copyright (c) 2018 DIVIDE-Studio
3Copyright (c) 2009 Ionut Cava
4
5This file is part of DIVIDE Framework.
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software
9and associated documentation files (the "Software"), to deal in the Software
10without restriction,
11including without limitation the rights to use, copy, modify, merge, publish,
12distribute, sublicense,
13and/or sell copies of the Software, and to permit persons to whom the
14Software is furnished to do so,
15subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED,
22INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23PARTICULAR PURPOSE AND NONINFRINGEMENT.
24IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25DAMAGES OR OTHER LIABILITY,
26WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27IN CONNECTION WITH THE SOFTWARE
28OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30*/
31
32#pragma once
33#ifndef DVD_TRANSFORM_INTERFACE_INL_
34#define DVD_TRANSFORM_INTERFACE_INL_
35
36namespace Divide
37{
38 inline bool operator==( const TransformValues& lhs, const TransformValues& rhs )
39 {
40 return lhs._scale.compare( rhs._scale ) &&
43 }
44
45 inline bool operator!=( const TransformValues& lhs, const TransformValues& rhs )
46 {
47 return !lhs._scale.compare( rhs._scale ) ||
48 !lhs._orientation.compare( rhs._orientation ) ||
50 }
51
52 inline TransformValues Lerp( const TransformValues& a, const TransformValues& b, const F32 t )
53 {
54 return TransformValues
55 {
57 ._translation = Lerp( a._translation, b._translation, t ),
58 ._scale = Lerp( a._scale, b._scale, t )
59 };
60 }
61
62 inline mat4<F32> GetMatrix( const TransformValues& values )
63 {
64 return mat4<F32>
65 {
66 values._translation,
67 values._scale,
68 GetMatrix( values._orientation )
69 };
70 }
71
72 inline void ITransform::setScale( const F32 ammout )
73 {
74 setScale( vec3<F32>( ammout ) );
75 }
76
77 inline void ITransform::setScale( const F32 x, const F32 y, const F32 z )
78 {
79 setScale( vec3<F32>( x, y, z ) );
80 }
81
82 inline void ITransform::setRotationEuler( const vec3<F32>& euler )
83 {
84 setRotation( euler.pitch, euler.yaw, euler.roll );
85 }
86
87 inline void ITransform::translate( const F32 x, const F32 y, const F32 z )
88 {
89 translate( vec3<F32>( x, y, z ) );
90 }
91
92 inline void ITransform::translateX( const F32 positionX )
93 {
94 translate( vec3<F32>( positionX, 0.0f, 0.0f ) );
95 }
96
97 inline void ITransform::translateY( const F32 positionY )
98 {
99 translate( vec3<F32>( 0.0f, positionY, 0.0f ) );
100 }
101
102 inline void ITransform::translateZ( const F32 positionZ )
103 {
104 translate( vec3<F32>( 0.0f, 0.0f, positionZ ) );
105 }
106
107 inline void ITransform::scale( const F32 amount )
108 {
109 scale( vec3<F32>( amount ) );
110 }
111
112 inline void ITransform::scale( const F32 x, const F32 y, const F32 z )
113 {
114 scale( vec3<F32>( x, y, z ) );
115 }
116
117 inline void ITransform::rotate( const F32 xAxis, const F32 yAxis, const F32 zAxis, const Angle::DEGREES<F32> degrees )
118 {
119 rotate( vec3<F32>( xAxis, yAxis, zAxis ), degrees );
120 }
121
122 inline void ITransform::rotate( const vec3<F32>& euler )
123 {
124 rotate( euler.pitch, euler.yaw, euler.roll );
125 }
126} //namespace Divide
127
128#endif //DVD_TRANSFORM_INTERFACE_INL_
virtual void rotate(const vec3< F32 > &axis, Angle::DEGREES< F32 > degrees)=0
void translateY(F32 positionY)
Translate the object on the Y axis by the specified amount.
virtual void translate(const vec3< F32 > &axisFactors)=0
Add the specified translation factors to the current local position.
virtual void setScale(const vec3< F32 > &amount)=0
Set the local X,Y and Z scale factors.
void translateX(F32 positionX)
Translate the object on the X axis by the specified amount.
virtual void setRotation(const vec3< F32 > &axis, Angle::DEGREES< F32 > degrees)=0
virtual void scale(const vec3< F32 > &axisFactors)=0
Add the specified scale factors to the current local position.
void setRotationEuler(const vec3< F32 > &euler)
Set the euler rotation in degrees.
void translateZ(F32 positionZ)
Translate the object on the Z axis by the specified amount.
bool compare(const Quaternion &rq, Angle::DEGREES< T > tolerance=1e-3f) const
Definition: Quaternion.inl:141
bool compare(const vec3< U > &v) const noexcept
compare 2 vectors
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
FORCE_INLINE bool operator!=(const GUIDWrapper &lhs, const GUIDWrapper &rhs) noexcept
Definition: GUIDWrapper.h:67
T Lerp(T v1, T v2, U t) noexcept
Definition: MathHelper.inl:240
Quaternion< T > Slerp(const Quaternion< T > &q0, const Quaternion< T > &q1, F32 t) noexcept
Definition: Quaternion.inl:712
bool operator==(const DisplayManager::OutputDisplayProperties &lhs, const DisplayManager::OutputDisplayProperties &rhs) noexcept
Definition: Application.inl:37
mat3< T > GetMatrix(const Quaternion< T > &q) noexcept
Definition: Quaternion.inl:719
vec3< F32 > _translation
The object's position in the world as a 3 component vector.
Quaternion< F32 > _orientation