Bone.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. require "Polycode/SceneEntity"
  2. class "Bone" (SceneEntity)
  3. function Bone:__index__(name)
  4. if name == "parentBoneId" then
  5. return Polycore.Bone_get_parentBoneId(self.__ptr)
  6. end
  7. end
  8. function Bone:__set_callback(name,value)
  9. if name == "parentBoneId" then
  10. Polycore.Bone_set_parentBoneId(self.__ptr, value)
  11. return true
  12. end
  13. return false
  14. end
  15. function Bone:Bone(...)
  16. for k,v in pairs(arg) do
  17. if type(v) == "table" then
  18. if v.__ptr ~= nil then
  19. arg[k] = v.__ptr
  20. end
  21. end
  22. end
  23. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  24. self.__ptr = Polycore.Bone(unpack(arg))
  25. end
  26. end
  27. function Bone:enableBoneLabel(labelFont, size, scale, labelColor)
  28. local retVal = Polycore.Bone_enableBoneLabel(self.__ptr, labelFont, size, scale, labelColor.__ptr)
  29. end
  30. function Bone:getName()
  31. local retVal = Polycore.Bone_getName(self.__ptr)
  32. return retVal
  33. end
  34. function Bone:Render()
  35. local retVal = Polycore.Bone_Render(self.__ptr)
  36. end
  37. function Bone:setParentBone(bone)
  38. local retVal = Polycore.Bone_setParentBone(self.__ptr, bone.__ptr)
  39. end
  40. function Bone:addChildBone(bone)
  41. local retVal = Polycore.Bone_addChildBone(self.__ptr, bone.__ptr)
  42. end
  43. function Bone:getParentBone()
  44. local retVal = Polycore.Bone_getParentBone(self.__ptr)
  45. if Polycore.__ptr_lookup[retVal] ~= nil then
  46. return Polycore.__ptr_lookup[retVal]
  47. else
  48. Polycore.__ptr_lookup[retVal] = Bone("__skip_ptr__")
  49. Polycore.__ptr_lookup[retVal].__ptr = retVal
  50. return Polycore.__ptr_lookup[retVal]
  51. end
  52. end
  53. function Bone:getNumChildBones()
  54. local retVal = Polycore.Bone_getNumChildBones(self.__ptr)
  55. return retVal
  56. end
  57. function Bone:getChildBone(index)
  58. local retVal = Polycore.Bone_getChildBone(self.__ptr, index)
  59. if Polycore.__ptr_lookup[retVal] ~= nil then
  60. return Polycore.__ptr_lookup[retVal]
  61. else
  62. Polycore.__ptr_lookup[retVal] = Bone("__skip_ptr__")
  63. Polycore.__ptr_lookup[retVal].__ptr = retVal
  64. return Polycore.__ptr_lookup[retVal]
  65. end
  66. end
  67. function Bone:getBoneMatrix()
  68. local retVal = Polycore.Bone_getBoneMatrix(self.__ptr)
  69. if Polycore.__ptr_lookup[retVal] ~= nil then
  70. return Polycore.__ptr_lookup[retVal]
  71. else
  72. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  73. Polycore.__ptr_lookup[retVal].__ptr = retVal
  74. return Polycore.__ptr_lookup[retVal]
  75. end
  76. end
  77. function Bone:setBoneMatrix(matrix)
  78. local retVal = Polycore.Bone_setBoneMatrix(self.__ptr, matrix.__ptr)
  79. end
  80. function Bone:getRestMatrix()
  81. local retVal = Polycore.Bone_getRestMatrix(self.__ptr)
  82. if Polycore.__ptr_lookup[retVal] ~= nil then
  83. return Polycore.__ptr_lookup[retVal]
  84. else
  85. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  86. Polycore.__ptr_lookup[retVal].__ptr = retVal
  87. return Polycore.__ptr_lookup[retVal]
  88. end
  89. end
  90. function Bone:getFullRestMatrix()
  91. local retVal = Polycore.Bone_getFullRestMatrix(self.__ptr)
  92. if Polycore.__ptr_lookup[retVal] ~= nil then
  93. return Polycore.__ptr_lookup[retVal]
  94. else
  95. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  96. Polycore.__ptr_lookup[retVal].__ptr = retVal
  97. return Polycore.__ptr_lookup[retVal]
  98. end
  99. end
  100. function Bone:getParentRestMatrix()
  101. local retVal = Polycore.Bone_getParentRestMatrix(self.__ptr)
  102. if Polycore.__ptr_lookup[retVal] ~= nil then
  103. return Polycore.__ptr_lookup[retVal]
  104. else
  105. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  106. Polycore.__ptr_lookup[retVal].__ptr = retVal
  107. return Polycore.__ptr_lookup[retVal]
  108. end
  109. end
  110. function Bone:getFinalMatrix()
  111. local retVal = Polycore.Bone_getFinalMatrix(self.__ptr)
  112. if Polycore.__ptr_lookup[retVal] ~= nil then
  113. return Polycore.__ptr_lookup[retVal]
  114. else
  115. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  116. Polycore.__ptr_lookup[retVal].__ptr = retVal
  117. return Polycore.__ptr_lookup[retVal]
  118. end
  119. end
  120. function Bone:setRestMatrix(matrix)
  121. local retVal = Polycore.Bone_setRestMatrix(self.__ptr, matrix.__ptr)
  122. end
  123. function Bone:setBaseMatrix(matrix)
  124. local retVal = Polycore.Bone_setBaseMatrix(self.__ptr, matrix.__ptr)
  125. end
  126. function Bone:getBaseMatrix()
  127. local retVal = Polycore.Bone_getBaseMatrix(self.__ptr)
  128. if Polycore.__ptr_lookup[retVal] ~= nil then
  129. return Polycore.__ptr_lookup[retVal]
  130. else
  131. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  132. Polycore.__ptr_lookup[retVal].__ptr = retVal
  133. return Polycore.__ptr_lookup[retVal]
  134. end
  135. end
  136. function Bone:getFullBaseMatrix()
  137. local retVal = Polycore.Bone_getFullBaseMatrix(self.__ptr)
  138. if Polycore.__ptr_lookup[retVal] ~= nil then
  139. return Polycore.__ptr_lookup[retVal]
  140. else
  141. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  142. Polycore.__ptr_lookup[retVal].__ptr = retVal
  143. return Polycore.__ptr_lookup[retVal]
  144. end
  145. end