Bone.lua 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. Polycore.__ptr_lookup[self.__ptr] = self
  26. end
  27. end
  28. function Bone:enableBoneLabel(labelFont, size, scale, labelColor)
  29. local retVal = Polycore.Bone_enableBoneLabel(self.__ptr, labelFont, size, scale, labelColor.__ptr)
  30. end
  31. function Bone:getName()
  32. local retVal = Polycore.Bone_getName(self.__ptr)
  33. return retVal
  34. end
  35. function Bone:Render()
  36. local retVal = Polycore.Bone_Render(self.__ptr)
  37. end
  38. function Bone:setParentBone(bone)
  39. local retVal = Polycore.Bone_setParentBone(self.__ptr, bone.__ptr)
  40. end
  41. function Bone:addChildBone(bone)
  42. local retVal = Polycore.Bone_addChildBone(self.__ptr, bone.__ptr)
  43. end
  44. function Bone:getParentBone()
  45. local retVal = Polycore.Bone_getParentBone(self.__ptr)
  46. if Polycore.__ptr_lookup[retVal] ~= nil then
  47. return Polycore.__ptr_lookup[retVal]
  48. else
  49. Polycore.__ptr_lookup[retVal] = Bone("__skip_ptr__")
  50. Polycore.__ptr_lookup[retVal].__ptr = retVal
  51. return Polycore.__ptr_lookup[retVal]
  52. end
  53. end
  54. function Bone:getNumChildBones()
  55. local retVal = Polycore.Bone_getNumChildBones(self.__ptr)
  56. return retVal
  57. end
  58. function Bone:getChildBone(index)
  59. local retVal = Polycore.Bone_getChildBone(self.__ptr, index)
  60. if Polycore.__ptr_lookup[retVal] ~= nil then
  61. return Polycore.__ptr_lookup[retVal]
  62. else
  63. Polycore.__ptr_lookup[retVal] = Bone("__skip_ptr__")
  64. Polycore.__ptr_lookup[retVal].__ptr = retVal
  65. return Polycore.__ptr_lookup[retVal]
  66. end
  67. end
  68. function Bone:getBoneMatrix()
  69. local retVal = Polycore.Bone_getBoneMatrix(self.__ptr)
  70. if Polycore.__ptr_lookup[retVal] ~= nil then
  71. return Polycore.__ptr_lookup[retVal]
  72. else
  73. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  74. Polycore.__ptr_lookup[retVal].__ptr = retVal
  75. return Polycore.__ptr_lookup[retVal]
  76. end
  77. end
  78. function Bone:setBoneMatrix(matrix)
  79. local retVal = Polycore.Bone_setBoneMatrix(self.__ptr, matrix.__ptr)
  80. end
  81. function Bone:getRestMatrix()
  82. local retVal = Polycore.Bone_getRestMatrix(self.__ptr)
  83. if Polycore.__ptr_lookup[retVal] ~= nil then
  84. return Polycore.__ptr_lookup[retVal]
  85. else
  86. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  87. Polycore.__ptr_lookup[retVal].__ptr = retVal
  88. return Polycore.__ptr_lookup[retVal]
  89. end
  90. end
  91. function Bone:getFullRestMatrix()
  92. local retVal = Polycore.Bone_getFullRestMatrix(self.__ptr)
  93. if Polycore.__ptr_lookup[retVal] ~= nil then
  94. return Polycore.__ptr_lookup[retVal]
  95. else
  96. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  97. Polycore.__ptr_lookup[retVal].__ptr = retVal
  98. return Polycore.__ptr_lookup[retVal]
  99. end
  100. end
  101. function Bone:getParentRestMatrix()
  102. local retVal = Polycore.Bone_getParentRestMatrix(self.__ptr)
  103. if Polycore.__ptr_lookup[retVal] ~= nil then
  104. return Polycore.__ptr_lookup[retVal]
  105. else
  106. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  107. Polycore.__ptr_lookup[retVal].__ptr = retVal
  108. return Polycore.__ptr_lookup[retVal]
  109. end
  110. end
  111. function Bone:getFinalMatrix()
  112. local retVal = Polycore.Bone_getFinalMatrix(self.__ptr)
  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:setRestMatrix(matrix)
  122. local retVal = Polycore.Bone_setRestMatrix(self.__ptr, matrix.__ptr)
  123. end
  124. function Bone:setBaseMatrix(matrix)
  125. local retVal = Polycore.Bone_setBaseMatrix(self.__ptr, matrix.__ptr)
  126. end
  127. function Bone:getBaseMatrix()
  128. local retVal = Polycore.Bone_getBaseMatrix(self.__ptr)
  129. if Polycore.__ptr_lookup[retVal] ~= nil then
  130. return Polycore.__ptr_lookup[retVal]
  131. else
  132. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  133. Polycore.__ptr_lookup[retVal].__ptr = retVal
  134. return Polycore.__ptr_lookup[retVal]
  135. end
  136. end
  137. function Bone:getFullBaseMatrix()
  138. local retVal = Polycore.Bone_getFullBaseMatrix(self.__ptr)
  139. if Polycore.__ptr_lookup[retVal] ~= nil then
  140. return Polycore.__ptr_lookup[retVal]
  141. else
  142. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  143. Polycore.__ptr_lookup[retVal].__ptr = retVal
  144. return Polycore.__ptr_lookup[retVal]
  145. end
  146. end