Bone.lua 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. elseif name == "boneMatrix" then
  7. retVal = Polycore.Bone_get_boneMatrix(self.__ptr)
  8. if Polycore.__ptr_lookup[retVal] ~= nil then
  9. return Polycore.__ptr_lookup[retVal]
  10. else
  11. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  12. Polycore.__ptr_lookup[retVal].__ptr = retVal
  13. return Polycore.__ptr_lookup[retVal]
  14. end
  15. elseif name == "restMatrix" then
  16. retVal = Polycore.Bone_get_restMatrix(self.__ptr)
  17. if Polycore.__ptr_lookup[retVal] ~= nil then
  18. return Polycore.__ptr_lookup[retVal]
  19. else
  20. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  21. Polycore.__ptr_lookup[retVal].__ptr = retVal
  22. return Polycore.__ptr_lookup[retVal]
  23. end
  24. elseif name == "baseMatrix" then
  25. retVal = Polycore.Bone_get_baseMatrix(self.__ptr)
  26. if Polycore.__ptr_lookup[retVal] ~= nil then
  27. return Polycore.__ptr_lookup[retVal]
  28. else
  29. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  30. Polycore.__ptr_lookup[retVal].__ptr = retVal
  31. return Polycore.__ptr_lookup[retVal]
  32. end
  33. end
  34. end
  35. function Bone:__set_callback(name,value)
  36. if name == "parentBoneId" then
  37. Polycore.Bone_set_parentBoneId(self.__ptr, value)
  38. return true
  39. end
  40. return false
  41. end
  42. function Bone:Bone(...)
  43. if type(arg[1]) == "table" and count(arg) == 1 then
  44. if ""..arg[1]:class() == "SceneEntity" then
  45. self.__ptr = arg[1].__ptr
  46. return
  47. end
  48. end
  49. for k,v in pairs(arg) do
  50. if type(v) == "table" then
  51. if v.__ptr ~= nil then
  52. arg[k] = v.__ptr
  53. end
  54. end
  55. end
  56. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  57. self.__ptr = Polycore.Bone(unpack(arg))
  58. Polycore.__ptr_lookup[self.__ptr] = self
  59. end
  60. end
  61. function Bone:enableBoneLabel(labelFont, size, scale, labelColor)
  62. local retVal = Polycore.Bone_enableBoneLabel(self.__ptr, labelFont, size, scale, labelColor.__ptr)
  63. end
  64. function Bone:getName()
  65. local retVal = Polycore.Bone_getName(self.__ptr)
  66. return retVal
  67. end
  68. function Bone:Render()
  69. local retVal = Polycore.Bone_Render(self.__ptr)
  70. end
  71. function Bone:setParentBone(bone)
  72. local retVal = Polycore.Bone_setParentBone(self.__ptr, bone.__ptr)
  73. end
  74. function Bone:addChildBone(bone)
  75. local retVal = Polycore.Bone_addChildBone(self.__ptr, bone.__ptr)
  76. end
  77. function Bone:getParentBone()
  78. local retVal = Polycore.Bone_getParentBone(self.__ptr)
  79. if retVal == nil then return nil end
  80. if Polycore.__ptr_lookup[retVal] ~= nil then
  81. return Polycore.__ptr_lookup[retVal]
  82. else
  83. Polycore.__ptr_lookup[retVal] = Bone("__skip_ptr__")
  84. Polycore.__ptr_lookup[retVal].__ptr = retVal
  85. return Polycore.__ptr_lookup[retVal]
  86. end
  87. end
  88. function Bone:getNumChildBones()
  89. local retVal = Polycore.Bone_getNumChildBones(self.__ptr)
  90. return retVal
  91. end
  92. function Bone:getChildBone(index)
  93. local retVal = Polycore.Bone_getChildBone(self.__ptr, index)
  94. if retVal == nil then return nil end
  95. if Polycore.__ptr_lookup[retVal] ~= nil then
  96. return Polycore.__ptr_lookup[retVal]
  97. else
  98. Polycore.__ptr_lookup[retVal] = Bone("__skip_ptr__")
  99. Polycore.__ptr_lookup[retVal].__ptr = retVal
  100. return Polycore.__ptr_lookup[retVal]
  101. end
  102. end
  103. function Bone:getBoneMatrix()
  104. local retVal = Polycore.Bone_getBoneMatrix(self.__ptr)
  105. if retVal == nil then return nil end
  106. if Polycore.__ptr_lookup[retVal] ~= nil then
  107. return Polycore.__ptr_lookup[retVal]
  108. else
  109. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  110. Polycore.__ptr_lookup[retVal].__ptr = retVal
  111. return Polycore.__ptr_lookup[retVal]
  112. end
  113. end
  114. function Bone:setBoneMatrix(matrix)
  115. local retVal = Polycore.Bone_setBoneMatrix(self.__ptr, matrix.__ptr)
  116. end
  117. function Bone:getRestMatrix()
  118. local retVal = Polycore.Bone_getRestMatrix(self.__ptr)
  119. if retVal == nil then return nil end
  120. if Polycore.__ptr_lookup[retVal] ~= nil then
  121. return Polycore.__ptr_lookup[retVal]
  122. else
  123. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  124. Polycore.__ptr_lookup[retVal].__ptr = retVal
  125. return Polycore.__ptr_lookup[retVal]
  126. end
  127. end
  128. function Bone:getFullRestMatrix()
  129. local retVal = Polycore.Bone_getFullRestMatrix(self.__ptr)
  130. if retVal == nil then return nil end
  131. if Polycore.__ptr_lookup[retVal] ~= nil then
  132. return Polycore.__ptr_lookup[retVal]
  133. else
  134. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  135. Polycore.__ptr_lookup[retVal].__ptr = retVal
  136. return Polycore.__ptr_lookup[retVal]
  137. end
  138. end
  139. function Bone:getParentRestMatrix()
  140. local retVal = Polycore.Bone_getParentRestMatrix(self.__ptr)
  141. if retVal == nil then return nil end
  142. if Polycore.__ptr_lookup[retVal] ~= nil then
  143. return Polycore.__ptr_lookup[retVal]
  144. else
  145. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  146. Polycore.__ptr_lookup[retVal].__ptr = retVal
  147. return Polycore.__ptr_lookup[retVal]
  148. end
  149. end
  150. function Bone:getFinalMatrix()
  151. local retVal = Polycore.Bone_getFinalMatrix(self.__ptr)
  152. if retVal == nil then return nil end
  153. if Polycore.__ptr_lookup[retVal] ~= nil then
  154. return Polycore.__ptr_lookup[retVal]
  155. else
  156. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  157. Polycore.__ptr_lookup[retVal].__ptr = retVal
  158. return Polycore.__ptr_lookup[retVal]
  159. end
  160. end
  161. function Bone:setRestMatrix(matrix)
  162. local retVal = Polycore.Bone_setRestMatrix(self.__ptr, matrix.__ptr)
  163. end
  164. function Bone:setBaseMatrix(matrix)
  165. local retVal = Polycore.Bone_setBaseMatrix(self.__ptr, matrix.__ptr)
  166. end
  167. function Bone:getBaseMatrix()
  168. local retVal = Polycore.Bone_getBaseMatrix(self.__ptr)
  169. if retVal == nil then return nil end
  170. if Polycore.__ptr_lookup[retVal] ~= nil then
  171. return Polycore.__ptr_lookup[retVal]
  172. else
  173. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  174. Polycore.__ptr_lookup[retVal].__ptr = retVal
  175. return Polycore.__ptr_lookup[retVal]
  176. end
  177. end
  178. function Bone:getFullBaseMatrix()
  179. local retVal = Polycore.Bone_getFullBaseMatrix(self.__ptr)
  180. if retVal == nil then return nil end
  181. if Polycore.__ptr_lookup[retVal] ~= nil then
  182. return Polycore.__ptr_lookup[retVal]
  183. else
  184. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  185. Polycore.__ptr_lookup[retVal].__ptr = retVal
  186. return Polycore.__ptr_lookup[retVal]
  187. end
  188. end
  189. function Bone:__delete()
  190. Polycore.__ptr_lookup[self.__ptr] = nil
  191. Polycore.delete_Bone(self.__ptr)
  192. end