Model.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // Model.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. /// 3D model resource.
  21. /// </summary>
  22. public unsafe partial class Model : ResourceWithMetadata
  23. {
  24. unsafe partial void OnModelCreated ();
  25. [Preserve]
  26. public Model (IntPtr handle) : base (handle)
  27. {
  28. OnModelCreated ();
  29. }
  30. [Preserve]
  31. protected Model (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  32. {
  33. OnModelCreated ();
  34. }
  35. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  36. internal static extern int Model_GetType (IntPtr handle);
  37. private StringHash UrhoGetType ()
  38. {
  39. Runtime.ValidateRefCounted (this);
  40. return new StringHash (Model_GetType (handle));
  41. }
  42. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  43. internal static extern IntPtr Model_GetTypeName (IntPtr handle);
  44. private string GetTypeName ()
  45. {
  46. Runtime.ValidateRefCounted (this);
  47. return Marshal.PtrToStringAnsi (Model_GetTypeName (handle));
  48. }
  49. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  50. internal static extern int Model_GetTypeStatic ();
  51. private static StringHash GetTypeStatic ()
  52. {
  53. Runtime.Validate (typeof(Model));
  54. return new StringHash (Model_GetTypeStatic ());
  55. }
  56. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  57. internal static extern IntPtr Model_GetTypeNameStatic ();
  58. private static string GetTypeNameStatic ()
  59. {
  60. Runtime.Validate (typeof(Model));
  61. return Marshal.PtrToStringAnsi (Model_GetTypeNameStatic ());
  62. }
  63. [Preserve]
  64. public Model () : this (Application.CurrentContext)
  65. {
  66. }
  67. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  68. internal static extern IntPtr Model_Model (IntPtr context);
  69. [Preserve]
  70. public Model (Context context) : base (UrhoObjectFlag.Empty)
  71. {
  72. Runtime.Validate (typeof(Model));
  73. handle = Model_Model ((object)context == null ? IntPtr.Zero : context.Handle);
  74. Runtime.RegisterObject (this);
  75. OnModelCreated ();
  76. }
  77. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  78. internal static extern void Model_RegisterObject (IntPtr context);
  79. /// <summary>
  80. /// Register object factory.
  81. /// </summary>
  82. public static void RegisterObject (Context context)
  83. {
  84. Runtime.Validate (typeof(Model));
  85. Model_RegisterObject ((object)context == null ? IntPtr.Zero : context.Handle);
  86. }
  87. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  88. internal static extern bool Model_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 Model_BeginLoad_File (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  96. }
  97. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  98. internal static extern bool Model_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 Model_BeginLoad_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  106. }
  107. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  108. internal static extern bool Model_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 Model_EndLoad (handle);
  116. }
  117. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  118. internal static extern bool Model_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 Model_Save_File (handle, (object)dest == null ? IntPtr.Zero : dest.Handle);
  126. }
  127. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  128. internal static extern bool Model_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 Model_Save_MemoryBuffer (handle, (object)dest == null ? IntPtr.Zero : dest.Handle);
  136. }
  137. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  138. internal static extern void Model_SetBoundingBox (IntPtr handle, ref Urho.BoundingBox box);
  139. /// <summary>
  140. /// Set local-space bounding box.
  141. /// </summary>
  142. private void SetBoundingBox (Urho.BoundingBox box)
  143. {
  144. Runtime.ValidateRefCounted (this);
  145. Model_SetBoundingBox (handle, ref box);
  146. }
  147. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  148. internal static extern void Model_SetNumGeometries (IntPtr handle, uint num);
  149. /// <summary>
  150. /// Set number of geometries.
  151. /// </summary>
  152. private void SetNumGeometries (uint num)
  153. {
  154. Runtime.ValidateRefCounted (this);
  155. Model_SetNumGeometries (handle, num);
  156. }
  157. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  158. internal static extern bool Model_SetNumGeometryLodLevels (IntPtr handle, uint index, uint num);
  159. /// <summary>
  160. /// Set number of LOD levels in a geometry.
  161. /// </summary>
  162. public bool SetNumGeometryLodLevels (uint index, uint num)
  163. {
  164. Runtime.ValidateRefCounted (this);
  165. return Model_SetNumGeometryLodLevels (handle, index, num);
  166. }
  167. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  168. internal static extern bool Model_SetGeometry (IntPtr handle, uint index, uint lodLevel, IntPtr geometry);
  169. /// <summary>
  170. /// Set geometry.
  171. /// </summary>
  172. public bool SetGeometry (uint index, uint lodLevel, Geometry geometry)
  173. {
  174. Runtime.ValidateRefCounted (this);
  175. return Model_SetGeometry (handle, index, lodLevel, (object)geometry == null ? IntPtr.Zero : geometry.Handle);
  176. }
  177. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  178. internal static extern bool Model_SetGeometryCenter (IntPtr handle, uint index, ref Urho.Vector3 center);
  179. /// <summary>
  180. /// Set geometry center.
  181. /// </summary>
  182. public bool SetGeometryCenter (uint index, Urho.Vector3 center)
  183. {
  184. Runtime.ValidateRefCounted (this);
  185. return Model_SetGeometryCenter (handle, index, ref center);
  186. }
  187. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  188. internal static extern IntPtr Model_Clone (IntPtr handle, string cloneName);
  189. /// <summary>
  190. /// Clone the model. The geometry data is deep-copied and can be modified in the clone without affecting the original.
  191. /// </summary>
  192. public Model Clone (string cloneName = "")
  193. {
  194. Runtime.ValidateRefCounted (this);
  195. return Runtime.LookupRefCounted<Model> (Model_Clone (handle, cloneName));
  196. }
  197. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  198. internal static extern Urho.BoundingBox Model_GetBoundingBox (IntPtr handle);
  199. /// <summary>
  200. /// Return bounding box.
  201. /// </summary>
  202. private Urho.BoundingBox GetBoundingBox ()
  203. {
  204. Runtime.ValidateRefCounted (this);
  205. return Model_GetBoundingBox (handle);
  206. }
  207. private IReadOnlyList<VertexBuffer> _GetVertexBuffers_cache;
  208. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  209. internal static extern IntPtr Model_GetVertexBuffers (IntPtr handle);
  210. /// <summary>
  211. /// Return vertex buffers.
  212. /// </summary>
  213. private IReadOnlyList<VertexBuffer> GetVertexBuffers ()
  214. {
  215. Runtime.ValidateRefCounted (this);
  216. return _GetVertexBuffers_cache != null ? _GetVertexBuffers_cache : _GetVertexBuffers_cache = Runtime.CreateVectorSharedPtrProxy<VertexBuffer> (Model_GetVertexBuffers (handle));
  217. }
  218. private IReadOnlyList<IndexBuffer> _GetIndexBuffers_cache;
  219. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  220. internal static extern IntPtr Model_GetIndexBuffers (IntPtr handle);
  221. /// <summary>
  222. /// Return index buffers.
  223. /// </summary>
  224. private IReadOnlyList<IndexBuffer> GetIndexBuffers ()
  225. {
  226. Runtime.ValidateRefCounted (this);
  227. return _GetIndexBuffers_cache != null ? _GetIndexBuffers_cache : _GetIndexBuffers_cache = Runtime.CreateVectorSharedPtrProxy<IndexBuffer> (Model_GetIndexBuffers (handle));
  228. }
  229. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  230. internal static extern uint Model_GetNumGeometries (IntPtr handle);
  231. /// <summary>
  232. /// Return number of geometries.
  233. /// </summary>
  234. private uint GetNumGeometries ()
  235. {
  236. Runtime.ValidateRefCounted (this);
  237. return Model_GetNumGeometries (handle);
  238. }
  239. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  240. internal static extern uint Model_GetNumGeometryLodLevels (IntPtr handle, uint index);
  241. /// <summary>
  242. /// Return number of LOD levels in geometry.
  243. /// </summary>
  244. public uint GetNumGeometryLodLevels (uint index)
  245. {
  246. Runtime.ValidateRefCounted (this);
  247. return Model_GetNumGeometryLodLevels (handle, index);
  248. }
  249. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  250. internal static extern IntPtr Model_GetGeometry (IntPtr handle, uint index, uint lodLevel);
  251. /// <summary>
  252. /// Return geometry by index and LOD level. The LOD level is clamped if out of range.
  253. /// </summary>
  254. public Geometry GetGeometry (uint index, uint lodLevel)
  255. {
  256. Runtime.ValidateRefCounted (this);
  257. return Runtime.LookupObject<Geometry> (Model_GetGeometry (handle, index, lodLevel));
  258. }
  259. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  260. internal static extern Urho.Vector3 Model_GetGeometryCenter (IntPtr handle, uint index);
  261. /// <summary>
  262. /// Return geometry center by index.
  263. /// </summary>
  264. public Urho.Vector3 GetGeometryCenter (uint index)
  265. {
  266. Runtime.ValidateRefCounted (this);
  267. return Model_GetGeometryCenter (handle, index);
  268. }
  269. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  270. internal static extern uint Model_GetNumMorphs (IntPtr handle);
  271. /// <summary>
  272. /// Return number of vertex morphs.
  273. /// </summary>
  274. private uint GetNumMorphs ()
  275. {
  276. Runtime.ValidateRefCounted (this);
  277. return Model_GetNumMorphs (handle);
  278. }
  279. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  280. internal static extern ModelMorph* Model_GetMorph (IntPtr handle, uint index);
  281. /// <summary>
  282. /// Return vertex morph by index.
  283. /// </summary>
  284. public ModelMorph* GetMorph (uint index)
  285. {
  286. Runtime.ValidateRefCounted (this);
  287. return Model_GetMorph (handle, index);
  288. }
  289. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  290. internal static extern ModelMorph* Model_GetMorph0 (IntPtr handle, string name);
  291. /// <summary>
  292. /// Return vertex morph by name.
  293. /// </summary>
  294. public ModelMorph* GetMorph (string name)
  295. {
  296. Runtime.ValidateRefCounted (this);
  297. return Model_GetMorph0 (handle, name);
  298. }
  299. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  300. internal static extern ModelMorph* Model_GetMorph1 (IntPtr handle, int nameHash);
  301. /// <summary>
  302. /// Return vertex morph by name hash.
  303. /// </summary>
  304. public ModelMorph* GetMorph (StringHash nameHash)
  305. {
  306. Runtime.ValidateRefCounted (this);
  307. return Model_GetMorph1 (handle, nameHash.Code);
  308. }
  309. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  310. internal static extern uint Model_GetMorphRangeStart (IntPtr handle, uint bufferIndex);
  311. /// <summary>
  312. /// Return vertex buffer morph range start.
  313. /// </summary>
  314. public uint GetMorphRangeStart (uint bufferIndex)
  315. {
  316. Runtime.ValidateRefCounted (this);
  317. return Model_GetMorphRangeStart (handle, bufferIndex);
  318. }
  319. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  320. internal static extern uint Model_GetMorphRangeCount (IntPtr handle, uint bufferIndex);
  321. /// <summary>
  322. /// Return vertex buffer morph range vertex count.
  323. /// </summary>
  324. public uint GetMorphRangeCount (uint bufferIndex)
  325. {
  326. Runtime.ValidateRefCounted (this);
  327. return Model_GetMorphRangeCount (handle, bufferIndex);
  328. }
  329. public override StringHash Type {
  330. get {
  331. return UrhoGetType ();
  332. }
  333. }
  334. public override string TypeName {
  335. get {
  336. return GetTypeName ();
  337. }
  338. }
  339. [Preserve]
  340. public new static StringHash TypeStatic {
  341. get {
  342. return GetTypeStatic ();
  343. }
  344. }
  345. public new static string TypeNameStatic {
  346. get {
  347. return GetTypeNameStatic ();
  348. }
  349. }
  350. /// <summary>
  351. /// Return bounding box.
  352. /// Or
  353. /// Set local-space bounding box.
  354. /// </summary>
  355. public Urho.BoundingBox BoundingBox {
  356. get {
  357. return GetBoundingBox ();
  358. }
  359. set {
  360. SetBoundingBox (value);
  361. }
  362. }
  363. /// <summary>
  364. /// Return index buffers.
  365. /// </summary>
  366. public IReadOnlyList<IndexBuffer> IndexBuffers {
  367. get {
  368. return GetIndexBuffers ();
  369. }
  370. }
  371. /// <summary>
  372. /// Return number of geometries.
  373. /// Or
  374. /// Set number of geometries.
  375. /// </summary>
  376. public uint NumGeometries {
  377. get {
  378. return GetNumGeometries ();
  379. }
  380. set {
  381. SetNumGeometries (value);
  382. }
  383. }
  384. /// <summary>
  385. /// Return vertex buffers.
  386. /// </summary>
  387. public IReadOnlyList<VertexBuffer> VertexBuffers {
  388. get {
  389. return GetVertexBuffers ();
  390. }
  391. }
  392. /// <summary>
  393. /// Return number of vertex morphs.
  394. /// </summary>
  395. public uint NumMorphs {
  396. get {
  397. return GetNumMorphs ();
  398. }
  399. }
  400. }
  401. }