Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="info"></param>
        /// <param name="parent"></param>
        /// <param name="pcolor"></param>
        /// <param name="renderQueue"></param>
        private void renderGraphics(BitmapAssetInfo info, DisplayObjectContainer parent, Color pcolor, int renderQueue)
        {
            Submesh submesh = null;

            if (info != null)
            {
                Material material = info.material;
                if (material != null)
                {
                    material.renderQueue = renderQueue;
                    if (phaseId == 0)
                    {
                        if (currentMaterial != material)
                        {
                            if (currentMaterial != null)
                            {
                                AppSubMesh();
                                triId    = 0;
                                numIndex = 0;
                            }
                            currentMaterial = material;
                        }

                        numVerts += 4;
                        numIndex += 6;
                        quadCount++;
                        zDrawOffset += zSpace;
                    }
                    else if (phaseId == 1)
                    {
                        if (currentMaterial != material)
                        {
                            subMeshId++;
                            currentMaterial = material;
                            triId           = 0;
                            submesh         = submeshIndices[subMeshId];
                        }

                        float  x           = 0f;
                        float  y           = 0f;
                        float  drawWidth   = info.srcRect.width;
                        float  drawHeight  = info.srcRect.height;
                        Rect   drawSrcRect = info.uvRect;
                        float  zDrawOffset = this.zDrawOffset;
                        Matrix matrix      = parent._fastGetFullMatrixRef();
                        lowerLeftUV.x  = drawSrcRect.x;
                        lowerLeftUV.y  = 1f - drawSrcRect.y;
                        UVDimensions.x = drawSrcRect.width;
                        UVDimensions.y = drawSrcRect.height;
                        tmpUv.x        = lowerLeftUV.x + UVDimensions.x;
                        tmpUv.y        = lowerLeftUV.y;
                        UVs[UVId++]    = tmpUv;
                        tmpUv.x        = lowerLeftUV.x + UVDimensions.x;
                        tmpUv.y        = lowerLeftUV.y - UVDimensions.y;
                        UVs[UVId++]    = tmpUv;
                        tmpUv.x        = lowerLeftUV.x;
                        tmpUv.y        = lowerLeftUV.y - UVDimensions.y;
                        UVs[UVId++]    = tmpUv;
                        tmpUv.x        = lowerLeftUV.x;
                        tmpUv.y        = lowerLeftUV.y;
                        UVs[UVId++]    = tmpUv;

                        if (!simpleGeneration)
                        {
                            colors[ColourId++] = white;
                            colors[ColourId++] = white;
                            colors[ColourId++] = white;
                            colors[ColourId++] = white;
                        }
                        else
                        {
                            float alpha = parent.getInheritedAlpha();
                            Color color = pcolor;
                            if (alpha <= 0.95f || alpha >= 0.05f)
                            {
                                Color tem = Color.white;
                                tem.a = alpha;
                                color = pcolor * tem;
                            }

                            colors[ColourId++] = color;
                            colors[ColourId++] = color;
                            colors[ColourId++] = color;
                            colors[ColourId++] = color;
                        }

                        vertices[VertId++] = matrix.transformVector3Static(x + drawWidth, y, zDrawOffset);
                        vertices[VertId++] = matrix.transformVector3Static(x + drawWidth, y + drawHeight, zDrawOffset);
                        vertices[VertId++] = matrix.transformVector3Static(x, y + drawHeight, zDrawOffset);
                        vertices[VertId++] = matrix.transformVector3Static(x, y, zDrawOffset);

                        if (submesh == null)
                        {
                            submesh = submeshIndices[subMeshId];
                        }
                        int[] triangles = submesh.triangles;
                        int   num11     = quadCount * 4;

                        triangles[triId++] = num11;
                        triangles[triId++] = num11 + 1;
                        triangles[triId++] = num11 + 3;
                        triangles[triId++] = num11 + 3;
                        triangles[triId++] = num11 + 1;
                        triangles[triId++] = num11 + 2;
                        quadCount++;
                        zDrawOffset += zSpace;
                    }
                }
            }
        }