Vertex.lua 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. 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.Vertex(unpack(arg))
  25. Polycore.__ptr_lookup[self.__ptr] = self
  26. end
  27. end
  28. function Vertex:addBoneAssignment(boneID, boneWeight)
  29. local retVal = Polycore.Vertex_addBoneAssignment(self.__ptr, boneID, boneWeight)
  30. end
  31. function Vertex:getNumBoneAssignments()
  32. local retVal = Polycore.Vertex_getNumBoneAssignments(self.__ptr)
  33. return retVal
  34. end
  35. function Vertex:getBoneAssignment(index)
  36. local retVal = Polycore.Vertex_getBoneAssignment(self.__ptr, index)
  37. if Polycore.__ptr_lookup[retVal] ~= nil then
  38. return Polycore.__ptr_lookup[retVal]
  39. else
  40. Polycore.__ptr_lookup[retVal] = BoneAssignment("__skip_ptr__")
  41. Polycore.__ptr_lookup[retVal].__ptr = retVal
  42. return Polycore.__ptr_lookup[retVal]
  43. end
  44. end
  45. function Vertex:normalizeWeights()
  46. local retVal = Polycore.Vertex_normalizeWeights(self.__ptr)
  47. end
  48. function Vertex:getTexCoord()
  49. local retVal = Polycore.Vertex_getTexCoord(self.__ptr)
  50. if Polycore.__ptr_lookup[retVal] ~= nil then
  51. return Polycore.__ptr_lookup[retVal]
  52. else
  53. Polycore.__ptr_lookup[retVal] = Vector2("__skip_ptr__")
  54. Polycore.__ptr_lookup[retVal].__ptr = retVal
  55. return Polycore.__ptr_lookup[retVal]
  56. end
  57. end
  58. function Vertex:setTexCoord(u, v)
  59. local retVal = Polycore.Vertex_setTexCoord(self.__ptr, u, v)
  60. end
  61. function Vertex:setNormal(x, y, z)
  62. local retVal = Polycore.Vertex_setNormal(self.__ptr, x, y, z)
  63. end