示例#1
0
    public void renderBatch()
    {
        foreach (Material key in batch.Keys)
        {
            BatchedGeometry geometry = batch[key];

            Graphics.DrawMesh(geometry.finalMesh, Vector3.zero, Quaternion.identity, key, 0);
        }
    }
示例#2
0
    public void renderBatchNow()
    {
        foreach (Material key in batch.Keys)
        {
            BatchedGeometry geometry = batch[key];

            key.SetPass(1);
            Graphics.DrawMeshNow(geometry.finalMesh, Vector3.zero, Quaternion.identity);
        }
    }
示例#3
0
    public void clearDecals()
    {
        decals.Clear();

        foreach (Material key in batch.Keys)
        {
            BatchedGeometry geometry = batch[key];

            geometry.finalMesh.Clear();
        }
    }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="geom"></param>
        public override void Init(PagedGeometry geom)
        {
            mSceneMgr = geom.SceneManager;
            mBatch    = new BatchedGeometry(mSceneMgr, geom.SceneNode);

            mFadeEnabled = false;
            RenderSystemCapabilities caps = Root.Singleton.RenderSystem.Capabilities;

            if (caps.HasCapability(Capabilities.VertexPrograms))
            {
                mShadersSupported = true;
            }
            else
            {
                mShadersSupported = false;
            }

            ++mRefCount;
        }
示例#5
0
    public void updateBatch()
    {
        // update the decals and respective geometry
        for (int j = 0; j < decals.Count; j++)
        {
            ProjectedStaticDecal decal = decals[j];

            if (decal == null || decal.gameObject == null)
            {
                decals.RemoveAt(j);
                continue;
            }

            if (decal.isRtUpdateEnabled())
            {
                decal.updateMesh();
            }

            filler.reset();

            decal.fillBatchData(filler);

            // we have our batched data, add it into overall batch
            if (filler.material != null)
            {
                // we already have this material, add to batch
                if (batch.ContainsKey(filler.material))
                {
                    BatchedGeometry m = batch[filler.material];

                    int offset = m.vertices.Count;

                    m.vertices.AddRange(filler.vertices);

                    // offset out indices to new vertex positions
                    for (int i = 0; i < filler.indices.Count; i++)
                    {
                        m.indices.Add(filler.indices[i] + offset);
                    }

                    m.uv.AddRange(filler.uv);
                }
                else
                {
                    // add a new key because key doesnt exist, and add to batch
                    batch.Add(filler.material, new BatchedGeometry());

                    BatchedGeometry m = batch[filler.material];

                    int offset = m.vertices.Count;

                    m.vertices.AddRange(filler.vertices);

                    // offset our indices to new vertex positions
                    for (int i = 0; i < filler.indices.Count; i++)
                    {
                        m.indices.Add(filler.indices[i] + offset);
                    }

                    m.uv.AddRange(filler.uv);
                }
            }
        }

        // batch all the updated decals and clear previous buffers
        foreach (BatchedGeometry b in batch.Values)
        {
            b.batch();
        }
    }