I want to scale an object in different spaces. For example, in a hierarchical system I want to scale a node as if it is in its parent coordinate space, or in world space.
void ABT::Node::Scale(glm::vec3 val, TransformationSpace space)
{
switch (space)
{
case ABT::TS_WORLD:
{
glm::quat ws = GetOrientation(ABT::TS_WORLD);
m_scale += ws * val * glm::inverse(ws);
}
break;
case ABT::TS_PARENT:
{
glm::quat ps;
if (m_parent)
ps = m_parent->GetOrientation(ABT::TS_WORLD);
m_scale += ps * val * glm::inverse(ps);
}
break;
case ABT::TS_LOCAL:
{
glm::quat ls = GetOrientation(ABT::TS_LOCAL);
m_scale += ls * val * glm::inverse(ls);
}
break;
}
}
Bad think with this code is, it doesn't apply transformation to one axis. It applies all three of them when I observe it.