/// <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); }
/// <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); }
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)); }
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); }
/// <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)); }
/// <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); }
/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
public static Material Load(string name, bool makeIfNotFound = true, bool nonRemovable = false) { var ptr = MaterialInterop.LoadMaterial(name, makeIfNotFound, nonRemovable); return(TryGet(ptr)); }
public static Material Find(string name) { var ptr = MaterialInterop.FindMaterial(name); return(TryGet(ptr)); }
public static SurfaceType Get(string name) { return(TryGet(MaterialInterop.GetSurfaceTypeByName(name))); }
public static SurfaceType Get(int id) { return(TryGet(MaterialInterop.GetSurfaceTypeById(id))); }