public override void Update(float time) { float r = (m_fRadius + m_fDeltaRadius * time) * CCCamera.GetZEye(); float za = m_fRadZ + m_fRadDeltaZ * time; float xa = m_fRadX + m_fRadDeltaX * time; float i = (float)Math.Sin(za) * (float)Math.Cos(xa) * r + m_fCenterXOrig; float j = (float)Math.Sin(za) * (float)Math.Sin(xa) * r + m_fCenterYOrig; float k = (float)Math.Cos(za) * r + m_fCenterZOrig; m_pTarget.Camera.SetEyeXyz(i, j, k); }
public void SphericalRadius(out float newRadius, out float zenith, out float azimuth) { float ex, ey, ez, cx, cy, cz, x, y, z; float r; // radius float s; CCCamera pCamera = m_pTarget.Camera; pCamera.GetEyeXyz(out ex, out ey, out ez); pCamera.GetCenterXyz(out cx, out cy, out cz); x = ex - cx; y = ey - cy; z = ez - cz; r = (float)Math.Sqrt(x * x + y * y + z * z); s = (float)Math.Sqrt(x * x + y * y); if (s == 0.0f) { s = float.Epsilon; } if (r == 0.0f) { r = float.Epsilon; } zenith = (float)Math.Acos(z / r); if (x < 0) { azimuth = (float)Math.PI - (float)Math.Sin(y / s); } else { azimuth = (float)Math.Sin(y / s); } newRadius = r / CCCamera.GetZEye(); }