2
0

SceneMesh.lua 4.1 KB

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