Material.generated.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using System.Runtime.InteropServices;
  4. namespace BansheeEngine
  5. {
  6. /** @addtogroup Rendering
  7. * @{
  8. */
  9. /// <summary>
  10. /// Material that controls how objects are rendered. It is represented by a shader and parameters used to set up that
  11. /// shader. It provides a simple interface for manipulating the parameters.
  12. /// </summary>
  13. public partial class Material : Resource
  14. {
  15. private Material(bool __dummy0) { }
  16. /// <summary>Creates a new empty material.</summary>
  17. public Material()
  18. {
  19. Internal_create(this);
  20. }
  21. /// <summary>Creates a new material with the specified shader.</summary>
  22. public Material(Shader shader)
  23. {
  24. Internal_create0(this, shader);
  25. }
  26. /// <summary>
  27. /// Sets a shader that will be used by the material. Material will be initialized using all compatible techniques from
  28. /// the shader. Shader must be set before doing any other operations with the material.
  29. /// </summary>
  30. public Shader Shader
  31. {
  32. get { return Internal_getShader(mCachedPtr); }
  33. set { Internal_setShader(mCachedPtr, value); }
  34. }
  35. /// <summary>Creates a deep copy of the material and returns the new object.</summary>
  36. public Material Clone()
  37. {
  38. return Internal_clone(mCachedPtr);
  39. }
  40. /// <summary>
  41. /// Assigns a float value to the shader parameter with the specified name.
  42. ///
  43. /// Optionally if the parameter is an array you may provide an array index to assign the value to.
  44. /// </summary>
  45. public void SetFloat(string name, float value, uint arrayIdx = 0)
  46. {
  47. Internal_setFloat(mCachedPtr, name, value, arrayIdx);
  48. }
  49. public void SetFloatCurve(string name, AnimationCurve value, uint arrayIdx = 0)
  50. {
  51. Internal_setFloatCurve(mCachedPtr, name, value, arrayIdx);
  52. }
  53. /// <summary>
  54. /// Assigns a color to the shader parameter with the specified name.
  55. ///
  56. /// Optionally if the parameter is an array you may provide an array index to assign the value to.
  57. /// </summary>
  58. public void SetColor(string name, Color value, uint arrayIdx = 0)
  59. {
  60. Internal_setColor(mCachedPtr, name, ref value, arrayIdx);
  61. }
  62. /// <summary>
  63. /// Assigns a color gradient to the shader parameter with the specified name. The system will automatically evaluate the
  64. /// gradient with the passage of time and apply the evaluated value to the parameter.
  65. ///
  66. /// Optionally if the parameter is an array you may provide an array index to assign the value to.
  67. /// </summary>
  68. public void SetColorGradient(string name, ColorGradient value, uint arrayIdx = 0)
  69. {
  70. Internal_setColorGradient(mCachedPtr, name, value, arrayIdx);
  71. }
  72. /// <summary>
  73. /// Assigns a 2D vector to the shader parameter with the specified name.
  74. ///
  75. /// Optionally if the parameter is an array you may provide an array index to assign the value to.
  76. /// </summary>
  77. public void SetVector2(string name, Vector2 value, uint arrayIdx = 0)
  78. {
  79. Internal_setVec2(mCachedPtr, name, ref value, arrayIdx);
  80. }
  81. /// <summary>
  82. /// Assigns a 3D vector to the shader parameter with the specified name.
  83. ///
  84. /// Optionally if the parameter is an array you may provide an array index to assign the value to.
  85. /// </summary>
  86. public void SetVector3(string name, Vector3 value, uint arrayIdx = 0)
  87. {
  88. Internal_setVec3(mCachedPtr, name, ref value, arrayIdx);
  89. }
  90. /// <summary>
  91. /// Assigns a 4D vector to the shader parameter with the specified name.
  92. ///
  93. /// Optionally if the parameter is an array you may provide an array index to assign the value to.
  94. /// </summary>
  95. public void SetVector4(string name, Vector4 value, uint arrayIdx = 0)
  96. {
  97. Internal_setVec4(mCachedPtr, name, ref value, arrayIdx);
  98. }
  99. /// <summary>
  100. /// Assigns a 3x3 matrix to the shader parameter with the specified name.
  101. ///
  102. /// Optionally if the parameter is an array you may provide an array index to assign the value to.
  103. /// </summary>
  104. public void SetMatrix3(string name, Matrix3 value, uint arrayIdx = 0)
  105. {
  106. Internal_setMat3(mCachedPtr, name, ref value, arrayIdx);
  107. }
  108. /// <summary>
  109. /// Assigns a 4x4 matrix to the shader parameter with the specified name.
  110. ///
  111. /// Optionally if the parameter is an array you may provide an array index to assign the value to.
  112. /// </summary>
  113. public void SetMatrix4(string name, Matrix4 value, uint arrayIdx = 0)
  114. {
  115. Internal_setMat4(mCachedPtr, name, ref value, arrayIdx);
  116. }
  117. /// <summary>
  118. /// Returns a float value assigned with the parameter with the specified name. If a curve is assigned to this parameter,
  119. /// returns the curve value evaluated at time 0. Use getBoundParamType() to determine the type of the parameter.
  120. ///
  121. /// Optionally if the parameter is an array you may provide an array index you which to retrieve.
  122. /// </summary>
  123. public float GetFloat(string name, uint arrayIdx = 0)
  124. {
  125. return Internal_getFloat(mCachedPtr, name, arrayIdx);
  126. }
  127. /// <summary>
  128. /// Returns a curve value assigned to the parameter with the specified name. If the parameter has a constant value bound
  129. /// instead of a curve then this method returns an empty curve. Use getBoundParamType() to determine the type of the
  130. /// parameter.
  131. ///
  132. /// Optionally if the parameter is an array you may provide an array index you which to retrieve.
  133. /// </summary>
  134. public AnimationCurve GetFloatCurve(string name, uint arrayIdx = 0)
  135. {
  136. return Internal_getFloatCurve(mCachedPtr, name, arrayIdx);
  137. }
  138. /// <summary>
  139. /// Returns a color assigned with the parameter with the specified name. If a color gradient is assigned to this
  140. /// parameter, returns the gradient color evaluated at time 0. Use getBoundParamType() to determine the type of the
  141. /// parameter.
  142. ///
  143. /// Optionally if the parameter is an array you may provide an array index you which to retrieve.
  144. /// </summary>
  145. public Color GetColor(string name, uint arrayIdx = 0)
  146. {
  147. Color temp;
  148. Internal_getColor(mCachedPtr, name, arrayIdx, out temp);
  149. return temp;
  150. }
  151. /// <summary>
  152. /// Returns a color gradient assigned with the parameter with the specified name. If the parameter has a constant value
  153. /// bound instead of a gradient then this method returns an empty gradient. Use getBoundParamType() to determine the type
  154. /// of the parameter.
  155. ///
  156. /// Optionally if the parameter is an array you may provide an array index you which to retrieve.
  157. /// </summary>
  158. public ColorGradient GetColorGradient(string name, uint arrayIdx = 0)
  159. {
  160. return Internal_getColorGradient(mCachedPtr, name, arrayIdx);
  161. }
  162. /// <summary>
  163. /// Returns a 2D vector assigned with the parameter with the specified name.
  164. ///
  165. /// Optionally if the parameter is an array you may provide an array index you which to retrieve.
  166. /// </summary>
  167. public Vector2 GetVector2(string name, uint arrayIdx = 0)
  168. {
  169. Vector2 temp;
  170. Internal_getVec2(mCachedPtr, name, arrayIdx, out temp);
  171. return temp;
  172. }
  173. /// <summary>
  174. /// Returns a 3D vector assigned with the parameter with the specified name.
  175. ///
  176. /// Optionally if the parameter is an array you may provide an array index you which to retrieve.
  177. /// </summary>
  178. public Vector3 GetVector3(string name, uint arrayIdx = 0)
  179. {
  180. Vector3 temp;
  181. Internal_getVec3(mCachedPtr, name, arrayIdx, out temp);
  182. return temp;
  183. }
  184. /// <summary>
  185. /// Returns a 4D vector assigned with the parameter with the specified name.
  186. ///
  187. /// Optionally if the parameter is an array you may provide an array index you which to retrieve.
  188. /// </summary>
  189. public Vector4 GetVector4(string name, uint arrayIdx = 0)
  190. {
  191. Vector4 temp;
  192. Internal_getVec4(mCachedPtr, name, arrayIdx, out temp);
  193. return temp;
  194. }
  195. /// <summary>
  196. /// Returns a 3x3 matrix assigned with the parameter with the specified name.
  197. ///
  198. /// Optionally if the parameter is an array you may provide an array index you which to retrieve.
  199. /// </summary>
  200. public Matrix3 GetMatrix3(string name, uint arrayIdx = 0)
  201. {
  202. Matrix3 temp;
  203. Internal_getMat3(mCachedPtr, name, arrayIdx, out temp);
  204. return temp;
  205. }
  206. /// <summary>
  207. /// Returns a 4x4 matrix assigned with the parameter with the specified name.
  208. ///
  209. /// Optionally if the parameter is an array you may provide an array index you which to retrieve.
  210. /// </summary>
  211. public Matrix4 GetMatrix4(string name, uint arrayIdx = 0)
  212. {
  213. Matrix4 temp;
  214. Internal_getMat4(mCachedPtr, name, arrayIdx, out temp);
  215. return temp;
  216. }
  217. [MethodImpl(MethodImplOptions.InternalCall)]
  218. private static extern void Internal_setShader(IntPtr thisPtr, Shader shader);
  219. [MethodImpl(MethodImplOptions.InternalCall)]
  220. private static extern Material Internal_clone(IntPtr thisPtr);
  221. [MethodImpl(MethodImplOptions.InternalCall)]
  222. private static extern Shader Internal_getShader(IntPtr thisPtr);
  223. [MethodImpl(MethodImplOptions.InternalCall)]
  224. private static extern void Internal_setFloat(IntPtr thisPtr, string name, float value, uint arrayIdx);
  225. [MethodImpl(MethodImplOptions.InternalCall)]
  226. private static extern void Internal_setFloatCurve(IntPtr thisPtr, string name, AnimationCurve value, uint arrayIdx);
  227. [MethodImpl(MethodImplOptions.InternalCall)]
  228. private static extern void Internal_setColor(IntPtr thisPtr, string name, ref Color value, uint arrayIdx);
  229. [MethodImpl(MethodImplOptions.InternalCall)]
  230. private static extern void Internal_setColorGradient(IntPtr thisPtr, string name, ColorGradient value, uint arrayIdx);
  231. [MethodImpl(MethodImplOptions.InternalCall)]
  232. private static extern void Internal_setVec2(IntPtr thisPtr, string name, ref Vector2 value, uint arrayIdx);
  233. [MethodImpl(MethodImplOptions.InternalCall)]
  234. private static extern void Internal_setVec3(IntPtr thisPtr, string name, ref Vector3 value, uint arrayIdx);
  235. [MethodImpl(MethodImplOptions.InternalCall)]
  236. private static extern void Internal_setVec4(IntPtr thisPtr, string name, ref Vector4 value, uint arrayIdx);
  237. [MethodImpl(MethodImplOptions.InternalCall)]
  238. private static extern void Internal_setMat3(IntPtr thisPtr, string name, ref Matrix3 value, uint arrayIdx);
  239. [MethodImpl(MethodImplOptions.InternalCall)]
  240. private static extern void Internal_setMat4(IntPtr thisPtr, string name, ref Matrix4 value, uint arrayIdx);
  241. [MethodImpl(MethodImplOptions.InternalCall)]
  242. private static extern float Internal_getFloat(IntPtr thisPtr, string name, uint arrayIdx);
  243. [MethodImpl(MethodImplOptions.InternalCall)]
  244. private static extern AnimationCurve Internal_getFloatCurve(IntPtr thisPtr, string name, uint arrayIdx);
  245. [MethodImpl(MethodImplOptions.InternalCall)]
  246. private static extern void Internal_getColor(IntPtr thisPtr, string name, uint arrayIdx, out Color __output);
  247. [MethodImpl(MethodImplOptions.InternalCall)]
  248. private static extern ColorGradient Internal_getColorGradient(IntPtr thisPtr, string name, uint arrayIdx);
  249. [MethodImpl(MethodImplOptions.InternalCall)]
  250. private static extern void Internal_getVec2(IntPtr thisPtr, string name, uint arrayIdx, out Vector2 __output);
  251. [MethodImpl(MethodImplOptions.InternalCall)]
  252. private static extern void Internal_getVec3(IntPtr thisPtr, string name, uint arrayIdx, out Vector3 __output);
  253. [MethodImpl(MethodImplOptions.InternalCall)]
  254. private static extern void Internal_getVec4(IntPtr thisPtr, string name, uint arrayIdx, out Vector4 __output);
  255. [MethodImpl(MethodImplOptions.InternalCall)]
  256. private static extern void Internal_getMat3(IntPtr thisPtr, string name, uint arrayIdx, out Matrix3 __output);
  257. [MethodImpl(MethodImplOptions.InternalCall)]
  258. private static extern void Internal_getMat4(IntPtr thisPtr, string name, uint arrayIdx, out Matrix4 __output);
  259. [MethodImpl(MethodImplOptions.InternalCall)]
  260. private static extern void Internal_create(Material managedInstance);
  261. [MethodImpl(MethodImplOptions.InternalCall)]
  262. private static extern void Internal_create0(Material managedInstance, Shader shader);
  263. [MethodImpl(MethodImplOptions.InternalCall)]
  264. private static extern void Internal_setTexture(IntPtr thisPtr, string name, Texture value, uint mipLevel, uint numMipLevels, uint arraySlice, uint numArraySlices);
  265. [MethodImpl(MethodImplOptions.InternalCall)]
  266. private static extern Texture Internal_getTexture(IntPtr thisPtr, string name);
  267. [MethodImpl(MethodImplOptions.InternalCall)]
  268. private static extern void Internal_setSpriteTexture(IntPtr thisPtr, string name, SpriteTexture value);
  269. [MethodImpl(MethodImplOptions.InternalCall)]
  270. private static extern SpriteTexture Internal_getSpriteTexture(IntPtr thisPtr, string name);
  271. }
  272. /** @} */
  273. }