|
@@ -86,21 +86,20 @@ void Kam3D::scrollOut( float val )
|
|
|
|
|
|
void Kam3D::setAusrichtung( Vec3< float > ziel )
|
|
|
{
|
|
|
- rotX = 0;
|
|
|
- rotY = 0;
|
|
|
- rotZ = 0;
|
|
|
-
|
|
|
Vec3< float > target = ( ziel - pos ).normalize();
|
|
|
- if( target == Vec3<float>( 0, 0, -1 ) )
|
|
|
- rotY = (float)PI;
|
|
|
- if( target == Vec3<float>( 0, 1, 0 ) )
|
|
|
- rotX = -(float)PI / 2.f;
|
|
|
- if( target == Vec3<float>( 0, -1, 0 ) )
|
|
|
- rotX = (float)PI / 2.f;
|
|
|
- if( target == Vec3<float>( 1, 0, 0 ) )
|
|
|
- rotY = (float)PI / 2.f;
|
|
|
- if( target == Vec3<float>( -1, 0, 0 ) )
|
|
|
- rotY = -(float)PI / 2.f;
|
|
|
+ if( Vec3< float >( 0, target.y, target.z ).getLength() == 0 )
|
|
|
+ rotX = 0;
|
|
|
+ else
|
|
|
+ rotX = -lowPrecisionACos( abs( target.z ) / Vec3< float >( 0, target.y, target.z ).getLength() );
|
|
|
+ if( target.y < 0 )
|
|
|
+ rotX = -rotX;
|
|
|
+ if( Vec3< float >( target.x, 0, target.z ).getLength() == 0 )
|
|
|
+ rotY = 0;
|
|
|
+ else
|
|
|
+ rotY = lowPrecisionACos( abs(target.z) / Vec3< float >( target.x, 0, target.z ).getLength() );
|
|
|
+ if( target.x < 0 )
|
|
|
+ rotY = -rotY;
|
|
|
+ rotZ = 0;
|
|
|
updateMatrix();
|
|
|
}
|
|
|
|