Ejemplo n.º 1
0
        public virtual void Begin()
        {
            // Save the current matrix
            CCDrawManager.PushMatrix();

            CCSize texSize = m_pTexture.ContentSizeInPixels;

            // Calculate the adjustment ratios based on the old and new projections
            CCDirector director    = CCDirector.SharedDirector;
            CCSize     size        = director.WinSizeInPixels;
            float      widthRatio  = size.Width / texSize.Width;
            float      heightRatio = size.Height / texSize.Height;

            CCDrawManager.SetRenderTarget(m_pTexture);

            CCDrawManager.SetViewPort(0, 0, (int)texSize.Width, (int)texSize.Height);

            Matrix projection = Matrix.CreateOrthographicOffCenter(
                -1.0f / widthRatio, 1.0f / widthRatio,
                -1.0f / heightRatio, 1.0f / heightRatio,
                -1, 1
                );

            CCDrawManager.MultMatrix(ref projection);

            if (m_bFirstUsage)
            {
                CCDrawManager.Clear(Color.Transparent);
                m_bFirstUsage = false;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///  Sets the camera using gluLookAt using its eye, center and up_vector
        /// </summary>
        public void Locate()
        {
            if (m_bDirty)
            {
                m_lookupMatrix = Matrix.CreateLookAt(new Vector3(m_fEyeX, m_fEyeY, m_fEyeZ),
                                                     new Vector3(m_fCenterX, m_fCenterY, m_fCenterZ),
                                                     new Vector3(m_fUpX, m_fUpY, m_fUpZ));
                m_bDirty = false;
            }

            CCDrawManager.MultMatrix(ref m_lookupMatrix);
        }
Ejemplo n.º 3
0
        public void Transform()
        {
            CCDrawManager.MultMatrix(NodeToParentTransform(), m_fVertexZ);

            // XXX: Expensive calls. Camera should be integrated into the cached affine matrix
            if (m_pCamera != null && !(m_pGrid != null && m_pGrid.Active))
            {
                bool translate = (m_obAnchorPointInPoints.X != 0.0f || m_obAnchorPointInPoints.Y != 0.0f);

                if (translate)
                {
                    CCDrawManager.Translate(m_obAnchorPointInPoints.X, m_obAnchorPointInPoints.Y, 0);
                }

                m_pCamera.Locate();

                if (translate)
                {
                    CCDrawManager.Translate(-m_obAnchorPointInPoints.X, -m_obAnchorPointInPoints.Y, 0);
                }
            }
        }