Exemplo n.º 1
0
std::ostream& base::operator<<(std::ostream& out, const Transform& t)
{
  if (t.identity()) {
    out << "T:" << Matrix4();
  }
  else {
    if (t.isTransRotationOnly()) {
      out << "r:" << t.getRotation() << " t:" << t.getTranslation();
    }
    else
      out << "T:" << t.getTransform();
  }

  return out;
}
Exemplo n.º 2
0
Matrix4 Transform::getTransform() const
{
  if (isIdentity)
    return Matrix4();

  if (isPureTranslationRotation) {
    Matrix4 tm;
    if (hasRotation)
      tm = orient.getQuat4();
    if (hasTranslation)
      tm.setTranslationComponent(trans);
    return tm;
  }
  else
    return t;
}
Exemplo n.º 3
0
Transform& Transform::invert()
{
  if (isIdentity) return *this;
  if (!isPureTranslationRotation)
    t.invert();
  else {
    if (!hasTranslation)
      orient.invert();
    else {
      if (!hasRotation)
        trans = -trans;
      else {
        t = getTransform();
        t.invert();
        isPureTranslationRotation = false;
        hasTranslation = hasRotation = true;
        isIdentity = (t.equals(Matrix4(1)));
      }
    }
  }
  return *this;
}