Bone.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. require('Polycode/Entity')
  2. function Bone(boneName) {
  3. if(arguments[0] != "__skip_ptr__") {
  4. this.__ptr = Polycode.Bone(boneName)
  5. }
  6. Object.defineProperties(this, {
  7. 'parentBoneId': { enumerable: true, configurable: true, get: Bone.prototype.__get_parentBoneId, set: Bone.prototype.__set_parentBoneId},
  8. 'boneMatrix': { enumerable: true, configurable: true, get: Bone.prototype.__get_boneMatrix, set: Bone.prototype.__set_boneMatrix},
  9. 'restMatrix': { enumerable: true, configurable: true, get: Bone.prototype.__get_restMatrix, set: Bone.prototype.__set_restMatrix},
  10. 'baseMatrix': { enumerable: true, configurable: true, get: Bone.prototype.__get_baseMatrix, set: Bone.prototype.__set_baseMatrix},
  11. 'finalMatrix': { enumerable: true, configurable: true, get: Bone.prototype.__get_finalMatrix, set: Bone.prototype.__set_finalMatrix},
  12. 'baseRotation': { enumerable: true, configurable: true, get: Bone.prototype.__get_baseRotation, set: Bone.prototype.__set_baseRotation},
  13. 'baseScale': { enumerable: true, configurable: true, get: Bone.prototype.__get_baseScale, set: Bone.prototype.__set_baseScale},
  14. 'basePosition': { enumerable: true, configurable: true, get: Bone.prototype.__get_basePosition, set: Bone.prototype.__set_basePosition},
  15. 'disableAnimation': { enumerable: true, configurable: true, get: Bone.prototype.__get_disableAnimation, set: Bone.prototype.__set_disableAnimation}
  16. })
  17. }
  18. Bone.prototype = Object.create(Entity.prototype)
  19. Bone.prototype.__get_parentBoneId = function() {
  20. return Polycode.Bone__get_parentBoneId(this.__ptr)
  21. }
  22. Bone.prototype.__set_parentBoneId = function(val) {
  23. Polycode.Bone__set_parentBoneId(this.__ptr, val)
  24. }
  25. Bone.prototype.__get_boneMatrix = function() {
  26. var retVal = new Matrix4("__skip_ptr__")
  27. retVal.__ptr = Polycode.Bone__get_boneMatrix(this.__ptr)
  28. return retVal
  29. }
  30. Bone.prototype.__set_boneMatrix = function(val) {
  31. Polycode.Bone__set_boneMatrix(this.__ptr, val.__ptr)
  32. }
  33. Bone.prototype.__get_restMatrix = function() {
  34. var retVal = new Matrix4("__skip_ptr__")
  35. retVal.__ptr = Polycode.Bone__get_restMatrix(this.__ptr)
  36. return retVal
  37. }
  38. Bone.prototype.__set_restMatrix = function(val) {
  39. Polycode.Bone__set_restMatrix(this.__ptr, val.__ptr)
  40. }
  41. Bone.prototype.__get_baseMatrix = function() {
  42. var retVal = new Matrix4("__skip_ptr__")
  43. retVal.__ptr = Polycode.Bone__get_baseMatrix(this.__ptr)
  44. return retVal
  45. }
  46. Bone.prototype.__set_baseMatrix = function(val) {
  47. Polycode.Bone__set_baseMatrix(this.__ptr, val.__ptr)
  48. }
  49. Bone.prototype.__get_finalMatrix = function() {
  50. var retVal = new Matrix4("__skip_ptr__")
  51. retVal.__ptr = Polycode.Bone__get_finalMatrix(this.__ptr)
  52. return retVal
  53. }
  54. Bone.prototype.__set_finalMatrix = function(val) {
  55. Polycode.Bone__set_finalMatrix(this.__ptr, val.__ptr)
  56. }
  57. Bone.prototype.__get_baseRotation = function() {
  58. var retVal = new Quaternion("__skip_ptr__")
  59. retVal.__ptr = Polycode.Bone__get_baseRotation(this.__ptr)
  60. return retVal
  61. }
  62. Bone.prototype.__set_baseRotation = function(val) {
  63. Polycode.Bone__set_baseRotation(this.__ptr, val.__ptr)
  64. }
  65. Bone.prototype.__get_baseScale = function() {
  66. var retVal = new Vector3("__skip_ptr__")
  67. retVal.__ptr = Polycode.Bone__get_baseScale(this.__ptr)
  68. return retVal
  69. }
  70. Bone.prototype.__set_baseScale = function(val) {
  71. Polycode.Bone__set_baseScale(this.__ptr, val.__ptr)
  72. }
  73. Bone.prototype.__get_basePosition = function() {
  74. var retVal = new Vector3("__skip_ptr__")
  75. retVal.__ptr = Polycode.Bone__get_basePosition(this.__ptr)
  76. return retVal
  77. }
  78. Bone.prototype.__set_basePosition = function(val) {
  79. Polycode.Bone__set_basePosition(this.__ptr, val.__ptr)
  80. }
  81. Bone.prototype.__get_disableAnimation = function() {
  82. return Polycode.Bone__get_disableAnimation(this.__ptr)
  83. }
  84. Bone.prototype.__set_disableAnimation = function(val) {
  85. Polycode.Bone__set_disableAnimation(this.__ptr, val)
  86. }
  87. Duktape.fin(Bone.prototype, function (x) {
  88. if (x === Bone.prototype) {
  89. return;
  90. }
  91. Polycode.Bone__delete(x.__ptr)
  92. })
  93. Bone.prototype.getName = function() {
  94. return Polycode.Bone_getName(this.__ptr)
  95. }
  96. Bone.prototype.setParentBone = function(bone) {
  97. Polycode.Bone_setParentBone(this.__ptr, bone)
  98. }
  99. Bone.prototype.addChildBone = function(bone) {
  100. Polycode.Bone_addChildBone(this.__ptr, bone)
  101. }
  102. Bone.prototype.getParentBone = function() {
  103. var retVal = new Bone("__skip_ptr__")
  104. retVal.__ptr = Polycode.Bone_getParentBone(this.__ptr)
  105. return retVal
  106. }
  107. Bone.prototype.getNumChildBones = function() {
  108. return Polycode.Bone_getNumChildBones(this.__ptr)
  109. }
  110. Bone.prototype.getChildBone = function(index) {
  111. var retVal = new Bone("__skip_ptr__")
  112. retVal.__ptr = Polycode.Bone_getChildBone(this.__ptr, index)
  113. return retVal
  114. }
  115. Bone.prototype.getBoneMatrix = function() {
  116. var retVal = new Matrix4("__skip_ptr__")
  117. retVal.__ptr = Polycode.Bone_getBoneMatrix(this.__ptr)
  118. return retVal
  119. }
  120. Bone.prototype.setBoneMatrix = function(matrix) {
  121. Polycode.Bone_setBoneMatrix(this.__ptr, matrix)
  122. }
  123. Bone.prototype.getRestMatrix = function() {
  124. var retVal = new Matrix4("__skip_ptr__")
  125. retVal.__ptr = Polycode.Bone_getRestMatrix(this.__ptr)
  126. return retVal
  127. }
  128. Bone.prototype.getFullRestMatrix = function() {
  129. var retVal = new Matrix4("__skip_ptr__")
  130. retVal.__ptr = Polycode.Bone_getFullRestMatrix(this.__ptr)
  131. return retVal
  132. }
  133. Bone.prototype.getParentRestMatrix = function() {
  134. var retVal = new Matrix4("__skip_ptr__")
  135. retVal.__ptr = Polycode.Bone_getParentRestMatrix(this.__ptr)
  136. return retVal
  137. }
  138. Bone.prototype.getFinalMatrix = function() {
  139. var retVal = new Matrix4("__skip_ptr__")
  140. retVal.__ptr = Polycode.Bone_getFinalMatrix(this.__ptr)
  141. return retVal
  142. }
  143. Bone.prototype.setRestMatrix = function(matrix) {
  144. Polycode.Bone_setRestMatrix(this.__ptr, matrix)
  145. }
  146. Bone.prototype.setBaseMatrix = function(matrix) {
  147. Polycode.Bone_setBaseMatrix(this.__ptr, matrix)
  148. }
  149. Bone.prototype.getBaseMatrix = function() {
  150. var retVal = new Matrix4("__skip_ptr__")
  151. retVal.__ptr = Polycode.Bone_getBaseMatrix(this.__ptr)
  152. return retVal
  153. }
  154. Bone.prototype.getFullBaseMatrix = function() {
  155. var retVal = new Matrix4("__skip_ptr__")
  156. retVal.__ptr = Polycode.Bone_getFullBaseMatrix(this.__ptr)
  157. return retVal
  158. }
  159. Bone.prototype.rebuildFinalMatrix = function() {
  160. Polycode.Bone_rebuildFinalMatrix(this.__ptr)
  161. }
  162. Bone.prototype.buildFinalMatrix = function() {
  163. var retVal = new Matrix4("__skip_ptr__")
  164. retVal.__ptr = Polycode.Bone_buildFinalMatrix(this.__ptr)
  165. return retVal
  166. }
  167. Bone.prototype.intializeBone = function(basePosition,baseScale,baseRotation,restPosition,restScale,restRotation) {
  168. Polycode.Bone_intializeBone(this.__ptr, basePosition, baseScale, baseRotation, restPosition, restScale, restRotation)
  169. }