示例#1
0
        public void Draw(CommandList cmdList, Camera cam)
        {
            cmdList.SetVertexBuffer(0, m_vertexBuffer);
            cmdList.SetIndexBuffer(m_indexBuffer, IndexFormat.UInt32);
            cmdList.SetPipeline(m_pipelineState);

            SN.Matrix4x4 transform = WorldMatrix;

            for (int i = 0; i < m_meshesToDraw.Count; i++)
            {
                MeshDrawCall   drawParams = m_meshesToDraw[i];
                MeshPart       partData   = m_meshesData[drawParams.MeshPartIndex];
                SimpleMaterial material   = m_materials[partData.MaterialIndex];

                SN.Matrix4x4 w   = drawParams.World * transform;
                SN.Matrix4x4 wvp = w * cam.ViewProjection;

                cmdList.UpdateBuffer(m_wvpParam, 0, ref wvp);
                cmdList.UpdateBuffer(m_worldParam, 0, ref w);
                cmdList.UpdateBuffer(m_lightPosParam, 0, LightPosition);
                cmdList.UpdateBuffer(m_camPosParam, 0, cam.Position);

                cmdList.SetGraphicsResourceSet(0, m_worldLightCBSet);
                cmdList.SetGraphicsResourceSet(1, material.ColorAndTexture);

                cmdList.DrawIndexed((uint)partData.IndexCount, 1, (uint)partData.IndexOffset, 0, 0);
            }
        }
示例#2
0
    public MeshDrawCall createChild()
    {
        Debug.Log(" MeshDrawCall createChild ");

        GameObject   child = NGUITools.AddChild(gameObject);
        MeshDrawCall dc    = child.AddComponent <MeshDrawCall>();

        dc.Init(this.uiAtlas.spriteMaterial);
        return(dc);
    }