public override void startWithTarget(CCNode pTarget) { base.startWithTarget(pTarget); CCCamera camera = pTarget.Camera; camera.getCenterXYZ(out this.m_fCenterXOrig, out this.m_fCenterYOrig, out this.m_fCenterZOrig); camera.getEyeXYZ(out this.m_fEyeXOrig, out this.m_fEyeYOrig, out this.m_fEyeZOrig); camera.getUpXYZ(out this.m_fUpXOrig, out this.m_fUpYOrig, out this.m_fUpZOrig); }
/// <summary> /// positions the camera according to spherical coordinates /// </summary> 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 camera = Target.Camera; camera.getEyeXYZ(out ex, out ey, out ez); camera.getCenterXYZ(out cx, out cy, out cz); x = ex - cx; y = ey - cy; z = ez - cz; r = (float)Math.Sqrt((float)Math.Pow(x, 2) + (float)Math.Pow(y, 2) + (float)Math.Pow(z, 2)); s = (float)Math.Sqrt((float)Math.Pow(x, 2) + (float)Math.Pow(y, 2)); if (s == 0.0f) { s = ccMacros.FLT_EPSILON; } if (r == 0.0f) { r = ccMacros.FLT_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(); }
public void sphericalRadius(out float newRadius, out float zenith, out float azimuth) { float single; float single1; float single2; float single3; float single4; float single5; CCCamera camera = this.m_pTarget.Camera; camera.getEyeXYZ(out single, out single1, out single2); camera.getCenterXYZ(out single3, out single4, out single5); float single6 = single - single3; float single7 = single1 - single4; float single8 = single2 - single5; float fLTEPSILON = (float)Math.Sqrt((double)((float)Math.Pow((double)single6, 2) + (float)Math.Pow((double)single7, 2) + (float)Math.Pow((double)single8, 2))); float fLTEPSILON1 = (float)Math.Sqrt((double)((float)Math.Pow((double)single6, 2) + (float)Math.Pow((double)single7, 2))); if (fLTEPSILON1 == 0f) { fLTEPSILON1 = ccMacros.FLT_EPSILON; } if (fLTEPSILON == 0f) { fLTEPSILON = ccMacros.FLT_EPSILON; } zenith = (float)Math.Acos((double)(single8 / fLTEPSILON)); if (single6 >= 0f) { azimuth = (float)Math.Sin((double)(single7 / fLTEPSILON1)); } else { azimuth = 3.14159274f - (float)Math.Sin((double)(single7 / fLTEPSILON1)); } newRadius = fLTEPSILON / CCCamera.getZEye(); }