Entity.lua 14 KB

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