Beispiel #1
0
void SphericalCamera::MoveFocusUp(double amount)
{
  double focusPos[3];
  GetFocusPosition(focusPos);
  focusPos[0] += amount * yAxis[0];
  focusPos[1] += amount * yAxis[1];
  focusPos[2] += amount * yAxis[2];
  SetFocusPosition(focusPos);
}
void CharacterCamera::SetCharacter(Character* pCharacter)
{
    mCharacter = pCharacter;

    Vector3f anchorPos = GetAnchorPosition();
    mCurrentAnchorPos = anchorPos;
    mPreviousAnchorPos = anchorPos;
    mPosition = anchorPos;
    
    LookAt( GetFocusPosition() );
}
Beispiel #3
0
//////////////////////////////////////////////////////////////////////////
/// Adjust camera height. 
///
/// @param  height          - The new height. 
//////////////////////////////////////////////////////////////////////////
void Camera::AdjustCameraHeight(VCNFloat height)
{
  const Vector3& camPos = GetViewerPosition();
  const Vector3& camTarget = GetFocusPosition();

  const float oldViewerHeight = camPos.y;
  SetViewerPosition(Vector3(camPos.x, height, camPos.z));

  const float adjustHeight = height - oldViewerHeight;
  SetFocusPosition(Vector3(camTarget.x, camTarget.y + adjustHeight, camTarget.z));
}
void CharacterCamera::Update(Double pElapsedTime)
{
    // Follow the object if any.
    if(mCharacter)
    {
	    mPreviousAnchorPos = mCurrentAnchorPos;
        mCurrentAnchorPos = GetAnchorPosition();
        mPosition = SpringDamp(mPosition, mCurrentAnchorPos, mPreviousAnchorPos, 
			                   pElapsedTime, mSpringForce, 0.25f, 1.0f);

        LookAt( GetFocusPosition() );
    }
}
Vector3f CharacterCamera::GetAnchorPosition() const
{
    return GetFocusPosition() - mCharacter->GetViewDirection() * mFollowDistance;
}