Bone.lua 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. require "Polycode/Entity"
  2. class "Bone" (Entity)
  3. function Bone:__getvar(name)
  4. if name == "parentBoneId" then
  5. return Polycore.Bone_get_parentBoneId(self.__ptr)
  6. elseif name == "boneMatrix" then
  7. local retVal = Polycore.Bone_get_boneMatrix(self.__ptr)
  8. if retVal == nil then return nil end
  9. local __c = _G["Matrix4"]("__skip_ptr__")
  10. __c.__ptr = retVal
  11. return __c
  12. elseif name == "restMatrix" then
  13. local retVal = Polycore.Bone_get_restMatrix(self.__ptr)
  14. if retVal == nil then return nil end
  15. local __c = _G["Matrix4"]("__skip_ptr__")
  16. __c.__ptr = retVal
  17. return __c
  18. elseif name == "baseMatrix" then
  19. local retVal = Polycore.Bone_get_baseMatrix(self.__ptr)
  20. if retVal == nil then return nil end
  21. local __c = _G["Matrix4"]("__skip_ptr__")
  22. __c.__ptr = retVal
  23. return __c
  24. elseif name == "finalMatrix" then
  25. local retVal = Polycore.Bone_get_finalMatrix(self.__ptr)
  26. if retVal == nil then return nil end
  27. local __c = _G["Matrix4"]("__skip_ptr__")
  28. __c.__ptr = retVal
  29. return __c
  30. elseif name == "baseRotation" then
  31. local retVal = Polycore.Bone_get_baseRotation(self.__ptr)
  32. if retVal == nil then return nil end
  33. local __c = _G["Quaternion"]("__skip_ptr__")
  34. __c.__ptr = retVal
  35. return __c
  36. elseif name == "baseScale" then
  37. local retVal = Polycore.Bone_get_baseScale(self.__ptr)
  38. if retVal == nil then return nil end
  39. local __c = _G["Vector3"]("__skip_ptr__")
  40. __c.__ptr = retVal
  41. return __c
  42. elseif name == "basePosition" then
  43. local retVal = Polycore.Bone_get_basePosition(self.__ptr)
  44. if retVal == nil then return nil end
  45. local __c = _G["Vector3"]("__skip_ptr__")
  46. __c.__ptr = retVal
  47. return __c
  48. elseif name == "disableAnimation" then
  49. return Polycore.Bone_get_disableAnimation(self.__ptr)
  50. end
  51. if Entity["__getvar"] ~= nil then
  52. return Entity.__getvar(self, name)
  53. end
  54. end
  55. function Bone:__setvar(name,value)
  56. if name == "parentBoneId" then
  57. Polycore.Bone_set_parentBoneId(self.__ptr, value)
  58. return true
  59. elseif name == "boneMatrix" then
  60. Polycore.Bone_set_boneMatrix(self.__ptr, value.__ptr)
  61. return true
  62. elseif name == "restMatrix" then
  63. Polycore.Bone_set_restMatrix(self.__ptr, value.__ptr)
  64. return true
  65. elseif name == "baseMatrix" then
  66. Polycore.Bone_set_baseMatrix(self.__ptr, value.__ptr)
  67. return true
  68. elseif name == "finalMatrix" then
  69. Polycore.Bone_set_finalMatrix(self.__ptr, value.__ptr)
  70. return true
  71. elseif name == "baseRotation" then
  72. Polycore.Bone_set_baseRotation(self.__ptr, value.__ptr)
  73. return true
  74. elseif name == "baseScale" then
  75. Polycore.Bone_set_baseScale(self.__ptr, value.__ptr)
  76. return true
  77. elseif name == "basePosition" then
  78. Polycore.Bone_set_basePosition(self.__ptr, value.__ptr)
  79. return true
  80. elseif name == "disableAnimation" then
  81. Polycore.Bone_set_disableAnimation(self.__ptr, value)
  82. return true
  83. end
  84. if Entity["__setvar"] ~= nil then
  85. return Entity.__setvar(self, name, value)
  86. else
  87. return false
  88. end
  89. end
  90. function Bone:Bone(...)
  91. local arg = {...}
  92. if type(arg[1]) == "table" and count(arg) == 1 then
  93. if ""..arg[1].__classname == "Entity" then
  94. self.__ptr = arg[1].__ptr
  95. return
  96. end
  97. end
  98. for k,v in pairs(arg) do
  99. if type(v) == "table" then
  100. if v.__ptr ~= nil then
  101. arg[k] = v.__ptr
  102. end
  103. end
  104. end
  105. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  106. self.__ptr = Polycore.Bone(unpack(arg))
  107. end
  108. end
  109. function Bone:getName()
  110. local retVal = Polycore.Bone_getName(self.__ptr)
  111. return retVal
  112. end
  113. function Bone:setParentBone(bone)
  114. local retVal = Polycore.Bone_setParentBone(self.__ptr, bone.__ptr)
  115. end
  116. function Bone:addChildBone(bone)
  117. local retVal = Polycore.Bone_addChildBone(self.__ptr, bone.__ptr)
  118. end
  119. function Bone:getParentBone()
  120. local retVal = Polycore.Bone_getParentBone(self.__ptr)
  121. if retVal == nil then return nil end
  122. local __c = _G["Bone"]("__skip_ptr__")
  123. __c.__ptr = retVal
  124. return __c
  125. end
  126. function Bone:getNumChildBones()
  127. local retVal = Polycore.Bone_getNumChildBones(self.__ptr)
  128. return retVal
  129. end
  130. function Bone:getChildBone(index)
  131. local retVal = Polycore.Bone_getChildBone(self.__ptr, index)
  132. if retVal == nil then return nil end
  133. local __c = _G["Bone"]("__skip_ptr__")
  134. __c.__ptr = retVal
  135. return __c
  136. end
  137. function Bone:getBoneMatrix()
  138. local retVal = Polycore.Bone_getBoneMatrix(self.__ptr)
  139. if retVal == nil then return nil end
  140. local __c = _G["Matrix4"]("__skip_ptr__")
  141. __c.__ptr = retVal
  142. return __c
  143. end
  144. function Bone:setBoneMatrix(matrix)
  145. local retVal = Polycore.Bone_setBoneMatrix(self.__ptr, matrix.__ptr)
  146. end
  147. function Bone:getRestMatrix()
  148. local retVal = Polycore.Bone_getRestMatrix(self.__ptr)
  149. if retVal == nil then return nil end
  150. local __c = _G["Matrix4"]("__skip_ptr__")
  151. __c.__ptr = retVal
  152. return __c
  153. end
  154. function Bone:getFullRestMatrix()
  155. local retVal = Polycore.Bone_getFullRestMatrix(self.__ptr)
  156. if retVal == nil then return nil end
  157. local __c = _G["Matrix4"]("__skip_ptr__")
  158. __c.__ptr = retVal
  159. return __c
  160. end
  161. function Bone:getParentRestMatrix()
  162. local retVal = Polycore.Bone_getParentRestMatrix(self.__ptr)
  163. if retVal == nil then return nil end
  164. local __c = _G["Matrix4"]("__skip_ptr__")
  165. __c.__ptr = retVal
  166. return __c
  167. end
  168. function Bone:getFinalMatrix()
  169. local retVal = Polycore.Bone_getFinalMatrix(self.__ptr)
  170. if retVal == nil then return nil end
  171. local __c = _G["Matrix4"]("__skip_ptr__")
  172. __c.__ptr = retVal
  173. return __c
  174. end
  175. function Bone:setRestMatrix(matrix)
  176. local retVal = Polycore.Bone_setRestMatrix(self.__ptr, matrix.__ptr)
  177. end
  178. function Bone:setBaseMatrix(matrix)
  179. local retVal = Polycore.Bone_setBaseMatrix(self.__ptr, matrix.__ptr)
  180. end
  181. function Bone:getBaseMatrix()
  182. local retVal = Polycore.Bone_getBaseMatrix(self.__ptr)
  183. if retVal == nil then return nil end
  184. local __c = _G["Matrix4"]("__skip_ptr__")
  185. __c.__ptr = retVal
  186. return __c
  187. end
  188. function Bone:getFullBaseMatrix()
  189. local retVal = Polycore.Bone_getFullBaseMatrix(self.__ptr)
  190. if retVal == nil then return nil end
  191. local __c = _G["Matrix4"]("__skip_ptr__")
  192. __c.__ptr = retVal
  193. return __c
  194. end
  195. function Bone:rebuildFinalMatrix()
  196. local retVal = Polycore.Bone_rebuildFinalMatrix(self.__ptr)
  197. end
  198. function Bone:buildFinalMatrix()
  199. local retVal = Polycore.Bone_buildFinalMatrix(self.__ptr)
  200. if retVal == nil then return nil end
  201. local __c = _G["Matrix4"]("__skip_ptr__")
  202. __c.__ptr = retVal
  203. return __c
  204. end
  205. function Bone:intializeBone(basePosition, baseScale, baseRotation, restPosition, restScale, restRotation)
  206. local retVal = Polycore.Bone_intializeBone(self.__ptr, basePosition.__ptr, baseScale.__ptr, baseRotation.__ptr, restPosition.__ptr, restScale.__ptr, restRotation.__ptr)
  207. end
  208. function Bone:__delete()
  209. if self then Polycore.delete_Bone(self.__ptr) end
  210. end