예제 #1
0
void
Matrix4x4::decompose(Vector3::Ptr        translation,
                     Quaternion::Ptr    rotation,
                     Vector3::Ptr        scaling) const
{
    static auto matrixR = Matrix4x4::create();

    decomposeQR(rotation, matrixR);

    const std::vector<float>& matR = matrixR->_m;
    scaling->setTo(matR[0], matR[5], matR[10]);

#ifdef DEBUG
    if (fabsf(matR[1]) > 1e-3f || fabsf(matR[2]) > 1e-3f || fabsf(matR[6]) > 1e-3f)
        std::cout << "Warning: Matrix decomposition assumes the following composition order : scaling, rotation, and translation." << std::endl;
#endif // DEBUG

    translation->setTo(_m[3], _m[7], _m[11]);
}
예제 #2
0
Vector3::Ptr
bullet::PhysicsWorld::getColliderAngularVelocity(Collider::ConstPtr    collider,
                                                 Vector3::Ptr        output) const
{
    if (output == nullptr)
        output = Vector3::create(0.0f, 0.0f, 0.0f);

    auto foundColliderIt = _colliderMap.find(std::const_pointer_cast<Collider>(collider));
    if (foundColliderIt == _colliderMap.end())
        return output;

    auto rigidBody    = foundColliderIt->second->rigidBody();
    auto vec        = rigidBody->getAngularVelocity();

    return output->setTo(vec.x(), vec.y(), vec.z());
}
예제 #3
0
			inline
			void
			copyTranslation(Vector3::Ptr t)
			{
				t->setTo(_m[3], _m[7], _m[11]);
			}