Vertex.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. require "Polycode/Vector3"
  2. class "Vertex" (Vector3)
  3. function Vertex:__index__(name)
  4. if name == "useVertexColor" then
  5. return Polycore.Vertex_get_useVertexColor(self.__ptr)
  6. end
  7. end
  8. function Vertex:__set_callback(name,value)
  9. if name == "useVertexColor" then
  10. Polycore.Vertex_set_useVertexColor(self.__ptr, value)
  11. return true
  12. end
  13. return false
  14. end
  15. function Vertex:Vertex(...)
  16. if type(arg[1]) == "table" and count(arg) == 1 then
  17. if ""..arg[1]:class() == "Vector3" then
  18. self.__ptr = arg[1].__ptr
  19. return
  20. end
  21. end
  22. for k,v in pairs(arg) do
  23. if type(v) == "table" then
  24. if v.__ptr ~= nil then
  25. arg[k] = v.__ptr
  26. end
  27. end
  28. end
  29. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  30. self.__ptr = Polycore.Vertex(unpack(arg))
  31. Polycore.__ptr_lookup[self.__ptr] = self
  32. end
  33. end
  34. function Vertex:addBoneAssignment(boneID, boneWeight)
  35. local retVal = Polycore.Vertex_addBoneAssignment(self.__ptr, boneID, boneWeight)
  36. end
  37. function Vertex:getNumBoneAssignments()
  38. local retVal = Polycore.Vertex_getNumBoneAssignments(self.__ptr)
  39. return retVal
  40. end
  41. function Vertex:getBoneAssignment(index)
  42. local retVal = Polycore.Vertex_getBoneAssignment(self.__ptr, index)
  43. if Polycore.__ptr_lookup[retVal] ~= nil then
  44. return Polycore.__ptr_lookup[retVal]
  45. else
  46. Polycore.__ptr_lookup[retVal] = BoneAssignment("__skip_ptr__")
  47. Polycore.__ptr_lookup[retVal].__ptr = retVal
  48. return Polycore.__ptr_lookup[retVal]
  49. end
  50. end
  51. function Vertex:normalizeWeights()
  52. local retVal = Polycore.Vertex_normalizeWeights(self.__ptr)
  53. end
  54. function Vertex:getTexCoord()
  55. local retVal = Polycore.Vertex_getTexCoord(self.__ptr)
  56. if Polycore.__ptr_lookup[retVal] ~= nil then
  57. return Polycore.__ptr_lookup[retVal]
  58. else
  59. Polycore.__ptr_lookup[retVal] = Vector2("__skip_ptr__")
  60. Polycore.__ptr_lookup[retVal].__ptr = retVal
  61. return Polycore.__ptr_lookup[retVal]
  62. end
  63. end
  64. function Vertex:setTexCoord(u, v)
  65. local retVal = Polycore.Vertex_setTexCoord(self.__ptr, u, v)
  66. end
  67. function Vertex:setNormal(x, y, z)
  68. local retVal = Polycore.Vertex_setNormal(self.__ptr, x, y, z)
  69. end
  70. function Vertex:__delete()
  71. Polycore.__ptr_lookup[self.__ptr] = nil
  72. Polycore.delete_Vertex(self.__ptr)
  73. end