using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace BansheeEngine
{
/** @addtogroup Rendering
* @{
*/
///
/// Material that controls how objects are rendered. It is represented by a shader and parameters used to set up that
/// shader. It provides a simple interface for manipulating the parameters.
///
public partial class Material : Resource
{
private Material(bool __dummy0) { }
/// Creates a new empty material.
public Material()
{
Internal_create(this);
}
/// Creates a new material with the specified shader.
public Material(Shader shader)
{
Internal_create0(this, shader);
}
///
/// Sets a shader that will be used by the material. Material will be initialized using all compatible techniques from
/// the shader. Shader must be set before doing any other operations with the material.
///
public Shader Shader
{
get { return Internal_getShader(mCachedPtr); }
set { Internal_setShader(mCachedPtr, value); }
}
/// Creates a deep copy of the material and returns the new object.
public Material Clone()
{
return Internal_clone(mCachedPtr);
}
///
/// Assigns a float value to the shader parameter with the specified name.
///
/// Optionally if the parameter is an array you may provide an array index to assign the value to.
///
public void SetFloat(string name, float value, uint arrayIdx = 0)
{
Internal_setFloat(mCachedPtr, name, value, arrayIdx);
}
public void SetFloatCurve(string name, AnimationCurve value, uint arrayIdx = 0)
{
Internal_setFloatCurve(mCachedPtr, name, value, arrayIdx);
}
///
/// Assigns a color to the shader parameter with the specified name.
///
/// Optionally if the parameter is an array you may provide an array index to assign the value to.
///
public void SetColor(string name, Color value, uint arrayIdx = 0)
{
Internal_setColor(mCachedPtr, name, ref value, arrayIdx);
}
///
/// Assigns a color gradient to the shader parameter with the specified name. The system will automatically evaluate the
/// gradient with the passage of time and apply the evaluated value to the parameter.
///
/// Optionally if the parameter is an array you may provide an array index to assign the value to.
///
public void SetColorGradient(string name, ColorGradient value, uint arrayIdx = 0)
{
Internal_setColorGradient(mCachedPtr, name, value, arrayIdx);
}
///
/// Assigns a 2D vector to the shader parameter with the specified name.
///
/// Optionally if the parameter is an array you may provide an array index to assign the value to.
///
public void SetVector2(string name, Vector2 value, uint arrayIdx = 0)
{
Internal_setVec2(mCachedPtr, name, ref value, arrayIdx);
}
///
/// Assigns a 3D vector to the shader parameter with the specified name.
///
/// Optionally if the parameter is an array you may provide an array index to assign the value to.
///
public void SetVector3(string name, Vector3 value, uint arrayIdx = 0)
{
Internal_setVec3(mCachedPtr, name, ref value, arrayIdx);
}
///
/// Assigns a 4D vector to the shader parameter with the specified name.
///
/// Optionally if the parameter is an array you may provide an array index to assign the value to.
///
public void SetVector4(string name, Vector4 value, uint arrayIdx = 0)
{
Internal_setVec4(mCachedPtr, name, ref value, arrayIdx);
}
///
/// Assigns a 3x3 matrix to the shader parameter with the specified name.
///
/// Optionally if the parameter is an array you may provide an array index to assign the value to.
///
public void SetMatrix3(string name, Matrix3 value, uint arrayIdx = 0)
{
Internal_setMat3(mCachedPtr, name, ref value, arrayIdx);
}
///
/// Assigns a 4x4 matrix to the shader parameter with the specified name.
///
/// Optionally if the parameter is an array you may provide an array index to assign the value to.
///
public void SetMatrix4(string name, Matrix4 value, uint arrayIdx = 0)
{
Internal_setMat4(mCachedPtr, name, ref value, arrayIdx);
}
///
/// Returns a float value assigned with the parameter with the specified name. If a curve is assigned to this parameter,
/// returns the curve value evaluated at time 0. Use getBoundParamType() to determine the type of the parameter.
///
/// Optionally if the parameter is an array you may provide an array index you which to retrieve.
///
public float GetFloat(string name, uint arrayIdx = 0)
{
return Internal_getFloat(mCachedPtr, name, arrayIdx);
}
///
/// Returns a curve value assigned to the parameter with the specified name. If the parameter has a constant value bound
/// instead of a curve then this method returns an empty curve. Use getBoundParamType() to determine the type of the
/// parameter.
///
/// Optionally if the parameter is an array you may provide an array index you which to retrieve.
///
public AnimationCurve GetFloatCurve(string name, uint arrayIdx = 0)
{
return Internal_getFloatCurve(mCachedPtr, name, arrayIdx);
}
///
/// Returns a color assigned with the parameter with the specified name. If a color gradient is assigned to this
/// parameter, returns the gradient color evaluated at time 0. Use getBoundParamType() to determine the type of the
/// parameter.
///
/// Optionally if the parameter is an array you may provide an array index you which to retrieve.
///
public Color GetColor(string name, uint arrayIdx = 0)
{
Color temp;
Internal_getColor(mCachedPtr, name, arrayIdx, out temp);
return temp;
}
///
/// Returns a color gradient assigned with the parameter with the specified name. If the parameter has a constant value
/// bound instead of a gradient then this method returns an empty gradient. Use getBoundParamType() to determine the type
/// of the parameter.
///
/// Optionally if the parameter is an array you may provide an array index you which to retrieve.
///
public ColorGradient GetColorGradient(string name, uint arrayIdx = 0)
{
return Internal_getColorGradient(mCachedPtr, name, arrayIdx);
}
///
/// Returns a 2D vector assigned with the parameter with the specified name.
///
/// Optionally if the parameter is an array you may provide an array index you which to retrieve.
///
public Vector2 GetVector2(string name, uint arrayIdx = 0)
{
Vector2 temp;
Internal_getVec2(mCachedPtr, name, arrayIdx, out temp);
return temp;
}
///
/// Returns a 3D vector assigned with the parameter with the specified name.
///
/// Optionally if the parameter is an array you may provide an array index you which to retrieve.
///
public Vector3 GetVector3(string name, uint arrayIdx = 0)
{
Vector3 temp;
Internal_getVec3(mCachedPtr, name, arrayIdx, out temp);
return temp;
}
///
/// Returns a 4D vector assigned with the parameter with the specified name.
///
/// Optionally if the parameter is an array you may provide an array index you which to retrieve.
///
public Vector4 GetVector4(string name, uint arrayIdx = 0)
{
Vector4 temp;
Internal_getVec4(mCachedPtr, name, arrayIdx, out temp);
return temp;
}
///
/// Returns a 3x3 matrix assigned with the parameter with the specified name.
///
/// Optionally if the parameter is an array you may provide an array index you which to retrieve.
///
public Matrix3 GetMatrix3(string name, uint arrayIdx = 0)
{
Matrix3 temp;
Internal_getMat3(mCachedPtr, name, arrayIdx, out temp);
return temp;
}
///
/// Returns a 4x4 matrix assigned with the parameter with the specified name.
///
/// Optionally if the parameter is an array you may provide an array index you which to retrieve.
///
public Matrix4 GetMatrix4(string name, uint arrayIdx = 0)
{
Matrix4 temp;
Internal_getMat4(mCachedPtr, name, arrayIdx, out temp);
return temp;
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setShader(IntPtr thisPtr, Shader shader);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern Material Internal_clone(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern Shader Internal_getShader(IntPtr thisPtr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setFloat(IntPtr thisPtr, string name, float value, uint arrayIdx);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setFloatCurve(IntPtr thisPtr, string name, AnimationCurve value, uint arrayIdx);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setColor(IntPtr thisPtr, string name, ref Color value, uint arrayIdx);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setColorGradient(IntPtr thisPtr, string name, ColorGradient value, uint arrayIdx);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setVec2(IntPtr thisPtr, string name, ref Vector2 value, uint arrayIdx);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setVec3(IntPtr thisPtr, string name, ref Vector3 value, uint arrayIdx);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setVec4(IntPtr thisPtr, string name, ref Vector4 value, uint arrayIdx);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setMat3(IntPtr thisPtr, string name, ref Matrix3 value, uint arrayIdx);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setMat4(IntPtr thisPtr, string name, ref Matrix4 value, uint arrayIdx);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern float Internal_getFloat(IntPtr thisPtr, string name, uint arrayIdx);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern AnimationCurve Internal_getFloatCurve(IntPtr thisPtr, string name, uint arrayIdx);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_getColor(IntPtr thisPtr, string name, uint arrayIdx, out Color __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern ColorGradient Internal_getColorGradient(IntPtr thisPtr, string name, uint arrayIdx);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_getVec2(IntPtr thisPtr, string name, uint arrayIdx, out Vector2 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_getVec3(IntPtr thisPtr, string name, uint arrayIdx, out Vector3 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_getVec4(IntPtr thisPtr, string name, uint arrayIdx, out Vector4 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_getMat3(IntPtr thisPtr, string name, uint arrayIdx, out Matrix3 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_getMat4(IntPtr thisPtr, string name, uint arrayIdx, out Matrix4 __output);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_create(Material managedInstance);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_create0(Material managedInstance, Shader shader);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setTexture(IntPtr thisPtr, string name, Texture value, uint mipLevel, uint numMipLevels, uint arraySlice, uint numArraySlices);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern Texture Internal_getTexture(IntPtr thisPtr, string name);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_setSpriteTexture(IntPtr thisPtr, string name, SpriteTexture value);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern SpriteTexture Internal_getSpriteTexture(IntPtr thisPtr, string name);
}
/** @} */
}