Geometry.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // Geometry.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. /// Defines one or more vertex buffers, an index buffer and a draw range.
  21. /// </summary>
  22. public unsafe partial class Geometry : UrhoObject
  23. {
  24. unsafe partial void OnGeometryCreated ();
  25. [Preserve]
  26. public Geometry (IntPtr handle) : base (handle)
  27. {
  28. OnGeometryCreated ();
  29. }
  30. [Preserve]
  31. protected Geometry (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  32. {
  33. OnGeometryCreated ();
  34. }
  35. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  36. internal static extern int Geometry_GetType (IntPtr handle);
  37. private StringHash UrhoGetType ()
  38. {
  39. Runtime.ValidateRefCounted (this);
  40. return new StringHash (Geometry_GetType (handle));
  41. }
  42. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  43. internal static extern IntPtr Geometry_GetTypeName (IntPtr handle);
  44. private string GetTypeName ()
  45. {
  46. Runtime.ValidateRefCounted (this);
  47. return Marshal.PtrToStringAnsi (Geometry_GetTypeName (handle));
  48. }
  49. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  50. internal static extern int Geometry_GetTypeStatic ();
  51. private static StringHash GetTypeStatic ()
  52. {
  53. Runtime.Validate (typeof(Geometry));
  54. return new StringHash (Geometry_GetTypeStatic ());
  55. }
  56. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  57. internal static extern IntPtr Geometry_GetTypeNameStatic ();
  58. private static string GetTypeNameStatic ()
  59. {
  60. Runtime.Validate (typeof(Geometry));
  61. return Marshal.PtrToStringAnsi (Geometry_GetTypeNameStatic ());
  62. }
  63. [Preserve]
  64. public Geometry () : this (Application.CurrentContext)
  65. {
  66. }
  67. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  68. internal static extern IntPtr Geometry_Geometry (IntPtr context);
  69. [Preserve]
  70. public Geometry (Context context) : base (UrhoObjectFlag.Empty)
  71. {
  72. Runtime.Validate (typeof(Geometry));
  73. handle = Geometry_Geometry ((object)context == null ? IntPtr.Zero : context.Handle);
  74. Runtime.RegisterObject (this);
  75. OnGeometryCreated ();
  76. }
  77. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  78. internal static extern bool Geometry_SetNumVertexBuffers (IntPtr handle, uint num);
  79. /// <summary>
  80. /// Set number of vertex buffers.
  81. /// </summary>
  82. public bool SetNumVertexBuffers (uint num)
  83. {
  84. Runtime.ValidateRefCounted (this);
  85. return Geometry_SetNumVertexBuffers (handle, num);
  86. }
  87. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  88. internal static extern bool Geometry_SetVertexBuffer (IntPtr handle, uint index, IntPtr buffer);
  89. /// <summary>
  90. /// Set a vertex buffer by index.
  91. /// </summary>
  92. public bool SetVertexBuffer (uint index, VertexBuffer buffer)
  93. {
  94. Runtime.ValidateRefCounted (this);
  95. return Geometry_SetVertexBuffer (handle, index, (object)buffer == null ? IntPtr.Zero : buffer.Handle);
  96. }
  97. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  98. internal static extern void Geometry_SetIndexBuffer (IntPtr handle, IntPtr buffer);
  99. /// <summary>
  100. /// Set the index buffer.
  101. /// </summary>
  102. private void SetIndexBuffer (IndexBuffer buffer)
  103. {
  104. Runtime.ValidateRefCounted (this);
  105. Geometry_SetIndexBuffer (handle, (object)buffer == null ? IntPtr.Zero : buffer.Handle);
  106. }
  107. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  108. internal static extern bool Geometry_SetDrawRange (IntPtr handle, PrimitiveType type, uint indexStart, uint indexCount, bool getUsedVertexRange);
  109. /// <summary>
  110. /// Set the draw range.
  111. /// </summary>
  112. public bool SetDrawRange (PrimitiveType type, uint indexStart, uint indexCount, bool getUsedVertexRange = true)
  113. {
  114. Runtime.ValidateRefCounted (this);
  115. return Geometry_SetDrawRange (handle, type, indexStart, indexCount, getUsedVertexRange);
  116. }
  117. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  118. internal static extern bool Geometry_SetDrawRange0 (IntPtr handle, PrimitiveType type, uint indexStart, uint indexCount, uint vertexStart, uint vertexCount, bool checkIllegal);
  119. /// <summary>
  120. /// Set the draw range.
  121. /// </summary>
  122. public bool SetDrawRange (PrimitiveType type, uint indexStart, uint indexCount, uint vertexStart, uint vertexCount, bool checkIllegal = true)
  123. {
  124. Runtime.ValidateRefCounted (this);
  125. return Geometry_SetDrawRange0 (handle, type, indexStart, indexCount, vertexStart, vertexCount, checkIllegal);
  126. }
  127. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  128. internal static extern void Geometry_SetLodDistance (IntPtr handle, float distance);
  129. /// <summary>
  130. /// Set the LOD distance.
  131. /// </summary>
  132. private void SetLodDistance (float distance)
  133. {
  134. Runtime.ValidateRefCounted (this);
  135. Geometry_SetLodDistance (handle, distance);
  136. }
  137. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  138. internal static extern void Geometry_Draw (IntPtr handle, IntPtr graphics);
  139. /// <summary>
  140. /// Draw.
  141. /// </summary>
  142. public void Draw (Graphics graphics)
  143. {
  144. Runtime.ValidateRefCounted (this);
  145. Geometry_Draw (handle, (object)graphics == null ? IntPtr.Zero : graphics.Handle);
  146. }
  147. private IReadOnlyList<VertexBuffer> _GetVertexBuffers_cache;
  148. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  149. internal static extern IntPtr Geometry_GetVertexBuffers (IntPtr handle);
  150. /// <summary>
  151. /// Return all vertex buffers.
  152. /// </summary>
  153. private IReadOnlyList<VertexBuffer> GetVertexBuffers ()
  154. {
  155. Runtime.ValidateRefCounted (this);
  156. return _GetVertexBuffers_cache != null ? _GetVertexBuffers_cache : _GetVertexBuffers_cache = Runtime.CreateVectorSharedPtrProxy<VertexBuffer> (Geometry_GetVertexBuffers (handle));
  157. }
  158. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  159. internal static extern uint Geometry_GetNumVertexBuffers (IntPtr handle);
  160. /// <summary>
  161. /// Return number of vertex buffers.
  162. /// </summary>
  163. private uint GetNumVertexBuffers ()
  164. {
  165. Runtime.ValidateRefCounted (this);
  166. return Geometry_GetNumVertexBuffers (handle);
  167. }
  168. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  169. internal static extern IntPtr Geometry_GetVertexBuffer (IntPtr handle, uint index);
  170. /// <summary>
  171. /// Return vertex buffer by index.
  172. /// </summary>
  173. public VertexBuffer GetVertexBuffer (uint index)
  174. {
  175. Runtime.ValidateRefCounted (this);
  176. return Runtime.LookupObject<VertexBuffer> (Geometry_GetVertexBuffer (handle, index));
  177. }
  178. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  179. internal static extern IntPtr Geometry_GetIndexBuffer (IntPtr handle);
  180. /// <summary>
  181. /// Return the index buffer.
  182. /// </summary>
  183. private IndexBuffer GetIndexBuffer ()
  184. {
  185. Runtime.ValidateRefCounted (this);
  186. return Runtime.LookupObject<IndexBuffer> (Geometry_GetIndexBuffer (handle));
  187. }
  188. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  189. internal static extern PrimitiveType Geometry_GetPrimitiveType (IntPtr handle);
  190. /// <summary>
  191. /// Return primitive type.
  192. /// </summary>
  193. private PrimitiveType GetPrimitiveType ()
  194. {
  195. Runtime.ValidateRefCounted (this);
  196. return Geometry_GetPrimitiveType (handle);
  197. }
  198. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  199. internal static extern uint Geometry_GetIndexStart (IntPtr handle);
  200. /// <summary>
  201. /// Return start index.
  202. /// </summary>
  203. private uint GetIndexStart ()
  204. {
  205. Runtime.ValidateRefCounted (this);
  206. return Geometry_GetIndexStart (handle);
  207. }
  208. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  209. internal static extern uint Geometry_GetIndexCount (IntPtr handle);
  210. /// <summary>
  211. /// Return number of indices.
  212. /// </summary>
  213. private uint GetIndexCount ()
  214. {
  215. Runtime.ValidateRefCounted (this);
  216. return Geometry_GetIndexCount (handle);
  217. }
  218. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  219. internal static extern uint Geometry_GetVertexStart (IntPtr handle);
  220. /// <summary>
  221. /// Return first used vertex.
  222. /// </summary>
  223. private uint GetVertexStart ()
  224. {
  225. Runtime.ValidateRefCounted (this);
  226. return Geometry_GetVertexStart (handle);
  227. }
  228. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  229. internal static extern uint Geometry_GetVertexCount (IntPtr handle);
  230. /// <summary>
  231. /// Return number of used vertices.
  232. /// </summary>
  233. private uint GetVertexCount ()
  234. {
  235. Runtime.ValidateRefCounted (this);
  236. return Geometry_GetVertexCount (handle);
  237. }
  238. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  239. internal static extern float Geometry_GetLodDistance (IntPtr handle);
  240. /// <summary>
  241. /// Return LOD distance.
  242. /// </summary>
  243. private float GetLodDistance ()
  244. {
  245. Runtime.ValidateRefCounted (this);
  246. return Geometry_GetLodDistance (handle);
  247. }
  248. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  249. internal static extern ushort Geometry_GetBufferHash (IntPtr handle);
  250. /// <summary>
  251. /// Return buffers' combined hash value for state sorting.
  252. /// </summary>
  253. private ushort GetBufferHash ()
  254. {
  255. Runtime.ValidateRefCounted (this);
  256. return Geometry_GetBufferHash (handle);
  257. }
  258. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  259. internal static extern float Geometry_GetHitDistance (IntPtr handle, ref Urho.Ray ray, Vector3* outNormal, Vector2* outUV);
  260. /// <summary>
  261. /// Return ray hit distance or infinity if no hit. Requires raw data to be set. Optionally return hit normal and hit uv coordinates at intersect point.
  262. /// </summary>
  263. public float GetHitDistance (Urho.Ray ray, Vector3* outNormal = null, Vector2* outUV = null)
  264. {
  265. Runtime.ValidateRefCounted (this);
  266. return Geometry_GetHitDistance (handle, ref ray, outNormal, outUV);
  267. }
  268. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  269. internal static extern bool Geometry_IsInside (IntPtr handle, ref Urho.Ray ray);
  270. /// <summary>
  271. /// Return whether or not the ray is inside geometry.
  272. /// </summary>
  273. public bool IsInside (Urho.Ray ray)
  274. {
  275. Runtime.ValidateRefCounted (this);
  276. return Geometry_IsInside (handle, ref ray);
  277. }
  278. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  279. internal static extern bool Geometry_IsEmpty (IntPtr handle);
  280. /// <summary>
  281. /// Return whether has empty draw range.
  282. /// </summary>
  283. private bool IsEmpty ()
  284. {
  285. Runtime.ValidateRefCounted (this);
  286. return Geometry_IsEmpty (handle);
  287. }
  288. public override StringHash Type {
  289. get {
  290. return UrhoGetType ();
  291. }
  292. }
  293. public override string TypeName {
  294. get {
  295. return GetTypeName ();
  296. }
  297. }
  298. [Preserve]
  299. public static StringHash TypeStatic {
  300. get {
  301. return GetTypeStatic ();
  302. }
  303. }
  304. public static string TypeNameStatic {
  305. get {
  306. return GetTypeNameStatic ();
  307. }
  308. }
  309. /// <summary>
  310. /// Return number of vertex buffers.
  311. /// Or
  312. /// Set number of vertex buffers.
  313. /// </summary>
  314. public uint NumVertexBuffers {
  315. get {
  316. return GetNumVertexBuffers ();
  317. }
  318. set {
  319. SetNumVertexBuffers (value);
  320. }
  321. }
  322. /// <summary>
  323. /// Return the index buffer.
  324. /// Or
  325. /// Set the index buffer.
  326. /// </summary>
  327. public IndexBuffer IndexBuffer {
  328. get {
  329. return GetIndexBuffer ();
  330. }
  331. set {
  332. SetIndexBuffer (value);
  333. }
  334. }
  335. /// <summary>
  336. /// Return LOD distance.
  337. /// Or
  338. /// Set the LOD distance.
  339. /// </summary>
  340. public float LodDistance {
  341. get {
  342. return GetLodDistance ();
  343. }
  344. set {
  345. SetLodDistance (value);
  346. }
  347. }
  348. /// <summary>
  349. /// Return all vertex buffers.
  350. /// </summary>
  351. public IReadOnlyList<VertexBuffer> VertexBuffers {
  352. get {
  353. return GetVertexBuffers ();
  354. }
  355. }
  356. /// <summary>
  357. /// Return primitive type.
  358. /// </summary>
  359. public PrimitiveType PrimitiveType {
  360. get {
  361. return GetPrimitiveType ();
  362. }
  363. }
  364. /// <summary>
  365. /// Return start index.
  366. /// </summary>
  367. public uint IndexStart {
  368. get {
  369. return GetIndexStart ();
  370. }
  371. }
  372. /// <summary>
  373. /// Return number of indices.
  374. /// </summary>
  375. public uint IndexCount {
  376. get {
  377. return GetIndexCount ();
  378. }
  379. }
  380. /// <summary>
  381. /// Return first used vertex.
  382. /// </summary>
  383. public uint VertexStart {
  384. get {
  385. return GetVertexStart ();
  386. }
  387. }
  388. /// <summary>
  389. /// Return number of used vertices.
  390. /// </summary>
  391. public uint VertexCount {
  392. get {
  393. return GetVertexCount ();
  394. }
  395. }
  396. /// <summary>
  397. /// Return buffers' combined hash value for state sorting.
  398. /// </summary>
  399. public ushort BufferHash {
  400. get {
  401. return GetBufferHash ();
  402. }
  403. }
  404. /// <summary>
  405. /// Return whether has empty draw range.
  406. /// </summary>
  407. public bool Empty {
  408. get {
  409. return IsEmpty ();
  410. }
  411. }
  412. }
  413. }