Skeleton.cs 1.2 KB

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