Bone.lua 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. if retVal == nil then return nil end
  67. if Polycore.__ptr_lookup[retVal] ~= nil then
  68. return Polycore.__ptr_lookup[retVal]
  69. else
  70. Polycore.__ptr_lookup[retVal] = String("__skip_ptr__")
  71. Polycore.__ptr_lookup[retVal].__ptr = retVal
  72. return Polycore.__ptr_lookup[retVal]
  73. end
  74. end
  75. function Bone:Render()
  76. local retVal = Polycore.Bone_Render(self.__ptr)
  77. end
  78. function Bone:setParentBone(bone)
  79. local retVal = Polycore.Bone_setParentBone(self.__ptr, bone.__ptr)
  80. end
  81. function Bone:addChildBone(bone)
  82. local retVal = Polycore.Bone_addChildBone(self.__ptr, bone.__ptr)
  83. end
  84. function Bone:getParentBone()
  85. local retVal = Polycore.Bone_getParentBone(self.__ptr)
  86. if retVal == nil then return nil end
  87. if Polycore.__ptr_lookup[retVal] ~= nil then
  88. return Polycore.__ptr_lookup[retVal]
  89. else
  90. Polycore.__ptr_lookup[retVal] = Bone("__skip_ptr__")
  91. Polycore.__ptr_lookup[retVal].__ptr = retVal
  92. return Polycore.__ptr_lookup[retVal]
  93. end
  94. end
  95. function Bone:getNumChildBones()
  96. local retVal = Polycore.Bone_getNumChildBones(self.__ptr)
  97. return retVal
  98. end
  99. function Bone:getChildBone(index)
  100. local retVal = Polycore.Bone_getChildBone(self.__ptr, index)
  101. if retVal == nil then return nil end
  102. if Polycore.__ptr_lookup[retVal] ~= nil then
  103. return Polycore.__ptr_lookup[retVal]
  104. else
  105. Polycore.__ptr_lookup[retVal] = Bone("__skip_ptr__")
  106. Polycore.__ptr_lookup[retVal].__ptr = retVal
  107. return Polycore.__ptr_lookup[retVal]
  108. end
  109. end
  110. function Bone:getBoneMatrix()
  111. local retVal = Polycore.Bone_getBoneMatrix(self.__ptr)
  112. if retVal == nil then return nil end
  113. if Polycore.__ptr_lookup[retVal] ~= nil then
  114. return Polycore.__ptr_lookup[retVal]
  115. else
  116. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  117. Polycore.__ptr_lookup[retVal].__ptr = retVal
  118. return Polycore.__ptr_lookup[retVal]
  119. end
  120. end
  121. function Bone:setBoneMatrix(matrix)
  122. local retVal = Polycore.Bone_setBoneMatrix(self.__ptr, matrix.__ptr)
  123. end
  124. function Bone:getRestMatrix()
  125. local retVal = Polycore.Bone_getRestMatrix(self.__ptr)
  126. if retVal == nil then return nil end
  127. if Polycore.__ptr_lookup[retVal] ~= nil then
  128. return Polycore.__ptr_lookup[retVal]
  129. else
  130. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  131. Polycore.__ptr_lookup[retVal].__ptr = retVal
  132. return Polycore.__ptr_lookup[retVal]
  133. end
  134. end
  135. function Bone:getFullRestMatrix()
  136. local retVal = Polycore.Bone_getFullRestMatrix(self.__ptr)
  137. if retVal == nil then return nil end
  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
  146. function Bone:getParentRestMatrix()
  147. local retVal = Polycore.Bone_getParentRestMatrix(self.__ptr)
  148. if retVal == nil then return nil end
  149. if Polycore.__ptr_lookup[retVal] ~= nil then
  150. return Polycore.__ptr_lookup[retVal]
  151. else
  152. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  153. Polycore.__ptr_lookup[retVal].__ptr = retVal
  154. return Polycore.__ptr_lookup[retVal]
  155. end
  156. end
  157. function Bone:getFinalMatrix()
  158. local retVal = Polycore.Bone_getFinalMatrix(self.__ptr)
  159. if retVal == nil then return nil end
  160. if Polycore.__ptr_lookup[retVal] ~= nil then
  161. return Polycore.__ptr_lookup[retVal]
  162. else
  163. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  164. Polycore.__ptr_lookup[retVal].__ptr = retVal
  165. return Polycore.__ptr_lookup[retVal]
  166. end
  167. end
  168. function Bone:setRestMatrix(matrix)
  169. local retVal = Polycore.Bone_setRestMatrix(self.__ptr, matrix.__ptr)
  170. end
  171. function Bone:setBaseMatrix(matrix)
  172. local retVal = Polycore.Bone_setBaseMatrix(self.__ptr, matrix.__ptr)
  173. end
  174. function Bone:getBaseMatrix()
  175. local retVal = Polycore.Bone_getBaseMatrix(self.__ptr)
  176. if retVal == nil then return nil end
  177. if Polycore.__ptr_lookup[retVal] ~= nil then
  178. return Polycore.__ptr_lookup[retVal]
  179. else
  180. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  181. Polycore.__ptr_lookup[retVal].__ptr = retVal
  182. return Polycore.__ptr_lookup[retVal]
  183. end
  184. end
  185. function Bone:getFullBaseMatrix()
  186. local retVal = Polycore.Bone_getFullBaseMatrix(self.__ptr)
  187. if retVal == nil then return nil end
  188. if Polycore.__ptr_lookup[retVal] ~= nil then
  189. return Polycore.__ptr_lookup[retVal]
  190. else
  191. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  192. Polycore.__ptr_lookup[retVal].__ptr = retVal
  193. return Polycore.__ptr_lookup[retVal]
  194. end
  195. end
  196. function Bone:__delete()
  197. Polycore.__ptr_lookup[self.__ptr] = nil
  198. Polycore.delete_Bone(self.__ptr)
  199. end