Entity.lua 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. class "Entity"
  2. function Entity:__index__(name)
  3. if name == "custEntityType" then
  4. return Polycore.Entity_get_custEntityType(self.__ptr)
  5. elseif name == "billboardMode" then
  6. return Polycore.Entity_get_billboardMode(self.__ptr)
  7. elseif name == "billboardRoll" then
  8. return Polycore.Entity_get_billboardRoll(self.__ptr)
  9. elseif name == "alphaTest" then
  10. return Polycore.Entity_get_alphaTest(self.__ptr)
  11. elseif name == "backfaceCulled" then
  12. return Polycore.Entity_get_backfaceCulled(self.__ptr)
  13. elseif name == "renderWireframe" then
  14. return Polycore.Entity_get_renderWireframe(self.__ptr)
  15. elseif name == "enabled" then
  16. return Polycore.Entity_get_enabled(self.__ptr)
  17. elseif name == "visible" then
  18. return Polycore.Entity_get_visible(self.__ptr)
  19. elseif name == "depthWrite" then
  20. return Polycore.Entity_get_depthWrite(self.__ptr)
  21. elseif name == "depthTest" then
  22. return Polycore.Entity_get_depthTest(self.__ptr)
  23. elseif name == "blendingMode" then
  24. return Polycore.Entity_get_blendingMode(self.__ptr)
  25. elseif name == "colorAffectsChildren" then
  26. return Polycore.Entity_get_colorAffectsChildren(self.__ptr)
  27. elseif name == "depthOnly" then
  28. return Polycore.Entity_get_depthOnly(self.__ptr)
  29. elseif name == "ignoreParentMatrix" then
  30. return Polycore.Entity_get_ignoreParentMatrix(self.__ptr)
  31. elseif name == "isMask" then
  32. return Polycore.Entity_get_isMask(self.__ptr)
  33. end
  34. end
  35. function Entity:__set_callback(name,value)
  36. if name == "custEntityType" then
  37. Polycore.Entity_set_custEntityType(self.__ptr, value)
  38. return true
  39. elseif name == "billboardMode" then
  40. Polycore.Entity_set_billboardMode(self.__ptr, value)
  41. return true
  42. elseif name == "billboardRoll" then
  43. Polycore.Entity_set_billboardRoll(self.__ptr, value)
  44. return true
  45. elseif name == "alphaTest" then
  46. Polycore.Entity_set_alphaTest(self.__ptr, value)
  47. return true
  48. elseif name == "backfaceCulled" then
  49. Polycore.Entity_set_backfaceCulled(self.__ptr, value)
  50. return true
  51. elseif name == "renderWireframe" then
  52. Polycore.Entity_set_renderWireframe(self.__ptr, value)
  53. return true
  54. elseif name == "enabled" then
  55. Polycore.Entity_set_enabled(self.__ptr, value)
  56. return true
  57. elseif name == "visible" then
  58. Polycore.Entity_set_visible(self.__ptr, value)
  59. return true
  60. elseif name == "depthWrite" then
  61. Polycore.Entity_set_depthWrite(self.__ptr, value)
  62. return true
  63. elseif name == "depthTest" then
  64. Polycore.Entity_set_depthTest(self.__ptr, value)
  65. return true
  66. elseif name == "blendingMode" then
  67. Polycore.Entity_set_blendingMode(self.__ptr, value)
  68. return true
  69. elseif name == "colorAffectsChildren" then
  70. Polycore.Entity_set_colorAffectsChildren(self.__ptr, value)
  71. return true
  72. elseif name == "depthOnly" then
  73. Polycore.Entity_set_depthOnly(self.__ptr, value)
  74. return true
  75. elseif name == "ignoreParentMatrix" then
  76. Polycore.Entity_set_ignoreParentMatrix(self.__ptr, value)
  77. return true
  78. elseif name == "isMask" then
  79. Polycore.Entity_set_isMask(self.__ptr, value)
  80. return true
  81. end
  82. return false
  83. end
  84. function Entity:Entity(...)
  85. for k,v in pairs(arg) do
  86. if type(v) == "table" then
  87. if v.__ptr ~= nil then
  88. arg[k] = v.__ptr
  89. end
  90. end
  91. end
  92. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  93. self.__ptr = Polycore.Entity(unpack(arg))
  94. end
  95. end
  96. function Entity:Render()
  97. local retVal = Polycore.Entity_Render(self.__ptr)
  98. end
  99. function Entity:Update()
  100. local retVal = Polycore.Entity_Update(self.__ptr)
  101. end
  102. function Entity:transformAndRender()
  103. local retVal = Polycore.Entity_transformAndRender(self.__ptr)
  104. end
  105. function Entity:renderChildren()
  106. local retVal = Polycore.Entity_renderChildren(self.__ptr)
  107. end
  108. function Entity:dirtyMatrix(val)
  109. local retVal = Polycore.Entity_dirtyMatrix(self.__ptr, val)
  110. end
  111. function Entity:rebuildTransformMatrix()
  112. local retVal = Polycore.Entity_rebuildTransformMatrix(self.__ptr)
  113. end
  114. function Entity:updateEntityMatrix()
  115. local retVal = Polycore.Entity_updateEntityMatrix(self.__ptr)
  116. end
  117. function Entity:getTransformMatrix()
  118. local retVal = Polycore.Entity_getTransformMatrix(self.__ptr)
  119. if Polycore.__ptr_lookup[retVal] ~= nil then
  120. return Polycore.__ptr_lookup[retVal]
  121. else
  122. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  123. Polycore.__ptr_lookup[retVal].__ptr = retVal
  124. return Polycore.__ptr_lookup[retVal]
  125. end
  126. end
  127. function Entity:getConcatenatedMatrix()
  128. local retVal = Polycore.Entity_getConcatenatedMatrix(self.__ptr)
  129. if Polycore.__ptr_lookup[retVal] ~= nil then
  130. return Polycore.__ptr_lookup[retVal]
  131. else
  132. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  133. Polycore.__ptr_lookup[retVal].__ptr = retVal
  134. return Polycore.__ptr_lookup[retVal]
  135. end
  136. end
  137. function Entity:getConcatenatedRollMatrix()
  138. local retVal = Polycore.Entity_getConcatenatedRollMatrix(self.__ptr)
  139. if Polycore.__ptr_lookup[retVal] ~= nil then
  140. return Polycore.__ptr_lookup[retVal]
  141. else
  142. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  143. Polycore.__ptr_lookup[retVal].__ptr = retVal
  144. return Polycore.__ptr_lookup[retVal]
  145. end
  146. end
  147. function Entity:setTransformByMatrix(matrix)
  148. local retVal = Polycore.Entity_setTransformByMatrix(self.__ptr, matrix.__ptr)
  149. end
  150. function Entity:setTransformByMatrixPure(matrix)
  151. local retVal = Polycore.Entity_setTransformByMatrixPure(self.__ptr, matrix.__ptr)
  152. end
  153. function Entity:getLookAtMatrix(loc, upVector)
  154. local retVal = Polycore.Entity_getLookAtMatrix(self.__ptr, loc.__ptr, upVector.__ptr)
  155. if Polycore.__ptr_lookup[retVal] ~= nil then
  156. return Polycore.__ptr_lookup[retVal]
  157. else
  158. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  159. Polycore.__ptr_lookup[retVal].__ptr = retVal
  160. return Polycore.__ptr_lookup[retVal]
  161. end
  162. end
  163. function Entity:addEntity(newChild)
  164. local retVal = Polycore.Entity_addEntity(self.__ptr, newChild.__ptr)
  165. end
  166. function Entity:addChild(newChild)
  167. local retVal = Polycore.Entity_addChild(self.__ptr, newChild.__ptr)
  168. end
  169. function Entity:removeChild(entityToRemove)
  170. local retVal = Polycore.Entity_removeChild(self.__ptr, entityToRemove.__ptr)
  171. end
  172. function Entity:setParentEntity(entity)
  173. local retVal = Polycore.Entity_setParentEntity(self.__ptr, entity.__ptr)
  174. end
  175. function Entity:getParentEntity()
  176. local retVal = Polycore.Entity_getParentEntity(self.__ptr)
  177. if Polycore.__ptr_lookup[retVal] ~= nil then
  178. return Polycore.__ptr_lookup[retVal]
  179. else
  180. Polycore.__ptr_lookup[retVal] = Entity("__skip_ptr__")
  181. Polycore.__ptr_lookup[retVal].__ptr = retVal
  182. return Polycore.__ptr_lookup[retVal]
  183. end
  184. end
  185. function Entity:getPosition()
  186. local retVal = Polycore.Entity_getPosition(self.__ptr)
  187. if Polycore.__ptr_lookup[retVal] ~= nil then
  188. return Polycore.__ptr_lookup[retVal]
  189. else
  190. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  191. Polycore.__ptr_lookup[retVal].__ptr = retVal
  192. return Polycore.__ptr_lookup[retVal]
  193. end
  194. end
  195. function Entity:getCombinedPosition()
  196. local retVal = Polycore.Entity_getCombinedPosition(self.__ptr)
  197. if Polycore.__ptr_lookup[retVal] ~= nil then
  198. return Polycore.__ptr_lookup[retVal]
  199. else
  200. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  201. Polycore.__ptr_lookup[retVal].__ptr = retVal
  202. return Polycore.__ptr_lookup[retVal]
  203. end
  204. end
  205. function Entity:setPosition(x, y, z)
  206. local retVal = Polycore.Entity_setPosition(self.__ptr, x, y, z)
  207. end
  208. function Entity:setPositionX(x)
  209. local retVal = Polycore.Entity_setPositionX(self.__ptr, x)
  210. end
  211. function Entity:setPositionY(y)
  212. local retVal = Polycore.Entity_setPositionY(self.__ptr, y)
  213. end
  214. function Entity:Translate(x, y, z)
  215. local retVal = Polycore.Entity_Translate(self.__ptr, x, y, z)
  216. end
  217. function Entity:setPositionZ(z)
  218. local retVal = Polycore.Entity_setPositionZ(self.__ptr, z)
  219. end
  220. function Entity:setScaleX(x)
  221. local retVal = Polycore.Entity_setScaleX(self.__ptr, x)
  222. end
  223. function Entity:setScaleY(y)
  224. local retVal = Polycore.Entity_setScaleY(self.__ptr, y)
  225. end
  226. function Entity:setScaleZ(z)
  227. local retVal = Polycore.Entity_setScaleZ(self.__ptr, z)
  228. end
  229. function Entity:Scale(x, y, z)
  230. local retVal = Polycore.Entity_Scale(self.__ptr, x, y, z)
  231. end
  232. function Entity:setScale(x, y, z)
  233. local retVal = Polycore.Entity_setScale(self.__ptr, x, y, z)
  234. end
  235. function Entity:getCompoundScale()
  236. local retVal = Polycore.Entity_getCompoundScale(self.__ptr)
  237. if Polycore.__ptr_lookup[retVal] ~= nil then
  238. return Polycore.__ptr_lookup[retVal]
  239. else
  240. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  241. Polycore.__ptr_lookup[retVal].__ptr = retVal
  242. return Polycore.__ptr_lookup[retVal]
  243. end
  244. end
  245. function Entity:getScale()
  246. local retVal = Polycore.Entity_getScale(self.__ptr)
  247. if Polycore.__ptr_lookup[retVal] ~= nil then
  248. return Polycore.__ptr_lookup[retVal]
  249. else
  250. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  251. Polycore.__ptr_lookup[retVal].__ptr = retVal
  252. return Polycore.__ptr_lookup[retVal]
  253. end
  254. end
  255. function Entity:getCombinedPitch()
  256. local retVal = Polycore.Entity_getCombinedPitch(self.__ptr)
  257. return retVal
  258. end
  259. function Entity:getCombinedYaw()
  260. local retVal = Polycore.Entity_getCombinedYaw(self.__ptr)
  261. return retVal
  262. end
  263. function Entity:getCombinedRoll()
  264. local retVal = Polycore.Entity_getCombinedRoll(self.__ptr)
  265. return retVal
  266. end
  267. function Entity:rebuildRotation()
  268. local retVal = Polycore.Entity_rebuildRotation(self.__ptr)
  269. end
  270. function Entity:setPitch(pitch)
  271. local retVal = Polycore.Entity_setPitch(self.__ptr, pitch)
  272. end
  273. function Entity:setYaw(yaw)
  274. local retVal = Polycore.Entity_setYaw(self.__ptr, yaw)
  275. end
  276. function Entity:setRoll(roll)
  277. local retVal = Polycore.Entity_setRoll(self.__ptr, roll)
  278. end
  279. function Entity:Roll(roll)
  280. local retVal = Polycore.Entity_Roll(self.__ptr, roll)
  281. end
  282. function Entity:Yaw(yaw)
  283. local retVal = Polycore.Entity_Yaw(self.__ptr, yaw)
  284. end
  285. function Entity:Pitch(pitch)
  286. local retVal = Polycore.Entity_Pitch(self.__ptr, pitch)
  287. end
  288. function Entity:getPitch()
  289. local retVal = Polycore.Entity_getPitch(self.__ptr)
  290. return retVal
  291. end
  292. function Entity:getYaw()
  293. local retVal = Polycore.Entity_getYaw(self.__ptr)
  294. return retVal
  295. end
  296. function Entity:getRoll()
  297. local retVal = Polycore.Entity_getRoll(self.__ptr)
  298. return retVal
  299. end
  300. function Entity:setRotationQuat(w, x, y, z)
  301. local retVal = Polycore.Entity_setRotationQuat(self.__ptr, w, x, y, z)
  302. end
  303. function Entity:getRotationQuat()
  304. local retVal = Polycore.Entity_getRotationQuat(self.__ptr)
  305. if Polycore.__ptr_lookup[retVal] ~= nil then
  306. return Polycore.__ptr_lookup[retVal]
  307. else
  308. Polycore.__ptr_lookup[retVal] = Quaternion("__skip_ptr__")
  309. Polycore.__ptr_lookup[retVal].__ptr = retVal
  310. return Polycore.__ptr_lookup[retVal]
  311. end
  312. end
  313. function Entity:lookAt(loc, upVector)
  314. local retVal = Polycore.Entity_lookAt(self.__ptr, loc.__ptr, upVector.__ptr)
  315. end
  316. function Entity:lookAtEntity(entity, upVector)
  317. local retVal = Polycore.Entity_lookAtEntity(self.__ptr, entity.__ptr, upVector.__ptr)
  318. end
  319. function Entity:getCombinedColor()
  320. local retVal = Polycore.Entity_getCombinedColor(self.__ptr)
  321. if Polycore.__ptr_lookup[retVal] ~= nil then
  322. return Polycore.__ptr_lookup[retVal]
  323. else
  324. Polycore.__ptr_lookup[retVal] = Color("__skip_ptr__")
  325. Polycore.__ptr_lookup[retVal].__ptr = retVal
  326. return Polycore.__ptr_lookup[retVal]
  327. end
  328. end
  329. function Entity:setColor(r, g, b, a)
  330. local retVal = Polycore.Entity_setColor(self.__ptr, r, g, b, a)
  331. end
  332. function Entity:setColorInt(r, g, b, a)
  333. local retVal = Polycore.Entity_setColorInt(self.__ptr, r, g, b, a)
  334. end
  335. function Entity:recalculateBBox()
  336. local retVal = Polycore.Entity_recalculateBBox(self.__ptr)
  337. end
  338. function Entity:getBBoxRadius()
  339. local retVal = Polycore.Entity_getBBoxRadius(self.__ptr)
  340. return retVal
  341. end
  342. function Entity:getCompoundBBoxRadius()
  343. local retVal = Polycore.Entity_getCompoundBBoxRadius(self.__ptr)
  344. return retVal
  345. end
  346. function Entity:setBBoxRadius(rad)
  347. local retVal = Polycore.Entity_setBBoxRadius(self.__ptr, rad)
  348. end
  349. function Entity:setMask(mask)
  350. local retVal = Polycore.Entity_setMask(self.__ptr, mask.__ptr)
  351. end
  352. function Entity:clearMask()
  353. local retVal = Polycore.Entity_clearMask(self.__ptr)
  354. end
  355. function Entity:setBlendingMode(newBl_endingMode)
  356. local retVal = Polycore.Entity_setBlendingMode(self.__ptr, newBl_endingMode)
  357. end
  358. function Entity:getChildCenter()
  359. local retVal = Polycore.Entity_getChildCenter(self.__ptr)
  360. if Polycore.__ptr_lookup[retVal] ~= nil then
  361. return Polycore.__ptr_lookup[retVal]
  362. else
  363. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  364. Polycore.__ptr_lookup[retVal].__ptr = retVal
  365. return Polycore.__ptr_lookup[retVal]
  366. end
  367. end
  368. function Entity:getEntityProp(propName)
  369. local retVal = Polycore.Entity_getEntityProp(self.__ptr, propName)
  370. return retVal
  371. end
  372. function Entity:doUpdates()
  373. local retVal = Polycore.Entity_doUpdates(self.__ptr)
  374. end
  375. function Entity:buildPositionMatrix()
  376. local retVal = Polycore.Entity_buildPositionMatrix(self.__ptr)
  377. if Polycore.__ptr_lookup[retVal] ~= nil then
  378. return Polycore.__ptr_lookup[retVal]
  379. else
  380. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  381. Polycore.__ptr_lookup[retVal].__ptr = retVal
  382. return Polycore.__ptr_lookup[retVal]
  383. end
  384. end
  385. function Entity:adjustMatrixForChildren()
  386. local retVal = Polycore.Entity_adjustMatrixForChildren(self.__ptr)
  387. end
  388. function Entity:setRenderer(r_enderer)
  389. local retVal = Polycore.Entity_setRenderer(self.__ptr, r_enderer.__ptr)
  390. end