Ejemplo 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);
        }
Ejemplo n.º 2
0
        public override void update(float dt)
        {
            float r  = (m_fRadius + m_fDeltaRadius * dt) * CCCamera.getZEye();
            float za = m_fRadZ + m_fRadDeltaZ * dt;
            float xa = m_fRadX + m_fRadDeltaX * dt;

            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);
        }
Ejemplo n.º 3
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();
        }