//------------------------------------------------------------------------------- // @ Player::Player() //------------------------------------------------------------------------------- // Constructor //------------------------------------------------------------------------------- Player::Player() { // set animation params mRun = false; mTime = 0.0f; // set euler params mStartHeading = 0.0f; mStartPitch = 0.0f; mStartRoll = 0.0f; mEndHeading = kPI; mEndPitch = kPI * 0.5f; mEndRoll= 0.0f; // set quaternion params mStartRotate.Identity(); mEndRotate = IvQuat(IvVector3::yAxis, kPI * 0.5f ) * IvQuat( IvVector3::zAxis, kPI ); mSlerpRotate.Identity(); mUseQuat = false; // set object transform mRotate.Identity(); mStrip0 = 0; mStrip1 = 0; mNumPoints = 0; mFrameCounter = 0; } // End of Player::Player()
//------------------------------------------------------------------------------- // @ ::Inverse() //------------------------------------------------------------------------------- // Compute quaternion inverse //------------------------------------------------------------------------------- IvQuat Inverse( const IvQuat& quat ) { float norm = quat.w*quat.w + quat.x*quat.x + quat.y*quat.y + quat.z*quat.z; // if we're the zero quaternion, just return identity if ( !::IsZero( norm ) ) { ASSERT( false ); return IvQuat(); } float normRecip = 1.0f / norm; return IvQuat( normRecip*quat.w, -normRecip*quat.x, -normRecip*quat.y, -normRecip*quat.z ); } // End of Inverse()
//------------------------------------------------------------------------------- // @ IvQuat::operator*() //------------------------------------------------------------------------------- // Quaternion multiplication //------------------------------------------------------------------------------- IvQuat IvQuat::operator*( const IvQuat& other ) const { return IvQuat( w*other.w - x*other.x - y*other.y - z*other.z, w*other.x + x*other.w + y*other.z - z*other.y, w*other.y + y*other.w + z*other.x - x*other.z, w*other.z + z*other.w + x*other.y - y*other.x ); } // End of IvQuat::operator*()
//------------------------------------------------------------------------------- // @ operator*() //------------------------------------------------------------------------------- // Scalar multiplication //------------------------------------------------------------------------------- IvQuat operator*( float scalar, const IvQuat& quat ) { return IvQuat( scalar*quat.w, scalar*quat.x, scalar*quat.y, scalar*quat.z ); } // End of operator*()
//------------------------------------------------------------------------------- // @ IvQuat::operator-=() (unary) //------------------------------------------------------------------------------- // Negate self and return //------------------------------------------------------------------------------- IvQuat IvQuat::operator-() const { return IvQuat(-w, -x, -y, -z); } // End of IvQuat::operator-()
//------------------------------------------------------------------------------- // @ IvQuat::operator-() //------------------------------------------------------------------------------- // Subtract quat from self and return //------------------------------------------------------------------------------- IvQuat IvQuat::operator-( const IvQuat& other ) const { return IvQuat( w - other.w, x - other.x, y - other.y, z - other.z ); } // End of IvQuat::operator-()
//------------------------------------------------------------------------------- // @ IvQuat::operator+() //------------------------------------------------------------------------------- // Add quat to self and return //------------------------------------------------------------------------------- IvQuat IvQuat::operator+( const IvQuat& other ) const { return IvQuat( w + other.w, x + other.x, y + other.y, z + other.z ); } // End of IvQuat::operator+()
//------------------------------------------------------------------------------- // @ ::Conjugate() //------------------------------------------------------------------------------- // Compute complex conjugate //------------------------------------------------------------------------------- IvQuat Conjugate( const IvQuat& quat ) { return IvQuat( quat.w, -quat.x, -quat.y, -quat.z ); } // End of Conjugate()