Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qquick3dquaternionanimation.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5#include <QtQuick/private/qquickanimation_p_p.h>
6
8
37{
38 Q_DECLARE_PUBLIC(QQuick3DQuaternionAnimation)
39
40public:
43 { }
44
48};
49
50
52{
53 return QVariant::fromValue(QQuaternion::slerp(from, to, progress));
54}
55
57{
58 return QVariant::fromValue(QQuaternion::nlerp(from, to, progress));
59}
60
63{
65 d->interpolatorType = qMetaTypeId<QQuaternion>();
66 d->defaultToInterpolatorType = true;
67 d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
68}
69
78{
80 return d->from.value<QQuaternion>();
81}
82
84{
86}
87
96{
98 return d->to.value<QQuaternion>();
99}
100
102{
104}
105
117{
119 return d->type;
120}
121
123{
125 if (d->type == type)
126 return;
127
128 d->type = type;
129 switch (type) {
130 case Nlerp:
131 d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(reinterpret_cast<void(*)()>(&q_quaternionNlerpInterpolator));
132 break;
133 case Slerp:
134 default:
135 d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
136 break;
137 }
138
140}
141
151{
153 return d->anglesFrom.x();
154}
155
157{
159 if (d->anglesFrom.x() == f)
160 return;
161 d->anglesFrom.setX(f);
164}
165
175{
177 return d->anglesFrom.y();
178}
179
181{
183 if (d->anglesFrom.y() == f)
184 return;
185 d->anglesFrom.setY(f);
188}
189
199{
201 return d->anglesFrom.z();
202}
203
205{
207 if (d->anglesFrom.z() == f)
208 return;
209 d->anglesFrom.setZ(f);
212}
213
223{
225 return d->anglesTo.x();
226}
227
229{
231 if (d->anglesTo.x() == f)
232 return;
233 d->anglesTo.setX(f);
236}
237
247{
249 return d->anglesTo.y();
250}
251
253{
255 if (d->anglesTo.y() == f)
256 return;
257 d->anglesTo.setY(f);
260}
261
271{
273 return d->anglesTo.z();
274}
275
277{
279 if (d->anglesTo.z() == f)
280 return;
281 d->anglesTo.setZ(f);
284}
285
\inmodule QtCore
Definition qobject.h:90
The QQuaternion class represents a quaternion consisting of a vector and scalar.
Definition qquaternion.h:21
static QQuaternion fromEulerAngles(const QVector3D &eulerAngles)
static QQuaternion slerp(const QQuaternion &q1, const QQuaternion &q2, float t)
Interpolates along the shortest spherical path between the rotational positions q1 and q2.
static QQuaternion nlerp(const QQuaternion &q1, const QQuaternion &q2, float t)
Interpolates along the shortest linear path between the rotational positions q1 and q2.
\qmltype QuaternionAnimation \inherits PropertyAnimation \inqmlmodule QtQuick3D
void toXRotationChanged(float value)
QQuick3DQuaternionAnimation(QObject *parent=nullptr)
void typeChanged(QQuick3DQuaternionAnimation::Type type)
void toZRotationChanged(float value)
void fromZRotationChanged(float value)
void toYRotationChanged(float value)
void fromXRotationChanged(float value)
void fromYRotationChanged(float value)
void setFrom(const QVariant &)
void setTo(const QVariant &)
static Q_CORE_EXPORT QVariantAnimation::Interpolator getInterpolator(int interpolationType)
QVariant(* Interpolator)(const void *from, const void *to, qreal progress)
\inmodule QtCore
Definition qvariant.h:64
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:531
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
Combined button and popup list for selecting options.
GLfloat GLfloat f
GLenum type
GLdouble GLdouble t
Definition qopenglext.h:243
QVariant q_quaternionInterpolator(const QQuaternion &from, const QQuaternion &to, qreal progress)
QVariant q_quaternionNlerpInterpolator(const QQuaternion &from, const QQuaternion &to, qreal progress)
#define emit
double qreal
Definition qtypes.h:92
Definition moc.h:24
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent