ScenePrimitive.lua 777 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. require "Polycode/SceneMesh"
  2. class "ScenePrimitive" (SceneMesh)
  3. TYPE_BOX = 0
  4. TYPE_PLANE = 1
  5. TYPE_SPHERE = 2
  6. TYPE_CYLINDER = 3
  7. TYPE_CONE = 4
  8. TYPE_VPLANE = 5
  9. TYPE_TORUS = 6
  10. function ScenePrimitive:ScenePrimitive(...)
  11. if type(arg[1]) == "table" and count(arg) == 1 then
  12. if ""..arg[1]:class() == "SceneMesh" then
  13. self.__ptr = arg[1].__ptr
  14. return
  15. end
  16. end
  17. for k,v in pairs(arg) do
  18. if type(v) == "table" then
  19. if v.__ptr ~= nil then
  20. arg[k] = v.__ptr
  21. end
  22. end
  23. end
  24. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  25. self.__ptr = Polycore.ScenePrimitive(unpack(arg))
  26. Polycore.__ptr_lookup[self.__ptr] = self
  27. end
  28. end
  29. function ScenePrimitive:__delete()
  30. Polycore.__ptr_lookup[self.__ptr] = nil
  31. Polycore.delete_ScenePrimitive(self.__ptr)
  32. end