Vertex.lua 1.8 KB

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