Пример #1
0
void Camera::lookAt( const vec3 &aEyePoint, const vec3 &target )
{
	mEyePoint = aEyePoint;
	mViewDirection = normalize( target - mEyePoint );
	mOrientation = quat( glm::toQuat( alignZAxisWithTarget( -mViewDirection, mWorldUp ) ) );
	mModelViewCached = false;
}
Пример #2
0
Matrix44<T> Matrix44<T>::createRotation( const Vec3<T> &from, const Vec3<T> &to, const Vec3<T> &worldUp )
{
    // The goal is to obtain a rotation matrix that takes 
    // "fromDir" to "toDir".  We do this in two steps and 
    // compose the resulting rotation matrices; 
    //    (a) rotate "fromDir" into the z-axis
    //    (b) rotate the z-axis into "toDir"
 
    // The from direction must be non-zero; but we allow zero to and up dirs.
    if( from.lengthSquared() == 0 ) {
		return Matrix44<T>();
	}
    else {
		Matrix44<T> zAxis2FromDir = alignZAxisWithTarget( from, Vec3<T>::yAxis() );
		Matrix44<T> fromDir2zAxis = zAxis2FromDir.transposed();
		Matrix44<T> zAxis2ToDir = alignZAxisWithTarget( to, worldUp );
		return fromDir2zAxis * zAxis2ToDir;
    }
}
Пример #3
0
void Camera::setWorldUp( const vec3 &aWorldUp )
{
	mWorldUp = normalize( aWorldUp );
	mOrientation = glm::toQuat( alignZAxisWithTarget( -mViewDirection, mWorldUp ) );
	mModelViewCached = false;
}