Material.cs 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // Material.cs
  6. //
  7. // Copyright 2015 Xamarin Inc. All rights reserved.
  8. using System;
  9. using System.Runtime.InteropServices;
  10. using System.Collections.Generic;
  11. using Urho.Urho2D;
  12. using Urho.Gui;
  13. using Urho.Resources;
  14. using Urho.IO;
  15. using Urho.Navigation;
  16. using Urho.Network;
  17. namespace Urho
  18. {
  19. /// <summary>
  20. /// Describes how to render 3D geometries.
  21. /// </summary>
  22. public unsafe partial class Material : Resource
  23. {
  24. unsafe partial void OnMaterialCreated ();
  25. [Preserve]
  26. public Material (IntPtr handle) : base (handle)
  27. {
  28. OnMaterialCreated ();
  29. }
  30. [Preserve]
  31. protected Material (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  32. {
  33. OnMaterialCreated ();
  34. }
  35. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  36. internal static extern int Material_GetType (IntPtr handle);
  37. private StringHash UrhoGetType ()
  38. {
  39. Runtime.ValidateRefCounted (this);
  40. return new StringHash (Material_GetType (handle));
  41. }
  42. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  43. internal static extern IntPtr Material_GetTypeName (IntPtr handle);
  44. private string GetTypeName ()
  45. {
  46. Runtime.ValidateRefCounted (this);
  47. return Marshal.PtrToStringAnsi (Material_GetTypeName (handle));
  48. }
  49. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  50. internal static extern int Material_GetTypeStatic ();
  51. private static StringHash GetTypeStatic ()
  52. {
  53. Runtime.Validate (typeof(Material));
  54. return new StringHash (Material_GetTypeStatic ());
  55. }
  56. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  57. internal static extern IntPtr Material_GetTypeNameStatic ();
  58. private static string GetTypeNameStatic ()
  59. {
  60. Runtime.Validate (typeof(Material));
  61. return Marshal.PtrToStringAnsi (Material_GetTypeNameStatic ());
  62. }
  63. [Preserve]
  64. public Material () : this (Application.CurrentContext)
  65. {
  66. }
  67. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  68. internal static extern IntPtr Material_Material (IntPtr context);
  69. [Preserve]
  70. public Material (Context context) : base (UrhoObjectFlag.Empty)
  71. {
  72. Runtime.Validate (typeof(Material));
  73. handle = Material_Material ((object)context == null ? IntPtr.Zero : context.Handle);
  74. Runtime.RegisterObject (this);
  75. OnMaterialCreated ();
  76. }
  77. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  78. internal static extern void Material_RegisterObject (IntPtr context);
  79. /// <summary>
  80. /// Register object factory.
  81. /// </summary>
  82. public static void RegisterObject (Context context)
  83. {
  84. Runtime.Validate (typeof(Material));
  85. Material_RegisterObject ((object)context == null ? IntPtr.Zero : context.Handle);
  86. }
  87. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  88. internal static extern bool Material_BeginLoad_File (IntPtr handle, IntPtr source);
  89. /// <summary>
  90. /// Load resource from stream. May be called from a worker thread. Return true if successful.
  91. /// </summary>
  92. public override bool BeginLoad (File source)
  93. {
  94. Runtime.ValidateRefCounted (this);
  95. return Material_BeginLoad_File (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  96. }
  97. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  98. internal static extern bool Material_BeginLoad_MemoryBuffer (IntPtr handle, IntPtr source);
  99. /// <summary>
  100. /// Load resource from stream. May be called from a worker thread. Return true if successful.
  101. /// </summary>
  102. public override bool BeginLoad (MemoryBuffer source)
  103. {
  104. Runtime.ValidateRefCounted (this);
  105. return Material_BeginLoad_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  106. }
  107. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  108. internal static extern bool Material_EndLoad (IntPtr handle);
  109. /// <summary>
  110. /// Finish resource loading. Always called from the main thread. Return true if successful.
  111. /// </summary>
  112. public override bool EndLoad ()
  113. {
  114. Runtime.ValidateRefCounted (this);
  115. return Material_EndLoad (handle);
  116. }
  117. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  118. internal static extern bool Material_Save_File (IntPtr handle, IntPtr dest);
  119. /// <summary>
  120. /// Save resource. Return true if successful.
  121. /// </summary>
  122. public override bool Save (File dest)
  123. {
  124. Runtime.ValidateRefCounted (this);
  125. return Material_Save_File (handle, (object)dest == null ? IntPtr.Zero : dest.Handle);
  126. }
  127. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  128. internal static extern bool Material_Save_MemoryBuffer (IntPtr handle, IntPtr dest);
  129. /// <summary>
  130. /// Save resource. Return true if successful.
  131. /// </summary>
  132. public override bool Save (MemoryBuffer dest)
  133. {
  134. Runtime.ValidateRefCounted (this);
  135. return Material_Save_MemoryBuffer (handle, (object)dest == null ? IntPtr.Zero : dest.Handle);
  136. }
  137. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  138. internal static extern bool Material_Load (IntPtr handle, IntPtr source);
  139. /// <summary>
  140. /// Load from an XML element. Return true if successful.
  141. /// </summary>
  142. public bool Load (XmlElement source)
  143. {
  144. Runtime.ValidateRefCounted (this);
  145. return Material_Load (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  146. }
  147. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  148. internal static extern bool Material_Save0 (IntPtr handle, IntPtr dest);
  149. /// <summary>
  150. /// Save to an XML element. Return true if successful.
  151. /// </summary>
  152. public bool Save (XmlElement dest)
  153. {
  154. Runtime.ValidateRefCounted (this);
  155. return Material_Save0 (handle, (object)dest == null ? IntPtr.Zero : dest.Handle);
  156. }
  157. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  158. internal static extern void Material_SetNumTechniques (IntPtr handle, uint num);
  159. /// <summary>
  160. /// Set number of techniques.
  161. /// </summary>
  162. private void SetNumTechniques (uint num)
  163. {
  164. Runtime.ValidateRefCounted (this);
  165. Material_SetNumTechniques (handle, num);
  166. }
  167. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  168. internal static extern void Material_SetTechnique (IntPtr handle, uint index, IntPtr tech, uint qualityLevel, float lodDistance);
  169. /// <summary>
  170. /// Set technique.
  171. /// </summary>
  172. public void SetTechnique (uint index, Technique tech, uint qualityLevel = 0, float lodDistance = 0f)
  173. {
  174. Runtime.ValidateRefCounted (this);
  175. Material_SetTechnique (handle, index, (object)tech == null ? IntPtr.Zero : tech.Handle, qualityLevel, lodDistance);
  176. }
  177. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  178. internal static extern void Material_SetVertexShaderDefines (IntPtr handle, string defines);
  179. /// <summary>
  180. /// Set additional vertex shader defines. Separate multiple defines with spaces. Setting defines at the material level causes technique(s) to be cloned as necessary.
  181. /// </summary>
  182. private void SetVertexShaderDefines (string defines)
  183. {
  184. Runtime.ValidateRefCounted (this);
  185. Material_SetVertexShaderDefines (handle, defines);
  186. }
  187. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  188. internal static extern void Material_SetPixelShaderDefines (IntPtr handle, string defines);
  189. /// <summary>
  190. /// Set additional pixel shader defines. Separate multiple defines with spaces. Setting defines at the material level causes technique(s) to be cloned as necessary.
  191. /// </summary>
  192. private void SetPixelShaderDefines (string defines)
  193. {
  194. Runtime.ValidateRefCounted (this);
  195. Material_SetPixelShaderDefines (handle, defines);
  196. }
  197. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  198. internal static extern void Material_SetShaderParameter_0 (IntPtr handle, string name, ref Vector3 value);
  199. /// <summary>
  200. /// Set shader parameter.
  201. /// </summary>
  202. public void SetShaderParameter (string name, Vector3 value)
  203. {
  204. Runtime.ValidateRefCounted (this);
  205. Material_SetShaderParameter_0 (handle, name, ref value);
  206. }
  207. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  208. internal static extern void Material_SetShaderParameter_1 (IntPtr handle, string name, ref IntRect value);
  209. /// <summary>
  210. /// Set shader parameter.
  211. /// </summary>
  212. public void SetShaderParameter (string name, IntRect value)
  213. {
  214. Runtime.ValidateRefCounted (this);
  215. Material_SetShaderParameter_1 (handle, name, ref value);
  216. }
  217. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  218. internal static extern void Material_SetShaderParameter_2 (IntPtr handle, string name, ref Color value);
  219. /// <summary>
  220. /// Set shader parameter.
  221. /// </summary>
  222. public void SetShaderParameter (string name, Color value)
  223. {
  224. Runtime.ValidateRefCounted (this);
  225. Material_SetShaderParameter_2 (handle, name, ref value);
  226. }
  227. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  228. internal static extern void Material_SetShaderParameter_3 (IntPtr handle, string name, ref Vector2 value);
  229. /// <summary>
  230. /// Set shader parameter.
  231. /// </summary>
  232. public void SetShaderParameter (string name, Vector2 value)
  233. {
  234. Runtime.ValidateRefCounted (this);
  235. Material_SetShaderParameter_3 (handle, name, ref value);
  236. }
  237. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  238. internal static extern void Material_SetShaderParameter_4 (IntPtr handle, string name, ref Vector4 value);
  239. /// <summary>
  240. /// Set shader parameter.
  241. /// </summary>
  242. public void SetShaderParameter (string name, Vector4 value)
  243. {
  244. Runtime.ValidateRefCounted (this);
  245. Material_SetShaderParameter_4 (handle, name, ref value);
  246. }
  247. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  248. internal static extern void Material_SetShaderParameter_5 (IntPtr handle, string name, ref IntVector2 value);
  249. /// <summary>
  250. /// Set shader parameter.
  251. /// </summary>
  252. public void SetShaderParameter (string name, IntVector2 value)
  253. {
  254. Runtime.ValidateRefCounted (this);
  255. Material_SetShaderParameter_5 (handle, name, ref value);
  256. }
  257. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  258. internal static extern void Material_SetShaderParameter_6 (IntPtr handle, string name, ref Quaternion value);
  259. /// <summary>
  260. /// Set shader parameter.
  261. /// </summary>
  262. public void SetShaderParameter (string name, Quaternion value)
  263. {
  264. Runtime.ValidateRefCounted (this);
  265. Material_SetShaderParameter_6 (handle, name, ref value);
  266. }
  267. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  268. internal static extern void Material_SetShaderParameter_7 (IntPtr handle, string name, ref Matrix4 value);
  269. /// <summary>
  270. /// Set shader parameter.
  271. /// </summary>
  272. public void SetShaderParameter (string name, Matrix4 value)
  273. {
  274. Runtime.ValidateRefCounted (this);
  275. Material_SetShaderParameter_7 (handle, name, ref value);
  276. }
  277. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  278. internal static extern void Material_SetShaderParameter_8 (IntPtr handle, string name, ref Matrix3x4 value);
  279. /// <summary>
  280. /// Set shader parameter.
  281. /// </summary>
  282. public void SetShaderParameter (string name, Matrix3x4 value)
  283. {
  284. Runtime.ValidateRefCounted (this);
  285. Material_SetShaderParameter_8 (handle, name, ref value);
  286. }
  287. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  288. internal static extern void Material_SetShaderParameter_9 (IntPtr handle, string name, int value);
  289. /// <summary>
  290. /// Set shader parameter.
  291. /// </summary>
  292. public void SetShaderParameter (string name, int value)
  293. {
  294. Runtime.ValidateRefCounted (this);
  295. Material_SetShaderParameter_9 (handle, name, value);
  296. }
  297. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  298. internal static extern void Material_SetShaderParameter_10 (IntPtr handle, string name, float value);
  299. /// <summary>
  300. /// Set shader parameter.
  301. /// </summary>
  302. public void SetShaderParameter (string name, float value)
  303. {
  304. Runtime.ValidateRefCounted (this);
  305. Material_SetShaderParameter_10 (handle, name, value);
  306. }
  307. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  308. internal static extern void Material_SetShaderParameter_11 (IntPtr handle, string name, string value);
  309. /// <summary>
  310. /// Set shader parameter.
  311. /// </summary>
  312. public void SetShaderParameter (string name, string value)
  313. {
  314. Runtime.ValidateRefCounted (this);
  315. Material_SetShaderParameter_11 (handle, name, value);
  316. }
  317. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  318. internal static extern void Material_SetShaderParameter_12 (IntPtr handle, string name, bool value);
  319. /// <summary>
  320. /// Set shader parameter.
  321. /// </summary>
  322. public void SetShaderParameter (string name, bool value)
  323. {
  324. Runtime.ValidateRefCounted (this);
  325. Material_SetShaderParameter_12 (handle, name, value);
  326. }
  327. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  328. internal static extern void Material_SetShaderParameterAnimation (IntPtr handle, string name, IntPtr animation, WrapMode wrapMode, float speed);
  329. /// <summary>
  330. /// Set shader parameter animation.
  331. /// </summary>
  332. public void SetShaderParameterAnimation (string name, ValueAnimation animation, WrapMode wrapMode = WrapMode.Loop, float speed = 1f)
  333. {
  334. Runtime.ValidateRefCounted (this);
  335. Material_SetShaderParameterAnimation (handle, name, (object)animation == null ? IntPtr.Zero : animation.Handle, wrapMode, speed);
  336. }
  337. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  338. internal static extern void Material_SetShaderParameterAnimationWrapMode (IntPtr handle, string name, WrapMode wrapMode);
  339. /// <summary>
  340. /// Set shader parameter animation wrap mode.
  341. /// </summary>
  342. public void SetShaderParameterAnimationWrapMode (string name, WrapMode wrapMode)
  343. {
  344. Runtime.ValidateRefCounted (this);
  345. Material_SetShaderParameterAnimationWrapMode (handle, name, wrapMode);
  346. }
  347. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  348. internal static extern void Material_SetShaderParameterAnimationSpeed (IntPtr handle, string name, float speed);
  349. /// <summary>
  350. /// Set shader parameter animation speed.
  351. /// </summary>
  352. public void SetShaderParameterAnimationSpeed (string name, float speed)
  353. {
  354. Runtime.ValidateRefCounted (this);
  355. Material_SetShaderParameterAnimationSpeed (handle, name, speed);
  356. }
  357. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  358. internal static extern void Material_SetTexture (IntPtr handle, TextureUnit unit, IntPtr texture);
  359. /// <summary>
  360. /// Set texture.
  361. /// </summary>
  362. public void SetTexture (TextureUnit unit, Texture texture)
  363. {
  364. Runtime.ValidateRefCounted (this);
  365. Material_SetTexture (handle, unit, (object)texture == null ? IntPtr.Zero : texture.Handle);
  366. }
  367. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  368. internal static extern void Material_SetUVTransform (IntPtr handle, ref Urho.Vector2 offset, float rotation, ref Urho.Vector2 repeat);
  369. /// <summary>
  370. /// Set texture coordinate transform.
  371. /// </summary>
  372. public void SetUVTransform (Urho.Vector2 offset, float rotation, Urho.Vector2 repeat)
  373. {
  374. Runtime.ValidateRefCounted (this);
  375. Material_SetUVTransform (handle, ref offset, rotation, ref repeat);
  376. }
  377. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  378. internal static extern void Material_SetUVTransform1 (IntPtr handle, ref Urho.Vector2 offset, float rotation, float repeat);
  379. /// <summary>
  380. /// Set texture coordinate transform.
  381. /// </summary>
  382. public void SetUVTransform (Urho.Vector2 offset, float rotation, float repeat)
  383. {
  384. Runtime.ValidateRefCounted (this);
  385. Material_SetUVTransform1 (handle, ref offset, rotation, repeat);
  386. }
  387. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  388. internal static extern void Material_SetCullMode (IntPtr handle, CullMode mode);
  389. /// <summary>
  390. /// Set culling mode.
  391. /// </summary>
  392. private void SetCullMode (CullMode mode)
  393. {
  394. Runtime.ValidateRefCounted (this);
  395. Material_SetCullMode (handle, mode);
  396. }
  397. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  398. internal static extern void Material_SetShadowCullMode (IntPtr handle, CullMode mode);
  399. /// <summary>
  400. /// Set culling mode for shadows.
  401. /// </summary>
  402. private void SetShadowCullMode (CullMode mode)
  403. {
  404. Runtime.ValidateRefCounted (this);
  405. Material_SetShadowCullMode (handle, mode);
  406. }
  407. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  408. internal static extern void Material_SetFillMode (IntPtr handle, FillMode mode);
  409. /// <summary>
  410. /// Set polygon fill mode. Interacts with the camera's fill mode setting so that the "least filled" mode will be used.
  411. /// </summary>
  412. private void SetFillMode (FillMode mode)
  413. {
  414. Runtime.ValidateRefCounted (this);
  415. Material_SetFillMode (handle, mode);
  416. }
  417. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  418. internal static extern void Material_SetDepthBias (IntPtr handle, ref BiasParameters parameters);
  419. /// <summary>
  420. /// Set depth bias parameters for depth write and compare. Note that the normal offset parameter is not used and will not be saved, as it affects only shadow map sampling during light rendering.
  421. /// </summary>
  422. private void SetDepthBias (BiasParameters parameters)
  423. {
  424. Runtime.ValidateRefCounted (this);
  425. Material_SetDepthBias (handle, ref parameters);
  426. }
  427. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  428. internal static extern void Material_SetAlphaToCoverage (IntPtr handle, bool enable);
  429. /// <summary>
  430. /// Set alpha-to-coverage mode on all passes.
  431. /// </summary>
  432. private void SetAlphaToCoverage (bool enable)
  433. {
  434. Runtime.ValidateRefCounted (this);
  435. Material_SetAlphaToCoverage (handle, enable);
  436. }
  437. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  438. internal static extern void Material_SetLineAntiAlias (IntPtr handle, bool enable);
  439. /// <summary>
  440. /// Set line antialiasing on/off. Has effect only on models that consist of line lists.
  441. /// </summary>
  442. private void SetLineAntiAlias (bool enable)
  443. {
  444. Runtime.ValidateRefCounted (this);
  445. Material_SetLineAntiAlias (handle, enable);
  446. }
  447. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  448. internal static extern void Material_SetRenderOrder (IntPtr handle, byte order);
  449. /// <summary>
  450. /// Set 8-bit render order within pass. Default 128. Lower values will render earlier and higher values later, taking precedence over e.g. state and distance sorting.
  451. /// </summary>
  452. private void SetRenderOrder (byte order)
  453. {
  454. Runtime.ValidateRefCounted (this);
  455. Material_SetRenderOrder (handle, order);
  456. }
  457. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  458. internal static extern void Material_SetOcclusion (IntPtr handle, bool enable);
  459. /// <summary>
  460. /// Set whether to use in occlusion rendering. Default true.
  461. /// </summary>
  462. private void SetOcclusion (bool enable)
  463. {
  464. Runtime.ValidateRefCounted (this);
  465. Material_SetOcclusion (handle, enable);
  466. }
  467. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  468. internal static extern void Material_SetScene (IntPtr handle, IntPtr scene);
  469. /// <summary>
  470. /// Associate the material with a scene to ensure that shader parameter animation happens in sync with scene update, respecting the scene time scale. If no scene is set, the global update events will be used.
  471. /// </summary>
  472. private void SetScene (Scene scene)
  473. {
  474. Runtime.ValidateRefCounted (this);
  475. Material_SetScene (handle, (object)scene == null ? IntPtr.Zero : scene.Handle);
  476. }
  477. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  478. internal static extern void Material_RemoveShaderParameter (IntPtr handle, string name);
  479. /// <summary>
  480. /// Remove shader parameter.
  481. /// </summary>
  482. public void RemoveShaderParameter (string name)
  483. {
  484. Runtime.ValidateRefCounted (this);
  485. Material_RemoveShaderParameter (handle, name);
  486. }
  487. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  488. internal static extern void Material_ReleaseShaders (IntPtr handle);
  489. /// <summary>
  490. /// Reset all shader pointers.
  491. /// </summary>
  492. public void ReleaseShaders ()
  493. {
  494. Runtime.ValidateRefCounted (this);
  495. Material_ReleaseShaders (handle);
  496. }
  497. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  498. internal static extern IntPtr Material_Clone (IntPtr handle, string cloneName);
  499. /// <summary>
  500. /// Clone the material.
  501. /// </summary>
  502. public Material Clone (string cloneName = "")
  503. {
  504. Runtime.ValidateRefCounted (this);
  505. return Runtime.LookupRefCounted<Material> (Material_Clone (handle, cloneName));
  506. }
  507. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  508. internal static extern void Material_SortTechniques (IntPtr handle);
  509. /// <summary>
  510. /// Ensure that material techniques are listed in correct order.
  511. /// </summary>
  512. public void SortTechniques ()
  513. {
  514. Runtime.ValidateRefCounted (this);
  515. Material_SortTechniques (handle);
  516. }
  517. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  518. internal static extern void Material_MarkForAuxView (IntPtr handle, uint frameNumber);
  519. /// <summary>
  520. /// Mark material for auxiliary view rendering.
  521. /// </summary>
  522. public void MarkForAuxView (uint frameNumber)
  523. {
  524. Runtime.ValidateRefCounted (this);
  525. Material_MarkForAuxView (handle, frameNumber);
  526. }
  527. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  528. internal static extern uint Material_GetNumTechniques (IntPtr handle);
  529. /// <summary>
  530. /// Return number of techniques.
  531. /// </summary>
  532. private uint GetNumTechniques ()
  533. {
  534. Runtime.ValidateRefCounted (this);
  535. return Material_GetNumTechniques (handle);
  536. }
  537. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  538. internal static extern IntPtr Material_GetTechnique (IntPtr handle, uint index);
  539. /// <summary>
  540. /// Return technique by index.
  541. /// </summary>
  542. public Technique GetTechnique (uint index)
  543. {
  544. Runtime.ValidateRefCounted (this);
  545. return Runtime.LookupObject<Technique> (Material_GetTechnique (handle, index));
  546. }
  547. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  548. internal static extern IntPtr Material_GetPass (IntPtr handle, uint index, string passName);
  549. /// <summary>
  550. /// Return pass by technique index and pass name.
  551. /// </summary>
  552. public Pass GetPass (uint index, string passName)
  553. {
  554. Runtime.ValidateRefCounted (this);
  555. return Runtime.LookupRefCounted<Pass> (Material_GetPass (handle, index, passName));
  556. }
  557. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  558. internal static extern IntPtr Material_GetTexture (IntPtr handle, TextureUnit unit);
  559. /// <summary>
  560. /// Return texture by unit.
  561. /// </summary>
  562. public Texture GetTexture (TextureUnit unit)
  563. {
  564. Runtime.ValidateRefCounted (this);
  565. return Runtime.LookupObject<Texture> (Material_GetTexture (handle, unit));
  566. }
  567. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  568. internal static extern IntPtr Material_GetVertexShaderDefines (IntPtr handle);
  569. /// <summary>
  570. /// Return additional vertex shader defines.
  571. /// </summary>
  572. private string GetVertexShaderDefines ()
  573. {
  574. Runtime.ValidateRefCounted (this);
  575. return Marshal.PtrToStringAnsi (Material_GetVertexShaderDefines (handle));
  576. }
  577. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  578. internal static extern IntPtr Material_GetPixelShaderDefines (IntPtr handle);
  579. /// <summary>
  580. /// Return additional pixel shader defines.
  581. /// </summary>
  582. private string GetPixelShaderDefines ()
  583. {
  584. Runtime.ValidateRefCounted (this);
  585. return Marshal.PtrToStringAnsi (Material_GetPixelShaderDefines (handle));
  586. }
  587. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  588. internal static extern IntPtr Material_GetShaderParameterAnimation (IntPtr handle, string name);
  589. /// <summary>
  590. /// Return shader parameter animation.
  591. /// </summary>
  592. public ValueAnimation GetShaderParameterAnimation (string name)
  593. {
  594. Runtime.ValidateRefCounted (this);
  595. return Runtime.LookupObject<ValueAnimation> (Material_GetShaderParameterAnimation (handle, name));
  596. }
  597. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  598. internal static extern WrapMode Material_GetShaderParameterAnimationWrapMode (IntPtr handle, string name);
  599. /// <summary>
  600. /// Return shader parameter animation wrap mode.
  601. /// </summary>
  602. public WrapMode GetShaderParameterAnimationWrapMode (string name)
  603. {
  604. Runtime.ValidateRefCounted (this);
  605. return Material_GetShaderParameterAnimationWrapMode (handle, name);
  606. }
  607. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  608. internal static extern float Material_GetShaderParameterAnimationSpeed (IntPtr handle, string name);
  609. /// <summary>
  610. /// Return shader parameter animation speed.
  611. /// </summary>
  612. public float GetShaderParameterAnimationSpeed (string name)
  613. {
  614. Runtime.ValidateRefCounted (this);
  615. return Material_GetShaderParameterAnimationSpeed (handle, name);
  616. }
  617. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  618. internal static extern CullMode Material_GetCullMode (IntPtr handle);
  619. /// <summary>
  620. /// Return normal culling mode.
  621. /// </summary>
  622. private CullMode GetCullMode ()
  623. {
  624. Runtime.ValidateRefCounted (this);
  625. return Material_GetCullMode (handle);
  626. }
  627. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  628. internal static extern CullMode Material_GetShadowCullMode (IntPtr handle);
  629. /// <summary>
  630. /// Return culling mode for shadows.
  631. /// </summary>
  632. private CullMode GetShadowCullMode ()
  633. {
  634. Runtime.ValidateRefCounted (this);
  635. return Material_GetShadowCullMode (handle);
  636. }
  637. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  638. internal static extern FillMode Material_GetFillMode (IntPtr handle);
  639. /// <summary>
  640. /// Return polygon fill mode.
  641. /// </summary>
  642. private FillMode GetFillMode ()
  643. {
  644. Runtime.ValidateRefCounted (this);
  645. return Material_GetFillMode (handle);
  646. }
  647. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  648. internal static extern BiasParameters Material_GetDepthBias (IntPtr handle);
  649. /// <summary>
  650. /// Return depth bias.
  651. /// </summary>
  652. private BiasParameters GetDepthBias ()
  653. {
  654. Runtime.ValidateRefCounted (this);
  655. return Material_GetDepthBias (handle);
  656. }
  657. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  658. internal static extern bool Material_GetAlphaToCoverage (IntPtr handle);
  659. /// <summary>
  660. /// Return alpha-to-coverage mode.
  661. /// </summary>
  662. private bool GetAlphaToCoverage ()
  663. {
  664. Runtime.ValidateRefCounted (this);
  665. return Material_GetAlphaToCoverage (handle);
  666. }
  667. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  668. internal static extern bool Material_GetLineAntiAlias (IntPtr handle);
  669. /// <summary>
  670. /// Return whether line antialiasing is enabled.
  671. /// </summary>
  672. private bool GetLineAntiAlias ()
  673. {
  674. Runtime.ValidateRefCounted (this);
  675. return Material_GetLineAntiAlias (handle);
  676. }
  677. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  678. internal static extern byte Material_GetRenderOrder (IntPtr handle);
  679. /// <summary>
  680. /// Return render order.
  681. /// </summary>
  682. private byte GetRenderOrder ()
  683. {
  684. Runtime.ValidateRefCounted (this);
  685. return Material_GetRenderOrder (handle);
  686. }
  687. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  688. internal static extern uint Material_GetAuxViewFrameNumber (IntPtr handle);
  689. /// <summary>
  690. /// Return last auxiliary view rendered frame number.
  691. /// </summary>
  692. private uint GetAuxViewFrameNumber ()
  693. {
  694. Runtime.ValidateRefCounted (this);
  695. return Material_GetAuxViewFrameNumber (handle);
  696. }
  697. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  698. internal static extern bool Material_GetOcclusion (IntPtr handle);
  699. /// <summary>
  700. /// Return whether should render occlusion.
  701. /// </summary>
  702. private bool GetOcclusion ()
  703. {
  704. Runtime.ValidateRefCounted (this);
  705. return Material_GetOcclusion (handle);
  706. }
  707. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  708. internal static extern bool Material_GetSpecular (IntPtr handle);
  709. /// <summary>
  710. /// Return whether should render specular.
  711. /// </summary>
  712. private bool GetSpecular ()
  713. {
  714. Runtime.ValidateRefCounted (this);
  715. return Material_GetSpecular (handle);
  716. }
  717. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  718. internal static extern IntPtr Material_GetScene (IntPtr handle);
  719. /// <summary>
  720. /// Return the scene associated with the material for shader parameter animation updates.
  721. /// </summary>
  722. private Scene GetScene ()
  723. {
  724. Runtime.ValidateRefCounted (this);
  725. return Runtime.LookupObject<Scene> (Material_GetScene (handle));
  726. }
  727. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  728. internal static extern uint Material_GetShaderParameterHash (IntPtr handle);
  729. /// <summary>
  730. /// Return shader parameter hash value. Used as an optimization to avoid setting shader parameters unnecessarily.
  731. /// </summary>
  732. private uint GetShaderParameterHash ()
  733. {
  734. Runtime.ValidateRefCounted (this);
  735. return Material_GetShaderParameterHash (handle);
  736. }
  737. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  738. internal static extern IntPtr Material_GetTextureUnitName (TextureUnit unit);
  739. /// <summary>
  740. /// Return name for texture unit.
  741. /// </summary>
  742. public static string GetTextureUnitName (TextureUnit unit)
  743. {
  744. Runtime.Validate (typeof(Material));
  745. return Marshal.PtrToStringAnsi (Material_GetTextureUnitName (unit));
  746. }
  747. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  748. internal static extern Variant Material_ParseShaderParameterValue (string value);
  749. /// <summary>
  750. /// Parse a shader parameter value from a string. Retunrs either a bool, a float, or a 2 to 4-component vector.
  751. /// </summary>
  752. public static Variant ParseShaderParameterValue (string value)
  753. {
  754. Runtime.Validate (typeof(Material));
  755. return Material_ParseShaderParameterValue (value);
  756. }
  757. public override StringHash Type {
  758. get {
  759. return UrhoGetType ();
  760. }
  761. }
  762. public override string TypeName {
  763. get {
  764. return GetTypeName ();
  765. }
  766. }
  767. [Preserve]
  768. public new static StringHash TypeStatic {
  769. get {
  770. return GetTypeStatic ();
  771. }
  772. }
  773. public new static string TypeNameStatic {
  774. get {
  775. return GetTypeNameStatic ();
  776. }
  777. }
  778. /// <summary>
  779. /// Return number of techniques.
  780. /// Or
  781. /// Set number of techniques.
  782. /// </summary>
  783. public uint NumTechniques {
  784. get {
  785. return GetNumTechniques ();
  786. }
  787. set {
  788. SetNumTechniques (value);
  789. }
  790. }
  791. /// <summary>
  792. /// Return additional vertex shader defines.
  793. /// Or
  794. /// Set additional vertex shader defines. Separate multiple defines with spaces. Setting defines at the material level causes technique(s) to be cloned as necessary.
  795. /// </summary>
  796. public string VertexShaderDefines {
  797. get {
  798. return GetVertexShaderDefines ();
  799. }
  800. set {
  801. SetVertexShaderDefines (value);
  802. }
  803. }
  804. /// <summary>
  805. /// Return additional pixel shader defines.
  806. /// Or
  807. /// Set additional pixel shader defines. Separate multiple defines with spaces. Setting defines at the material level causes technique(s) to be cloned as necessary.
  808. /// </summary>
  809. public string PixelShaderDefines {
  810. get {
  811. return GetPixelShaderDefines ();
  812. }
  813. set {
  814. SetPixelShaderDefines (value);
  815. }
  816. }
  817. /// <summary>
  818. /// Return normal culling mode.
  819. /// Or
  820. /// Set culling mode.
  821. /// </summary>
  822. public CullMode CullMode {
  823. get {
  824. return GetCullMode ();
  825. }
  826. set {
  827. SetCullMode (value);
  828. }
  829. }
  830. /// <summary>
  831. /// Return culling mode for shadows.
  832. /// Or
  833. /// Set culling mode for shadows.
  834. /// </summary>
  835. public CullMode ShadowCullMode {
  836. get {
  837. return GetShadowCullMode ();
  838. }
  839. set {
  840. SetShadowCullMode (value);
  841. }
  842. }
  843. /// <summary>
  844. /// Return polygon fill mode.
  845. /// Or
  846. /// Set polygon fill mode. Interacts with the camera's fill mode setting so that the "least filled" mode will be used.
  847. /// </summary>
  848. public FillMode FillMode {
  849. get {
  850. return GetFillMode ();
  851. }
  852. set {
  853. SetFillMode (value);
  854. }
  855. }
  856. /// <summary>
  857. /// Return depth bias.
  858. /// Or
  859. /// Set depth bias parameters for depth write and compare. Note that the normal offset parameter is not used and will not be saved, as it affects only shadow map sampling during light rendering.
  860. /// </summary>
  861. public BiasParameters DepthBias {
  862. get {
  863. return GetDepthBias ();
  864. }
  865. set {
  866. SetDepthBias (value);
  867. }
  868. }
  869. /// <summary>
  870. /// Return alpha-to-coverage mode.
  871. /// Or
  872. /// Set alpha-to-coverage mode on all passes.
  873. /// </summary>
  874. public bool AlphaToCoverage {
  875. get {
  876. return GetAlphaToCoverage ();
  877. }
  878. set {
  879. SetAlphaToCoverage (value);
  880. }
  881. }
  882. /// <summary>
  883. /// Return whether line antialiasing is enabled.
  884. /// Or
  885. /// Set line antialiasing on/off. Has effect only on models that consist of line lists.
  886. /// </summary>
  887. public bool LineAntiAlias {
  888. get {
  889. return GetLineAntiAlias ();
  890. }
  891. set {
  892. SetLineAntiAlias (value);
  893. }
  894. }
  895. /// <summary>
  896. /// Return render order.
  897. /// Or
  898. /// Set 8-bit render order within pass. Default 128. Lower values will render earlier and higher values later, taking precedence over e.g. state and distance sorting.
  899. /// </summary>
  900. public byte RenderOrder {
  901. get {
  902. return GetRenderOrder ();
  903. }
  904. set {
  905. SetRenderOrder (value);
  906. }
  907. }
  908. /// <summary>
  909. /// Return whether should render occlusion.
  910. /// Or
  911. /// Set whether to use in occlusion rendering. Default true.
  912. /// </summary>
  913. public bool Occlusion {
  914. get {
  915. return GetOcclusion ();
  916. }
  917. set {
  918. SetOcclusion (value);
  919. }
  920. }
  921. /// <summary>
  922. /// Return the scene associated with the material for shader parameter animation updates.
  923. /// Or
  924. /// Associate the material with a scene to ensure that shader parameter animation happens in sync with scene update, respecting the scene time scale. If no scene is set, the global update events will be used.
  925. /// </summary>
  926. public Scene Scene {
  927. get {
  928. return GetScene ();
  929. }
  930. set {
  931. SetScene (value);
  932. }
  933. }
  934. /// <summary>
  935. /// Return last auxiliary view rendered frame number.
  936. /// </summary>
  937. public uint AuxViewFrameNumber {
  938. get {
  939. return GetAuxViewFrameNumber ();
  940. }
  941. }
  942. /// <summary>
  943. /// Return whether should render specular.
  944. /// </summary>
  945. public bool Specular {
  946. get {
  947. return GetSpecular ();
  948. }
  949. }
  950. /// <summary>
  951. /// Return shader parameter hash value. Used as an optimization to avoid setting shader parameters unnecessarily.
  952. /// </summary>
  953. public uint ShaderParameterHash {
  954. get {
  955. return GetShaderParameterHash ();
  956. }
  957. }
  958. }
  959. }