SceneMesh.lua 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 retVal == nil then return nil end
  49. if Polycore.__ptr_lookup[retVal] ~= nil then
  50. return Polycore.__ptr_lookup[retVal]
  51. else
  52. Polycore.__ptr_lookup[retVal] = ShaderBinding("__skip_ptr__")
  53. Polycore.__ptr_lookup[retVal].__ptr = retVal
  54. return Polycore.__ptr_lookup[retVal]
  55. end
  56. end
  57. function SceneMesh:getMesh()
  58. local retVal = Polycore.SceneMesh_getMesh(self.__ptr)
  59. if retVal == nil then return nil end
  60. if Polycore.__ptr_lookup[retVal] ~= nil then
  61. return Polycore.__ptr_lookup[retVal]
  62. else
  63. Polycore.__ptr_lookup[retVal] = Mesh("__skip_ptr__")
  64. Polycore.__ptr_lookup[retVal].__ptr = retVal
  65. return Polycore.__ptr_lookup[retVal]
  66. end
  67. end
  68. function SceneMesh:getTexture()
  69. local retVal = Polycore.SceneMesh_getTexture(self.__ptr)
  70. if retVal == nil then return nil end
  71. if Polycore.__ptr_lookup[retVal] ~= nil then
  72. return Polycore.__ptr_lookup[retVal]
  73. else
  74. Polycore.__ptr_lookup[retVal] = Texture("__skip_ptr__")
  75. Polycore.__ptr_lookup[retVal].__ptr = retVal
  76. return Polycore.__ptr_lookup[retVal]
  77. end
  78. end
  79. function SceneMesh:getMaterial()
  80. local retVal = Polycore.SceneMesh_getMaterial(self.__ptr)
  81. if retVal == nil then return nil end
  82. if Polycore.__ptr_lookup[retVal] ~= nil then
  83. return Polycore.__ptr_lookup[retVal]
  84. else
  85. Polycore.__ptr_lookup[retVal] = Material("__skip_ptr__")
  86. Polycore.__ptr_lookup[retVal].__ptr = retVal
  87. return Polycore.__ptr_lookup[retVal]
  88. end
  89. end
  90. function SceneMesh:loadTexture(fileName, clamp)
  91. local retVal = Polycore.SceneMesh_loadTexture(self.__ptr, fileName.__ptr, clamp)
  92. end
  93. function SceneMesh:loadSkeleton(fileName)
  94. local retVal = Polycore.SceneMesh_loadSkeleton(self.__ptr, fileName.__ptr)
  95. end
  96. function SceneMesh:setTexture(texture)
  97. local retVal = Polycore.SceneMesh_setTexture(self.__ptr, texture.__ptr)
  98. end
  99. function SceneMesh:setMaterial(material)
  100. local retVal = Polycore.SceneMesh_setMaterial(self.__ptr, material.__ptr)
  101. end
  102. function SceneMesh:setMaterialByName(materialName)
  103. local retVal = Polycore.SceneMesh_setMaterialByName(self.__ptr, materialName.__ptr)
  104. end
  105. function SceneMesh:setMesh(mesh)
  106. local retVal = Polycore.SceneMesh_setMesh(self.__ptr, mesh.__ptr)
  107. end
  108. function SceneMesh:setSkeleton(skeleton)
  109. local retVal = Polycore.SceneMesh_setSkeleton(self.__ptr, skeleton.__ptr)
  110. end
  111. function SceneMesh:getSkeleton()
  112. local retVal = Polycore.SceneMesh_getSkeleton(self.__ptr)
  113. if retVal == nil then return nil end
  114. if Polycore.__ptr_lookup[retVal] ~= nil then
  115. return Polycore.__ptr_lookup[retVal]
  116. else
  117. Polycore.__ptr_lookup[retVal] = Skeleton("__skip_ptr__")
  118. Polycore.__ptr_lookup[retVal].__ptr = retVal
  119. return Polycore.__ptr_lookup[retVal]
  120. end
  121. end
  122. function SceneMesh:renderMeshLocally()
  123. local retVal = Polycore.SceneMesh_renderMeshLocally(self.__ptr)
  124. end
  125. function SceneMesh:cacheToVertexBuffer(cache)
  126. local retVal = Polycore.SceneMesh_cacheToVertexBuffer(self.__ptr, cache)
  127. end
  128. function SceneMesh:__delete()
  129. Polycore.__ptr_lookup[self.__ptr] = nil
  130. Polycore.delete_SceneMesh(self.__ptr)
  131. end