CustomGeometry.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // CustomGeometry.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. /// Custom geometry component.
  21. /// </summary>
  22. public unsafe partial class CustomGeometry : Drawable
  23. {
  24. unsafe partial void OnCustomGeometryCreated ();
  25. [Preserve]
  26. public CustomGeometry (IntPtr handle) : base (handle)
  27. {
  28. OnCustomGeometryCreated ();
  29. }
  30. [Preserve]
  31. protected CustomGeometry (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  32. {
  33. OnCustomGeometryCreated ();
  34. }
  35. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  36. internal static extern int CustomGeometry_GetType (IntPtr handle);
  37. private StringHash UrhoGetType ()
  38. {
  39. Runtime.ValidateRefCounted (this);
  40. return new StringHash (CustomGeometry_GetType (handle));
  41. }
  42. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  43. internal static extern IntPtr CustomGeometry_GetTypeName (IntPtr handle);
  44. private string GetTypeName ()
  45. {
  46. Runtime.ValidateRefCounted (this);
  47. return Marshal.PtrToStringAnsi (CustomGeometry_GetTypeName (handle));
  48. }
  49. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  50. internal static extern int CustomGeometry_GetTypeStatic ();
  51. private static StringHash GetTypeStatic ()
  52. {
  53. Runtime.Validate (typeof(CustomGeometry));
  54. return new StringHash (CustomGeometry_GetTypeStatic ());
  55. }
  56. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  57. internal static extern IntPtr CustomGeometry_GetTypeNameStatic ();
  58. private static string GetTypeNameStatic ()
  59. {
  60. Runtime.Validate (typeof(CustomGeometry));
  61. return Marshal.PtrToStringAnsi (CustomGeometry_GetTypeNameStatic ());
  62. }
  63. [Preserve]
  64. public CustomGeometry () : this (Application.CurrentContext)
  65. {
  66. }
  67. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  68. internal static extern IntPtr CustomGeometry_CustomGeometry (IntPtr context);
  69. [Preserve]
  70. public CustomGeometry (Context context) : base (UrhoObjectFlag.Empty)
  71. {
  72. Runtime.Validate (typeof(CustomGeometry));
  73. handle = CustomGeometry_CustomGeometry ((object)context == null ? IntPtr.Zero : context.Handle);
  74. Runtime.RegisterObject (this);
  75. OnCustomGeometryCreated ();
  76. }
  77. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  78. internal static extern void CustomGeometry_RegisterObject (IntPtr context);
  79. /// <summary>
  80. /// Register object factory. Drawable must be registered first.
  81. /// </summary>
  82. public new static void RegisterObject (Context context)
  83. {
  84. Runtime.Validate (typeof(CustomGeometry));
  85. CustomGeometry_RegisterObject ((object)context == null ? IntPtr.Zero : context.Handle);
  86. }
  87. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  88. internal static extern IntPtr CustomGeometry_GetLodGeometry (IntPtr handle, uint batchIndex, uint level);
  89. /// <summary>
  90. /// Return the geometry for a specific LOD level.
  91. /// </summary>
  92. public override Geometry GetLodGeometry (uint batchIndex, uint level)
  93. {
  94. Runtime.ValidateRefCounted (this);
  95. return Runtime.LookupObject<Geometry> (CustomGeometry_GetLodGeometry (handle, batchIndex, level));
  96. }
  97. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  98. internal static extern uint CustomGeometry_GetNumOccluderTriangles (IntPtr handle);
  99. /// <summary>
  100. /// Return number of occlusion geometry triangles.
  101. /// </summary>
  102. private uint GetNumOccluderTriangles ()
  103. {
  104. Runtime.ValidateRefCounted (this);
  105. return CustomGeometry_GetNumOccluderTriangles (handle);
  106. }
  107. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  108. internal static extern bool CustomGeometry_DrawOcclusion (IntPtr handle, IntPtr buffer);
  109. /// <summary>
  110. /// Draw to occlusion buffer. Return true if did not run out of triangles.
  111. /// </summary>
  112. public override bool DrawOcclusion (OcclusionBuffer buffer)
  113. {
  114. Runtime.ValidateRefCounted (this);
  115. return CustomGeometry_DrawOcclusion (handle, (object)buffer == null ? IntPtr.Zero : buffer.Handle);
  116. }
  117. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  118. internal static extern void CustomGeometry_Clear (IntPtr handle);
  119. /// <summary>
  120. /// Clear all geometries.
  121. /// </summary>
  122. public void Clear ()
  123. {
  124. Runtime.ValidateRefCounted (this);
  125. CustomGeometry_Clear (handle);
  126. }
  127. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  128. internal static extern void CustomGeometry_SetNumGeometries (IntPtr handle, uint num);
  129. /// <summary>
  130. /// Set number of geometries.
  131. /// </summary>
  132. private void SetNumGeometries (uint num)
  133. {
  134. Runtime.ValidateRefCounted (this);
  135. CustomGeometry_SetNumGeometries (handle, num);
  136. }
  137. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  138. internal static extern void CustomGeometry_SetDynamic (IntPtr handle, bool enable);
  139. /// <summary>
  140. /// Set vertex buffer dynamic mode. A dynamic buffer should be faster to update frequently. Effective at the next Commit() call.
  141. /// </summary>
  142. private void SetDynamic (bool enable)
  143. {
  144. Runtime.ValidateRefCounted (this);
  145. CustomGeometry_SetDynamic (handle, enable);
  146. }
  147. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  148. internal static extern void CustomGeometry_BeginGeometry (IntPtr handle, uint index, PrimitiveType type);
  149. /// <summary>
  150. /// Begin defining a geometry. Clears existing vertices in that index.
  151. /// </summary>
  152. public void BeginGeometry (uint index, PrimitiveType type)
  153. {
  154. Runtime.ValidateRefCounted (this);
  155. CustomGeometry_BeginGeometry (handle, index, type);
  156. }
  157. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  158. internal static extern void CustomGeometry_DefineVertex (IntPtr handle, ref Urho.Vector3 position);
  159. /// <summary>
  160. /// Define a vertex position. This begins a new vertex.
  161. /// </summary>
  162. public void DefineVertex (Urho.Vector3 position)
  163. {
  164. Runtime.ValidateRefCounted (this);
  165. CustomGeometry_DefineVertex (handle, ref position);
  166. }
  167. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  168. internal static extern void CustomGeometry_DefineNormal (IntPtr handle, ref Urho.Vector3 normal);
  169. /// <summary>
  170. /// Define a vertex normal.
  171. /// </summary>
  172. public void DefineNormal (Urho.Vector3 normal)
  173. {
  174. Runtime.ValidateRefCounted (this);
  175. CustomGeometry_DefineNormal (handle, ref normal);
  176. }
  177. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  178. internal static extern void CustomGeometry_DefineColor (IntPtr handle, ref Urho.Color color);
  179. /// <summary>
  180. /// Define a vertex color.
  181. /// </summary>
  182. public void DefineColor (Urho.Color color)
  183. {
  184. Runtime.ValidateRefCounted (this);
  185. CustomGeometry_DefineColor (handle, ref color);
  186. }
  187. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  188. internal static extern void CustomGeometry_DefineTexCoord (IntPtr handle, ref Urho.Vector2 texCoord);
  189. /// <summary>
  190. /// Define a vertex UV coordinate.
  191. /// </summary>
  192. public void DefineTexCoord (Urho.Vector2 texCoord)
  193. {
  194. Runtime.ValidateRefCounted (this);
  195. CustomGeometry_DefineTexCoord (handle, ref texCoord);
  196. }
  197. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  198. internal static extern void CustomGeometry_DefineTangent (IntPtr handle, ref Urho.Vector4 tangent);
  199. /// <summary>
  200. /// Define a vertex tangent.
  201. /// </summary>
  202. public void DefineTangent (Urho.Vector4 tangent)
  203. {
  204. Runtime.ValidateRefCounted (this);
  205. CustomGeometry_DefineTangent (handle, ref tangent);
  206. }
  207. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  208. internal static extern void CustomGeometry_DefineGeometry (IntPtr handle, uint index, PrimitiveType type, uint numVertices, bool hasNormals, bool hasColors, bool hasTexCoords, bool hasTangents);
  209. /// <summary>
  210. /// Set the primitive type, number of vertices and elements in a geometry, after which the vertices can be edited with GetVertex(). An alternative to BeginGeometry() / DefineVertex().
  211. /// </summary>
  212. public void DefineGeometry (uint index, PrimitiveType type, uint numVertices, bool hasNormals, bool hasColors, bool hasTexCoords, bool hasTangents)
  213. {
  214. Runtime.ValidateRefCounted (this);
  215. CustomGeometry_DefineGeometry (handle, index, type, numVertices, hasNormals, hasColors, hasTexCoords, hasTangents);
  216. }
  217. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  218. internal static extern void CustomGeometry_Commit (IntPtr handle);
  219. /// <summary>
  220. /// Update vertex buffer and calculate the bounding box. Call after finishing defining geometry.
  221. /// </summary>
  222. public void Commit ()
  223. {
  224. Runtime.ValidateRefCounted (this);
  225. CustomGeometry_Commit (handle);
  226. }
  227. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  228. internal static extern void CustomGeometry_SetMaterial (IntPtr handle, IntPtr material);
  229. /// <summary>
  230. /// Set material on all geometries.
  231. /// </summary>
  232. public void SetMaterial (Material material)
  233. {
  234. Runtime.ValidateRefCounted (this);
  235. CustomGeometry_SetMaterial (handle, (object)material == null ? IntPtr.Zero : material.Handle);
  236. }
  237. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  238. internal static extern bool CustomGeometry_SetMaterial0 (IntPtr handle, uint index, IntPtr material);
  239. /// <summary>
  240. /// Set material on one geometry. Return true if successful.
  241. /// </summary>
  242. public bool SetMaterial (uint index, Material material)
  243. {
  244. Runtime.ValidateRefCounted (this);
  245. return CustomGeometry_SetMaterial0 (handle, index, (object)material == null ? IntPtr.Zero : material.Handle);
  246. }
  247. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  248. internal static extern uint CustomGeometry_GetNumGeometries (IntPtr handle);
  249. /// <summary>
  250. /// Return number of geometries.
  251. /// </summary>
  252. private uint GetNumGeometries ()
  253. {
  254. Runtime.ValidateRefCounted (this);
  255. return CustomGeometry_GetNumGeometries (handle);
  256. }
  257. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  258. internal static extern uint CustomGeometry_GetNumVertices (IntPtr handle, uint index);
  259. /// <summary>
  260. /// Return number of vertices in a geometry.
  261. /// </summary>
  262. public uint GetNumVertices (uint index)
  263. {
  264. Runtime.ValidateRefCounted (this);
  265. return CustomGeometry_GetNumVertices (handle, index);
  266. }
  267. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  268. internal static extern bool CustomGeometry_IsDynamic (IntPtr handle);
  269. /// <summary>
  270. /// Return whether vertex buffer dynamic mode is enabled.
  271. /// </summary>
  272. private bool IsDynamic ()
  273. {
  274. Runtime.ValidateRefCounted (this);
  275. return CustomGeometry_IsDynamic (handle);
  276. }
  277. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  278. internal static extern IntPtr CustomGeometry_GetMaterial (IntPtr handle, uint index);
  279. /// <summary>
  280. /// Return material by geometry index.
  281. /// </summary>
  282. public Material GetMaterial (uint index = 0)
  283. {
  284. Runtime.ValidateRefCounted (this);
  285. return Runtime.LookupObject<Material> (CustomGeometry_GetMaterial (handle, index));
  286. }
  287. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  288. internal static extern CustomGeometryVertex* CustomGeometry_GetVertex (IntPtr handle, uint geometryIndex, uint vertexNum);
  289. /// <summary>
  290. /// Return a vertex in a geometry for editing, or null if out of bounds. After the edits are finished, calling Commit() updates the vertex buffer.
  291. /// </summary>
  292. public CustomGeometryVertex* GetVertex (uint geometryIndex, uint vertexNum)
  293. {
  294. Runtime.ValidateRefCounted (this);
  295. return CustomGeometry_GetVertex (handle, geometryIndex, vertexNum);
  296. }
  297. public override StringHash Type {
  298. get {
  299. return UrhoGetType ();
  300. }
  301. }
  302. public override string TypeName {
  303. get {
  304. return GetTypeName ();
  305. }
  306. }
  307. [Preserve]
  308. public new static StringHash TypeStatic {
  309. get {
  310. return GetTypeStatic ();
  311. }
  312. }
  313. public new static string TypeNameStatic {
  314. get {
  315. return GetTypeNameStatic ();
  316. }
  317. }
  318. /// <summary>
  319. /// Return number of occlusion geometry triangles.
  320. /// </summary>
  321. public override uint NumOccluderTriangles {
  322. get {
  323. return GetNumOccluderTriangles ();
  324. }
  325. }
  326. /// <summary>
  327. /// Return number of geometries.
  328. /// Or
  329. /// Set number of geometries.
  330. /// </summary>
  331. public uint NumGeometries {
  332. get {
  333. return GetNumGeometries ();
  334. }
  335. set {
  336. SetNumGeometries (value);
  337. }
  338. }
  339. /// <summary>
  340. /// Return whether vertex buffer dynamic mode is enabled.
  341. /// Or
  342. /// Set vertex buffer dynamic mode. A dynamic buffer should be faster to update frequently. Effective at the next Commit() call.
  343. /// </summary>
  344. public bool Dynamic {
  345. get {
  346. return IsDynamic ();
  347. }
  348. set {
  349. SetDynamic (value);
  350. }
  351. }
  352. }
  353. }