示例#1
0
        /// <summary>
        /// Adds the draw call (single terrain patch drawing).
        /// </summary>
        /// <param name="terrain">The terrain to render. Cannot be null.</param>
        /// <param name="patchCoord">The terrain patch coordinates.</param>
        /// <param name="material">The material to apply during rendering. Cannot be null.</param>
        /// <param name="lodIndex">The geometry Level Of Detail index.</param>
        public void AddDrawCall(Terrain terrain, ref Int2 patchCoord, MaterialBase material, int lodIndex = -1)
        {
            if (terrain == null)
            {
                throw new ArgumentNullException(nameof(terrain));
            }
            if (material == null)
            {
                throw new ArgumentNullException(nameof(material));
            }

            for (int i = 0; i < 16; i++)
            {
                var drawCall = new RenderTask.DrawCall
                {
                    Type     = RenderTask.DrawCall.Types.TerrainChunk,
                    Flags    = StaticFlags.None,
                    LodIndex = lodIndex,
                    Index0   = patchCoord,
                    Index1   = new Int2(i % 4, i / 4),
                    Object   = terrain.unmanagedPtr,
                    Material = Object.GetUnmanagedPtr(material),
                };

                _drawCalls.Add(drawCall);
            }
        }
        /// <summary>
        /// Adds the draw call.
        /// </summary>
        /// <param name="mesh">The mesh to render. Cannot be null.</param>
        /// <param name="material">The material to apply during rendering. Cannot be null.</param>
        /// <param name="world">The world matrix used to transform mesh geometry during rendering. Use <see cref="Matrix.Identity"/> to render mesh 'as is'.</param>
        /// <param name="flags">The static flags. Used to describe type of the geometry.</param>
        public void AddDrawCall(Mesh mesh, MaterialBase material, ref Matrix world, StaticFlags flags = StaticFlags.None)
        {
            if (mesh == null)
            {
                throw new ArgumentNullException(nameof(mesh));
            }
            if (material == null)
            {
                throw new ArgumentNullException(nameof(material));
            }

            var drawCall = new RenderTask.DrawCall
            {
                Flags             = flags,
                LodIndex          = mesh._lodIndex,
                MeshIndex         = mesh._meshIndex,
                AssetModel        = Object.GetUnmanagedPtr(mesh.ParentModel),
                AssetMaterialBase = Object.GetUnmanagedPtr(material),
                World             = world
            };

            _drawCalls.Add(drawCall);
        }
示例#3
0
        /// <summary>
        /// Adds the draw call (single mesh drawing).
        /// </summary>
        /// <param name="mesh">The mesh to render. Cannot be null.</param>
        /// <param name="material">The material to apply during rendering. Cannot be null.</param>
        /// <param name="world">The world matrix used to transform mesh geometry during rendering. Use <see cref="Matrix.Identity"/> to render mesh 'as is'.</param>
        /// <param name="flags">The static flags. Used to describe type of the geometry.</param>
        /// <param name="receiveDecals">True if rendered geometry can receive decals, otherwise false.</param>
        public void AddDrawCall(Mesh mesh, MaterialBase material, ref Matrix world, StaticFlags flags = StaticFlags.None, bool receiveDecals = true)
        {
            if (mesh == null)
            {
                throw new ArgumentNullException(nameof(mesh));
            }
            if (material == null)
            {
                throw new ArgumentNullException(nameof(material));
            }

            var drawCall = new RenderTask.DrawCall
            {
                Type     = RenderTask.DrawCall.Types.Mesh,
                Flags    = flags,
                LodIndex = mesh._lodIndex,
                Index0   = new Int2(mesh._meshIndex, receiveDecals ? 1 : 0),
                Object   = Object.GetUnmanagedPtr(mesh.ParentModel),
                Material = Object.GetUnmanagedPtr(material),
                World    = world
            };

            _drawCalls.Add(drawCall);
        }