SceneMesh.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. require "Polycode/SceneEntity"
  2. class "SceneMesh" (SceneEntity)
  3. function SceneMesh:__index__(name)
  4. if name == "showVertexNormals" then
  5. return Polycore.SceneMesh_get_showVertexNormals(self.__ptr)
  6. end
  7. end
  8. function SceneMesh:__set_callback(name,value)
  9. if name == "showVertexNormals" then
  10. Polycore.SceneMesh_set_showVertexNormals(self.__ptr, value)
  11. return true
  12. end
  13. return false
  14. end
  15. function SceneMesh:SceneMesh(...)
  16. if type(arg[1]) == "table" and count(arg) == 1 then
  17. if ""..arg[1]:class() == "SceneEntity" 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.SceneMesh(unpack(arg))
  31. Polycore.__ptr_lookup[self.__ptr] = self
  32. end
  33. end
  34. function SceneMesh:Render()
  35. local retVal = Polycore.SceneMesh_Render(self.__ptr)
  36. end
  37. function SceneMesh:getLocalShaderOptions()
  38. local retVal = Polycore.SceneMesh_getLocalShaderOptions(self.__ptr)
  39. if Polycore.__ptr_lookup[retVal] ~= nil then
  40. return Polycore.__ptr_lookup[retVal]
  41. else
  42. Polycore.__ptr_lookup[retVal] = ShaderBinding("__skip_ptr__")
  43. Polycore.__ptr_lookup[retVal].__ptr = retVal
  44. return Polycore.__ptr_lookup[retVal]
  45. end
  46. end
  47. function SceneMesh:getMesh()
  48. local retVal = Polycore.SceneMesh_getMesh(self.__ptr)
  49. if Polycore.__ptr_lookup[retVal] ~= nil then
  50. return Polycore.__ptr_lookup[retVal]
  51. else
  52. Polycore.__ptr_lookup[retVal] = Mesh("__skip_ptr__")
  53. Polycore.__ptr_lookup[retVal].__ptr = retVal
  54. return Polycore.__ptr_lookup[retVal]
  55. end
  56. end
  57. function SceneMesh:getTexture()
  58. local retVal = Polycore.SceneMesh_getTexture(self.__ptr)
  59. if Polycore.__ptr_lookup[retVal] ~= nil then
  60. return Polycore.__ptr_lookup[retVal]
  61. else
  62. Polycore.__ptr_lookup[retVal] = Texture("__skip_ptr__")
  63. Polycore.__ptr_lookup[retVal].__ptr = retVal
  64. return Polycore.__ptr_lookup[retVal]
  65. end
  66. end
  67. function SceneMesh:getMaterial()
  68. local retVal = Polycore.SceneMesh_getMaterial(self.__ptr)
  69. if Polycore.__ptr_lookup[retVal] ~= nil then
  70. return Polycore.__ptr_lookup[retVal]
  71. else
  72. Polycore.__ptr_lookup[retVal] = Material("__skip_ptr__")
  73. Polycore.__ptr_lookup[retVal].__ptr = retVal
  74. return Polycore.__ptr_lookup[retVal]
  75. end
  76. end
  77. function SceneMesh:loadTexture(fileName, clamp)
  78. local retVal = Polycore.SceneMesh_loadTexture(self.__ptr, fileName, clamp)
  79. end
  80. function SceneMesh:loadSkeleton(fileName)
  81. local retVal = Polycore.SceneMesh_loadSkeleton(self.__ptr, fileName)
  82. end
  83. function SceneMesh:setTexture(texture)
  84. local retVal = Polycore.SceneMesh_setTexture(self.__ptr, texture.__ptr)
  85. end
  86. function SceneMesh:setMaterial(material)
  87. local retVal = Polycore.SceneMesh_setMaterial(self.__ptr, material.__ptr)
  88. end
  89. function SceneMesh:setMaterialByName(materialName)
  90. local retVal = Polycore.SceneMesh_setMaterialByName(self.__ptr, materialName)
  91. end
  92. function SceneMesh:setMesh(mesh)
  93. local retVal = Polycore.SceneMesh_setMesh(self.__ptr, mesh.__ptr)
  94. end
  95. function SceneMesh:setSkeleton(skeleton)
  96. local retVal = Polycore.SceneMesh_setSkeleton(self.__ptr, skeleton.__ptr)
  97. end
  98. function SceneMesh:getSkeleton()
  99. local retVal = Polycore.SceneMesh_getSkeleton(self.__ptr)
  100. if Polycore.__ptr_lookup[retVal] ~= nil then
  101. return Polycore.__ptr_lookup[retVal]
  102. else
  103. Polycore.__ptr_lookup[retVal] = Skeleton("__skip_ptr__")
  104. Polycore.__ptr_lookup[retVal].__ptr = retVal
  105. return Polycore.__ptr_lookup[retVal]
  106. end
  107. end
  108. function SceneMesh:renderMeshLocally()
  109. local retVal = Polycore.SceneMesh_renderMeshLocally(self.__ptr)
  110. end
  111. function SceneMesh:cacheToVertexBuffer(cache)
  112. local retVal = Polycore.SceneMesh_cacheToVertexBuffer(self.__ptr, cache)
  113. end
  114. function SceneMesh:__delete()
  115. Polycore.__ptr_lookup[self.__ptr] = nil
  116. Polycore.delete_SceneMesh(self.__ptr)
  117. end