Exemplo n.º 1
0
        /// <summary>
        /// Sets a material parameter value by name.
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="value"></param>
        /// <returns>true if successful, otherwise false.</returns>
        public bool SetParam(string paramName, ColorSingle value)
        {
            Vector3 vecValue = new Vector3(value.R, value.G, value.B);
            var     result   = MaterialInterop.SetGetMaterialParamVec3(Handle, paramName, ref vecValue, false);

            Opacity = value.A;

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Attempts to get parameter value by name.
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="value"></param>
        /// <returns>true if successful, otherwise false.</returns>
        public bool TryGetParam(string paramName, out ColorSingle value)
        {
            Vector3 vecVal = Vector3.Zero;
            bool    result = MaterialInterop.SetGetMaterialParamVec3(Handle, paramName, ref vecVal, true);

            value = new ColorSingle {
                R = vecVal.X, G = vecVal.Y, B = vecVal.Z, A = this.Opacity
            };

            return(result);
        }
Exemplo n.º 3
0
        public static Material Get(EntityWrapper entity, int slot = 0)
        {
#if !(RELEASE && RELEASE_DISABLE_CHECKS)
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
#endif

            var ptr = MaterialInterop.GetMaterial(entity.Handle, slot);
            return(TryGet(ptr));
        }
Exemplo n.º 4
0
        public static void Set(EntityWrapper entity, Material mat, int slot = 0)
        {
#if !(RELEASE && RELEASE_DISABLE_CHECKS)
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            if (mat == null)
            {
                throw new ArgumentNullException("mat");
            }
#endif

            MaterialInterop.SetMaterial(entity.EntityHandle, mat.Handle, slot);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Gets a shader parameter name by index. See <see cref="ShaderParamCount" />
 /// </summary>
 /// <param name="index"></param>
 /// <returns>The shader parameter name.</returns>
 public string GetShaderParamName(int index)
 {
     return(MaterialInterop.GetShaderParamName(Handle, index));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Sets a shader parameter value by name.
 /// </summary>
 /// <param name="paramName"></param>
 /// <param name="newVal"></param>
 public void SetShaderParam(string paramName, ColorSingle newVal)
 {
     MaterialInterop.SetShaderParam(Handle, paramName, newVal);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Sets a shader parameter value by name.
 /// </summary>
 /// <param name="paramName"></param>
 /// <param name="newVal"></param>
 public void SetShaderParam(string paramName, float newVal)
 {
     MaterialInterop.SetShaderParam(Handle, paramName, newVal);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Attempts to get parameter value by name.
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="value"></param>
        /// <returns>true if successful, otherwise false.</returns>
        public bool TryGetParam(string paramName, out float value)
        {
            value = 0;

            return(MaterialInterop.SetGetMaterialParamFloat(Handle, paramName, ref value, true));
        }
Exemplo n.º 9
0
 /// <summary>
 /// Sets a material parameter value by name.
 /// </summary>
 /// <param name="paramName"></param>
 /// <param name="value"></param>
 /// <returns>true if successful, otherwise false.</returns>
 public bool SetParam(string paramName, float value)
 {
     return(MaterialInterop.SetGetMaterialParamFloat(Handle, paramName, ref value, false));
 }
Exemplo n.º 10
0
        /// <summary>
        /// Clones a material
        /// </summary>
        /// <param name="subMaterial">
        /// If negative, all sub materials are cloned, otherwise only the specified slot is
        /// </param>
        /// <returns>The new clone.</returns>
        public Material Clone(int subMaterial = -1)
        {
            var ptr = MaterialInterop.CloneMaterial(Handle, subMaterial);

            return(TryGet(ptr));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Gets a submaterial by slot.
        /// </summary>
        /// <param name="slot"></param>
        /// <returns>The submaterial, or null if failed.</returns>
        public Material GetSubmaterial(int slot)
        {
            var ptr = MaterialInterop.GetSubMaterial(Handle, slot);

            return(TryGet(ptr));
        }
Exemplo n.º 12
0
        public static Material Load(string name, bool makeIfNotFound = true, bool nonRemovable = false)
        {
            var ptr = MaterialInterop.LoadMaterial(name, makeIfNotFound, nonRemovable);

            return(TryGet(ptr));
        }
Exemplo n.º 13
0
        public static Material Find(string name)
        {
            var ptr = MaterialInterop.FindMaterial(name);

            return(TryGet(ptr));
        }
Exemplo n.º 14
0
 public static SurfaceType Get(string name)
 {
     return(TryGet(MaterialInterop.GetSurfaceTypeByName(name)));
 }
Exemplo n.º 15
0
 public static SurfaceType Get(int id)
 {
     return(TryGet(MaterialInterop.GetSurfaceTypeById(id)));
 }