101 lines
1.8 KiB
C++
101 lines
1.8 KiB
C++
#include "Transform.h"
|
|
|
|
Scale::Scale(double x, double y, double z)
|
|
: mX(x),
|
|
mY(y),
|
|
mZ(z)
|
|
{
|
|
|
|
}
|
|
|
|
bool Scale::isIdentity() const
|
|
{
|
|
return mX == 1.0 && mY == 1.0 && mZ == 1.0;
|
|
}
|
|
|
|
bool Scale::isEqual(const Scale& scale) const
|
|
{
|
|
return mX == scale.mX && mY == scale.mY && mZ == scale.mZ;
|
|
}
|
|
|
|
Transform::Transform(const Point3& location, const Scale& scale, const Rotation& rotation)
|
|
: mLocation(location),
|
|
mScale(scale),
|
|
mRotation(rotation),
|
|
mMatrix()
|
|
{
|
|
|
|
}
|
|
|
|
Transform::Transform(const Point2& location, const Scale& scale, const Rotation& rotation)
|
|
: mLocation(Point<3>::from(location)),
|
|
mScale(scale),
|
|
mRotation(rotation),
|
|
mMatrix()
|
|
{
|
|
|
|
}
|
|
|
|
void Transform::applyPre(const Transform& transform)
|
|
{
|
|
mLocation.moveBy(transform.getLocation().getX(), transform.getLocation().getY(), transform.getLocation().getZ());
|
|
mScale *= transform.getScale();
|
|
}
|
|
|
|
const Point3& Transform::getLocation() const
|
|
{
|
|
return mLocation;
|
|
}
|
|
|
|
const Scale& Transform::getScale() const
|
|
{
|
|
return mScale;
|
|
}
|
|
|
|
const Rotation& Transform::getRotation() const
|
|
{
|
|
return mRotation;
|
|
}
|
|
|
|
bool Transform::isEqual(const Transform& transform) const
|
|
{
|
|
return (mLocation == transform.mLocation) && (mScale == transform.mScale) && (mRotation == transform.mRotation);
|
|
}
|
|
|
|
bool Transform::isIdentityTransform() const
|
|
{
|
|
return mLocation.isAtOrigin() && mScale.isIdentity();
|
|
}
|
|
|
|
void Transform::setLocation(const Point3& loc)
|
|
{
|
|
if (mLocation != loc)
|
|
{
|
|
mLocation = loc;
|
|
updateMatrix();
|
|
}
|
|
}
|
|
|
|
void Transform::setScale(const Scale& scale)
|
|
{
|
|
if (mScale != scale)
|
|
{
|
|
mScale = scale;
|
|
updateMatrix();
|
|
}
|
|
}
|
|
|
|
void Transform::setRotation(const Rotation& rotation)
|
|
{
|
|
if (mRotation != rotation)
|
|
{
|
|
mRotation = rotation;
|
|
updateMatrix();
|
|
}
|
|
}
|
|
|
|
void Transform::updateMatrix()
|
|
{
|
|
|
|
}
|
|
|