Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds the draw call. Calculates target mesh level of detail and picks a proper meshes to draw (based on a material slot index).
        /// </summary>
        /// <param name="model">The model mesh to render. Cannot be null.</param>
        /// <param name="materialSlotIndex">The material slot index to draw.</param>
        /// <param name="material">The material to apply during rendering. Cannot be null.</param>
        /// <param name="bounds">The bounds of the model instance that is being drawn (model instance bounds).</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(Model model, int materialSlotIndex, MaterialBase material, ref BoundingSphere bounds, ref Matrix world, StaticFlags flags = StaticFlags.None)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            // Pick a proper LOD
            int lodIndex = RenderTask.Internal_ComputeModelLOD(model.unmanagedPtr, ref bounds, IntPtr.Zero);
            var lods     = model.LODs;

            if (lods == null || lods.Length < lodIndex || lodIndex < 0)
            {
                return;
            }
            var lod = lods[lodIndex];

            // Draw meshes
            for (int i = 0; i < lod.Meshes.Length; i++)
            {
                if (lod.Meshes[i].MaterialSlotIndex == materialSlotIndex)
                {
                    AddDrawCall(lod.Meshes[i], material, ref world, flags);
                }
            }
        }
Ejemplo n.º 4
0
 internal static extern void Internal_SetStaticFlags(IntPtr obj, StaticFlags value);
Ejemplo n.º 5
0
 public void SetStaticFlag(StaticFlags flag, bool value)
 {
     StaticFlags = StaticFlags & ~flag | (value ? flag : StaticFlags.None);
 }
Ejemplo n.º 6
0
 public bool HasStaticFlag(StaticFlags flag)
 {
     return((StaticFlags & flag) == flag);
 }
Ejemplo n.º 7
0
 public void AddStaticFlags(StaticFlags flags)
 {
     StaticFlags |= flags;
 }
Ejemplo n.º 8
0
 public void RemoveStaticFlags(StaticFlags flags)
 {
     StaticFlags &= ~flags;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Draws the model.
 /// </summary>
 /// <param name="renderContext">The rendering context.</param>
 /// <param name="material">The material to use for rendering.</param>
 /// <param name="world">The world transformation of the model.</param>
 /// <param name="flags">The object static flags.</param>
 /// <param name="receiveDecals">True if rendered geometry can receive decals, otherwise false.</param>
 public void Draw(ref RenderContext renderContext, MaterialBase material, ref Matrix world, StaticFlags flags = StaticFlags.None, bool receiveDecals = true)
 {
     Internal_Draw(unmanagedPtr, ref renderContext, FlaxEngine.Object.GetUnmanagedPtr(material), ref world, flags, receiveDecals);
 }
Ejemplo n.º 10
0
 internal static extern void Internal_Draw(IntPtr obj, ref RenderContext renderContext, IntPtr material, ref Matrix world, StaticFlags flags, bool receiveDecals);
Ejemplo n.º 11
0
        /// <summary>
        /// Adds the draw call (single model drawing). Calculates target mesh level of detail and picks a proper meshes to draw (based on a material slot index).
        /// </summary>
        /// <param name="model">The model mesh to render. Cannot be null.</param>
        /// <param name="materialSlotIndex">The material slot index to draw.</param>
        /// <param name="material">The material to apply during rendering. Cannot be null.</param>
        /// <param name="lodIndex">The model Level Of Detail to draw (zero-based index).</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(Model model, int materialSlotIndex, MaterialBase material, int lodIndex, ref Matrix world, StaticFlags flags = StaticFlags.None, bool receiveDecals = true)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            // Pick a proper LOD
            var lods = model.LODs;

            if (lods == null || lods.Length < lodIndex || lodIndex < 0)
            {
                return;
            }
            var lod = lods[lodIndex];

            // Draw meshes
            for (int i = 0; i < lod.Meshes.Length; i++)
            {
                if (lod.Meshes[i].MaterialSlotIndex == materialSlotIndex)
                {
                    AddDrawCall(lod.Meshes[i], material, ref world, flags);
                }
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Adds the actor static flags.
 /// </summary>
 /// <param name="flags">The flags to add.</param>
 public void AddStaticFlags(StaticFlags flags)
 {
     Internal_AddStaticFlags(unmanagedPtr, flags);
 }
Ejemplo n.º 13
0
 internal static extern void Internal_SetStaticFlag(IntPtr obj, StaticFlags flag, bool value);
Ejemplo n.º 14
0
 /// <summary>
 /// Sets a single static flag to the desire value.
 /// </summary>
 /// <param name="flag">The flag to change.</param>
 /// <param name="value">The target value of the flag.</param>
 public void SetStaticFlag(StaticFlags flag, bool value)
 {
     Internal_SetStaticFlag(unmanagedPtr, flag, value);
 }
Ejemplo n.º 15
0
 internal static extern void Internal_RemoveStaticFlags(IntPtr obj, StaticFlags flags);
Ejemplo n.º 16
0
 /// <summary>
 /// Removes the actor static flags.
 /// </summary>
 /// <param name="flags">The flags to remove.</param>
 public void RemoveStaticFlags(StaticFlags flags)
 {
     Internal_RemoveStaticFlags(unmanagedPtr, flags);
 }
Ejemplo n.º 17
0
 internal static extern void Internal_AddStaticFlags(IntPtr obj, StaticFlags flags);