Skeleton.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. [Preserve]
  11. public Skeleton (IntPtr handle, object container)
  12. {
  13. this.handle = handle;
  14. }
  15. public BoneWrapper GetBoneSafe(uint index)
  16. {
  17. Runtime.ValidateObject(this);
  18. unsafe
  19. {
  20. Bone* result = Skeleton_GetBone(handle, index);
  21. if (result == null)
  22. return null;
  23. return new BoneWrapper(this, result);
  24. }
  25. }
  26. public BoneWrapper GetBoneSafe(String name)
  27. {
  28. Runtime.ValidateObject(this);
  29. unsafe
  30. {
  31. Bone* result = Skeleton_GetBone0(handle, new StringHash(name).Code);
  32. if (result == null)
  33. return null;
  34. return new BoneWrapper(this, result);
  35. }
  36. }
  37. }
  38. public partial class AnimatedModel {
  39. [DllImport (Consts.NativeImport, CallingConvention=CallingConvention.Cdecl)]
  40. extern static IntPtr AnimatedModel_GetSkeleton (IntPtr handle);
  41. public Skeleton Skeleton {
  42. get
  43. {
  44. Runtime.ValidateObject(this);
  45. return new Skeleton (AnimatedModel_GetSkeleton (handle), this);
  46. }
  47. }
  48. }
  49. }