예제 #1
0
        /// <summary>
        /// Creates a new instance of this material. Material instances should be freed using
        /// <see cref="Engine.Destroy(MaterialInstance)"/>.
        /// </summary>
        /// <returns>The newly created instance.</returns>
        public MaterialInstance CreateInstance()
        {
            ThrowExceptionIfDisposed();

            return(MaterialInstance.GetOrCreateCache(
                       Native.Material.CreateInstance(NativePtr)
                       ));
        }
        /// <summary>
        /// <para>Binds a material instance to the specified primitive.</para>
        /// <para>If no material is specified for a given primitive, Filament will fall back to a basic default material.</para>
        /// </summary>
        /// <param name="index">Zero-based index of the primitive, must be less than the count passed to Builder constructor.</param>
        /// <param name="materialInstance">The material to bind.</param>
        public RenderableBuilder WithMaterial(int index, MaterialInstance materialInstance)
        {
            ThrowExceptionIfDisposed();

            Native.RenderableBuilder.Material(NativePtr, index, materialInstance.NativePtr);

            return(this);
        }
        /// <summary>
        /// Retrieves the material instance that is bound to the given primitive.
        /// </summary>
        public MaterialInstance GetMaterialInstanceAt(int instance, int primitiveIndex)
        {
            ThrowExceptionIfDisposed();

            return(MaterialInstance.GetOrCreateCache(
                       Native.RenderableManager.GetMaterialInstanceAt(NativePtr, instance, primitiveIndex)
                       ));
        }
예제 #4
0
        /// <summary>
        /// Destroys a MaterialInstance.
        /// </summary>
        /// <param name="materialInstance">A MaterialInstance.</param>
        public bool Destroy(MaterialInstance materialInstance)
        {
            ThrowExceptionIfDisposed();

            materialInstance.Dispose();

            return(Native.Engine.DestroyMaterialInstance(NativePtr, materialInstance.NativePtr));
        }
        /// <summary>
        /// Changes the material instance binding for the given primitive.
        /// </summary>
        public void SetMaterialInstanceAt(int instance, int primitiveIndex, MaterialInstance materialInstance)
        {
            ThrowExceptionIfDisposed();

            Native.RenderableManager.SetMaterialInstanceAt(NativePtr, instance, primitiveIndex, materialInstance.NativePtr);
        }