Skeleton.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace Urho {
  4. // Skeletons are typically references to internal storage in other objects
  5. // we surface this to C# as a pointer to the data, but to ensure that we do not
  6. // have dangling pointers, we only surface the constructor that retains a copy
  7. // to the container
  8. public partial class Skeleton {
  9. IntPtr handle;
  10. public Skeleton (IntPtr handle, object container)
  11. {
  12. this.handle = handle;
  13. }
  14. public BoneWrapper GetBoneSafe(uint index)
  15. {
  16. Runtime.ValidateObject(this);
  17. unsafe
  18. {
  19. Bone* result = Skeleton_GetBone(handle, index);
  20. if (result == null)
  21. return null;
  22. return new BoneWrapper(this, result);
  23. }
  24. }
  25. public BoneWrapper GetBoneSafe(String name)
  26. {
  27. Runtime.ValidateObject(this);
  28. unsafe
  29. {
  30. Bone* result = Skeleton_GetBone0(handle, new StringHash(name).Code);
  31. if (result == null)
  32. return null;
  33. return new BoneWrapper(this, result);
  34. }
  35. }
  36. }
  37. public partial class AnimatedModel {
  38. [DllImport (Consts.NativeImport, CallingConvention=CallingConvention.Cdecl)]
  39. extern static IntPtr AnimatedModel_GetSkeleton (IntPtr handle);
  40. public Skeleton Skeleton {
  41. get
  42. {
  43. Runtime.ValidateObject(this);
  44. return new Skeleton (AnimatedModel_GetSkeleton (handle), this);
  45. }
  46. }
  47. }
  48. }