Exemple #1
0
        public void lineWidth(GLfloat width)
        {
            string script = ScriptBuilder.Build(
                ScriptBuilder.Script(
                    "{0}.lineWidth({1});"
                    ),
                Script.GetObject(API.id), width
                );

            API.ExecuteJavaScript(script);
        }
Exemple #2
0
        public void polygonOffset(GLfloat factor, GLfloat units)
        {
            string script = ScriptBuilder.Build(
                ScriptBuilder.Script(
                    "{0}.polygonOffset({1},{2});"
                    ),
                Script.GetObject(API.id),
                factor, units
                );

            API.ExecuteJavaScript(script);
        }
        //CCAffineTransform temp = new CCAffineTransform();

        /// <summary>
        /// performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes.
        /// </summary>
        public void transform()
        {
            // transformations

            CCApplication app = CCApplication.sharedApplication();

#if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
            // BEGIN alternative -- using cached transform
            //
            if (m_bIsTransformGLDirty)
            {
                CCAffineTransform t = this.nodeToParentTransform();
                TransformUtils.CGAffineToGL(t, ref m_pTransformGL);
                m_bIsTransformGLDirty = false;
            }

            m_tCCNodeTransform = TransformUtils.CGAffineToMatrix(m_pTransformGL);

            if (m_fVertexZ > 0)
            {
                m_tCCNodeTransform *= Matrix.CreateRotationZ(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_tAnchorPointInPixels.x != 0.0f || m_tAnchorPointInPixels.y != 0.0f);

                Matrix? matrix = m_pCamera.locate();
                if (matrix != null)
                {
                    m_tCCNodeTransform = Matrix.CreateTranslation(-m_tAnchorPointInPixels.x, -m_tAnchorPointInPixels.y, 0) *
                        matrix.Value *
                        Matrix.CreateTranslation(m_tAnchorPointInPixels.x, m_tAnchorPointInPixels.y, 0) *
                        m_tCCNodeTransform;
                }


            }

            // This is ok here. Visit() will restore the world transform for the next node.
            app.basicEffect.World = m_tCCNodeTransform * app.basicEffect.World;


            // END alternative
#else
                // BEGIN original implementation
                // 
                // translate
                if ( m_bIsRelativeAnchorPoint && (m_tAnchorPointInPixels.x != 0 || m_tAnchorPointInPixels.y != 0 ) )
                    glTranslatef( RENDER_IN_SUBPIXEL(-m_tAnchorPointInPixels.x), RENDER_IN_SUBPIXEL(-m_tAnchorPointInPixels.y), 0);

                if (m_tAnchorPointInPixels.x != 0 || m_tAnchorPointInPixels.y != 0)
                    glTranslatef( RENDER_IN_SUBPIXEL(m_tPositionInPixels.x + m_tAnchorPointInPixels.x), RENDER_IN_SUBPIXEL(m_tPositionInPixels.y + m_tAnchorPointInPixels.y), m_fVertexZ);
                else if ( m_tPositionInPixels.x !=0 || m_tPositionInPixels.y !=0 || m_fVertexZ != 0)
                    glTranslatef( RENDER_IN_SUBPIXEL(m_tPositionInPixels.x), RENDER_IN_SUBPIXEL(m_tPositionInPixels.y), m_fVertexZ );

                // rotate
                if (m_fRotation != 0.0f )
                    glRotatef( -m_fRotation, 0.0f, 0.0f, 1.0f );

                // skew
                if ( (skewX_ != 0.0f) || (skewY_ != 0.0f) ) 
                {
                    CCAffineTransform skewMatrix = CCAffineTransformMake( 1.0f, tanf(CC_DEGREES_TO_RADIANS(skewY_)), tanf(CC_DEGREES_TO_RADIANS(skewX_)), 1.0f, 0.0f, 0.0f );
                    GLfloat[]	glMatrix = new GLfloat[16];
                    CCAffineToGL(&skewMatrix, glMatrix);															 
                    glMultMatrixf(glMatrix);
                }

                // scale
                if (m_fScaleX != 1.0f || m_fScaleY != 1.0f)
                    glScalef( m_fScaleX, m_fScaleY, 1.0f );

                if ( m_pCamera  && !(m_pGrid && m_pGrid->isActive()) )
                    m_pCamera->locate();

                // restore and re-position point
                if (m_tAnchorPointInPixels.x != 0.0f || m_tAnchorPointInPixels.y != 0.0f)
                    glTranslatef(RENDER_IN_SUBPIXEL(-m_tAnchorPointInPixels.x), RENDER_IN_SUBPIXEL(-m_tAnchorPointInPixels.y), 0);

                //
                // END original implementation
#endif
        }
Exemple #4
0
 void lw_object_scale(lwObject *lw_object, GLfloat scale);