Added LerpQuat/SLerpQuat/Blend(Transform)
This commit is contained in:
parent
7feefc65c9
commit
e8b5f2a477
@ -169,6 +169,16 @@ namespace hgl
|
|||||||
angle=glm::degrees(glm::angle(quat));
|
angle=glm::degrees(glm::angle(quat));
|
||||||
axis=glm::axis(quat);
|
axis=glm::axis(quat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline Quatf LerpQuat(const Quatf &from,const Quatf &to,const float t)
|
||||||
|
{
|
||||||
|
return glm::lerp(from,to,t);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Quatf SLerpQuat(const Quatf &from,const Quatf &to,const float t)
|
||||||
|
{
|
||||||
|
return glm::slerp(from,to,t);
|
||||||
|
}
|
||||||
|
|
||||||
inline Vector3f TransformPosition(const Matrix4f &m,const Vector3f &v)
|
inline Vector3f TransformPosition(const Matrix4f &m,const Vector3f &v)
|
||||||
{
|
{
|
||||||
@ -393,5 +403,7 @@ namespace hgl
|
|||||||
};//Transform
|
};//Transform
|
||||||
|
|
||||||
constexpr const size_t TransformMatrix4fLength=sizeof(Transform);
|
constexpr const size_t TransformMatrix4fLength=sizeof(Transform);
|
||||||
|
|
||||||
|
Transform Blend(const Transform &from,const Transform &to,const float t);
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
#endif//HGL_ALGORITHM_MATH_VECTOR_MATRIX_INCLUDE
|
#endif//HGL_ALGORITHM_MATH_VECTOR_MATRIX_INCLUDE
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include<hgl/math/Matrix.h>
|
#include<hgl/math/Matrix.h>
|
||||||
|
|
||||||
// Vulkan Cookbook
|
// Vulkan Cookbook
|
||||||
// ISBN: 9781786468154
|
// ISBN: 9781786468154
|
||||||
@ -167,4 +167,15 @@ namespace hgl
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Transform Blend(const Transform &from,const Transform &to,const float t)
|
||||||
|
{
|
||||||
|
Transform result;
|
||||||
|
|
||||||
|
result.SetTranslation( from.GetTranslation()*(1.0f-t) + to.GetTranslation() *t);
|
||||||
|
result.SetRotation( SLerpQuat(from.GetRotationQuat(),to.GetRotationQuat(),t));
|
||||||
|
result.SetScale( from.GetScale() *(1.0f-t) + to.GetScale() *t);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user