Esempio n. 1
0
        public override void startWithTarget(CCNode pTarget)
        {
            base.startWithTarget(pTarget);

            CCCamera camera = pTarget.Camera;

            camera.getCenterXYZ(out m_fCenterXOrig, out m_fCenterYOrig, out m_fCenterZOrig);
            camera.getEyeXYZ(out m_fEyeXOrig, out m_fEyeYOrig, out m_fEyeZOrig);
            camera.getUpXYZ(out m_fUpXOrig, out m_fUpYOrig, out m_fUpZOrig);
        }
Esempio n. 2
0
        /// <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 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((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();
        }