Entity.lua 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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. Polycore.__ptr_lookup[self.__ptr] = self
  95. end
  96. end
  97. function Entity:Render()
  98. local retVal = Polycore.Entity_Render(self.__ptr)
  99. end
  100. function Entity:Update()
  101. local retVal = Polycore.Entity_Update(self.__ptr)
  102. end
  103. function Entity:transformAndRender()
  104. local retVal = Polycore.Entity_transformAndRender(self.__ptr)
  105. end
  106. function Entity:renderChildren()
  107. local retVal = Polycore.Entity_renderChildren(self.__ptr)
  108. end
  109. function Entity:dirtyMatrix(val)
  110. local retVal = Polycore.Entity_dirtyMatrix(self.__ptr, val)
  111. end
  112. function Entity:rebuildTransformMatrix()
  113. local retVal = Polycore.Entity_rebuildTransformMatrix(self.__ptr)
  114. end
  115. function Entity:updateEntityMatrix()
  116. local retVal = Polycore.Entity_updateEntityMatrix(self.__ptr)
  117. end
  118. function Entity:getTransformMatrix()
  119. local retVal = Polycore.Entity_getTransformMatrix(self.__ptr)
  120. if Polycore.__ptr_lookup[retVal] ~= nil then
  121. return Polycore.__ptr_lookup[retVal]
  122. else
  123. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  124. Polycore.__ptr_lookup[retVal].__ptr = retVal
  125. return Polycore.__ptr_lookup[retVal]
  126. end
  127. end
  128. function Entity:getConcatenatedMatrix()
  129. local retVal = Polycore.Entity_getConcatenatedMatrix(self.__ptr)
  130. if Polycore.__ptr_lookup[retVal] ~= nil then
  131. return Polycore.__ptr_lookup[retVal]
  132. else
  133. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  134. Polycore.__ptr_lookup[retVal].__ptr = retVal
  135. return Polycore.__ptr_lookup[retVal]
  136. end
  137. end
  138. function Entity:getConcatenatedRollMatrix()
  139. local retVal = Polycore.Entity_getConcatenatedRollMatrix(self.__ptr)
  140. if Polycore.__ptr_lookup[retVal] ~= nil then
  141. return Polycore.__ptr_lookup[retVal]
  142. else
  143. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  144. Polycore.__ptr_lookup[retVal].__ptr = retVal
  145. return Polycore.__ptr_lookup[retVal]
  146. end
  147. end
  148. function Entity:setTransformByMatrix(matrix)
  149. local retVal = Polycore.Entity_setTransformByMatrix(self.__ptr, matrix.__ptr)
  150. end
  151. function Entity:setTransformByMatrixPure(matrix)
  152. local retVal = Polycore.Entity_setTransformByMatrixPure(self.__ptr, matrix.__ptr)
  153. end
  154. function Entity:getLookAtMatrix(loc, upVector)
  155. local retVal = Polycore.Entity_getLookAtMatrix(self.__ptr, loc.__ptr, upVector.__ptr)
  156. if Polycore.__ptr_lookup[retVal] ~= nil then
  157. return Polycore.__ptr_lookup[retVal]
  158. else
  159. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  160. Polycore.__ptr_lookup[retVal].__ptr = retVal
  161. return Polycore.__ptr_lookup[retVal]
  162. end
  163. end
  164. function Entity:addEntity(newChild)
  165. local retVal = Polycore.Entity_addEntity(self.__ptr, newChild.__ptr)
  166. end
  167. function Entity:addChild(newChild)
  168. local retVal = Polycore.Entity_addChild(self.__ptr, newChild.__ptr)
  169. end
  170. function Entity:removeChild(entityToRemove)
  171. local retVal = Polycore.Entity_removeChild(self.__ptr, entityToRemove.__ptr)
  172. end
  173. function Entity:setParentEntity(entity)
  174. local retVal = Polycore.Entity_setParentEntity(self.__ptr, entity.__ptr)
  175. end
  176. function Entity:getParentEntity()
  177. local retVal = Polycore.Entity_getParentEntity(self.__ptr)
  178. if Polycore.__ptr_lookup[retVal] ~= nil then
  179. return Polycore.__ptr_lookup[retVal]
  180. else
  181. Polycore.__ptr_lookup[retVal] = Entity("__skip_ptr__")
  182. Polycore.__ptr_lookup[retVal].__ptr = retVal
  183. return Polycore.__ptr_lookup[retVal]
  184. end
  185. end
  186. function Entity:getPosition()
  187. local retVal = Polycore.Entity_getPosition(self.__ptr)
  188. if Polycore.__ptr_lookup[retVal] ~= nil then
  189. return Polycore.__ptr_lookup[retVal]
  190. else
  191. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  192. Polycore.__ptr_lookup[retVal].__ptr = retVal
  193. return Polycore.__ptr_lookup[retVal]
  194. end
  195. end
  196. function Entity:getCombinedPosition()
  197. local retVal = Polycore.Entity_getCombinedPosition(self.__ptr)
  198. if Polycore.__ptr_lookup[retVal] ~= nil then
  199. return Polycore.__ptr_lookup[retVal]
  200. else
  201. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  202. Polycore.__ptr_lookup[retVal].__ptr = retVal
  203. return Polycore.__ptr_lookup[retVal]
  204. end
  205. end
  206. function Entity:setPosition(x, y, z)
  207. local retVal = Polycore.Entity_setPosition(self.__ptr, x, y, z)
  208. end
  209. function Entity:setPositionX(x)
  210. local retVal = Polycore.Entity_setPositionX(self.__ptr, x)
  211. end
  212. function Entity:setPositionY(y)
  213. local retVal = Polycore.Entity_setPositionY(self.__ptr, y)
  214. end
  215. function Entity:Translate(x, y, z)
  216. local retVal = Polycore.Entity_Translate(self.__ptr, x, y, z)
  217. end
  218. function Entity:setPositionZ(z)
  219. local retVal = Polycore.Entity_setPositionZ(self.__ptr, z)
  220. end
  221. function Entity:setScaleX(x)
  222. local retVal = Polycore.Entity_setScaleX(self.__ptr, x)
  223. end
  224. function Entity:setScaleY(y)
  225. local retVal = Polycore.Entity_setScaleY(self.__ptr, y)
  226. end
  227. function Entity:setScaleZ(z)
  228. local retVal = Polycore.Entity_setScaleZ(self.__ptr, z)
  229. end
  230. function Entity:Scale(x, y, z)
  231. local retVal = Polycore.Entity_Scale(self.__ptr, x, y, z)
  232. end
  233. function Entity:setScale(x, y, z)
  234. local retVal = Polycore.Entity_setScale(self.__ptr, x, y, z)
  235. end
  236. function Entity:getCompoundScale()
  237. local retVal = Polycore.Entity_getCompoundScale(self.__ptr)
  238. if Polycore.__ptr_lookup[retVal] ~= nil then
  239. return Polycore.__ptr_lookup[retVal]
  240. else
  241. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  242. Polycore.__ptr_lookup[retVal].__ptr = retVal
  243. return Polycore.__ptr_lookup[retVal]
  244. end
  245. end
  246. function Entity:getScale()
  247. local retVal = Polycore.Entity_getScale(self.__ptr)
  248. if Polycore.__ptr_lookup[retVal] ~= nil then
  249. return Polycore.__ptr_lookup[retVal]
  250. else
  251. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  252. Polycore.__ptr_lookup[retVal].__ptr = retVal
  253. return Polycore.__ptr_lookup[retVal]
  254. end
  255. end
  256. function Entity:getCombinedPitch()
  257. local retVal = Polycore.Entity_getCombinedPitch(self.__ptr)
  258. return retVal
  259. end
  260. function Entity:getCombinedYaw()
  261. local retVal = Polycore.Entity_getCombinedYaw(self.__ptr)
  262. return retVal
  263. end
  264. function Entity:getCombinedRoll()
  265. local retVal = Polycore.Entity_getCombinedRoll(self.__ptr)
  266. return retVal
  267. end
  268. function Entity:rebuildRotation()
  269. local retVal = Polycore.Entity_rebuildRotation(self.__ptr)
  270. end
  271. function Entity:setPitch(pitch)
  272. local retVal = Polycore.Entity_setPitch(self.__ptr, pitch)
  273. end
  274. function Entity:setYaw(yaw)
  275. local retVal = Polycore.Entity_setYaw(self.__ptr, yaw)
  276. end
  277. function Entity:setRoll(roll)
  278. local retVal = Polycore.Entity_setRoll(self.__ptr, roll)
  279. end
  280. function Entity:Roll(roll)
  281. local retVal = Polycore.Entity_Roll(self.__ptr, roll)
  282. end
  283. function Entity:Yaw(yaw)
  284. local retVal = Polycore.Entity_Yaw(self.__ptr, yaw)
  285. end
  286. function Entity:Pitch(pitch)
  287. local retVal = Polycore.Entity_Pitch(self.__ptr, pitch)
  288. end
  289. function Entity:getPitch()
  290. local retVal = Polycore.Entity_getPitch(self.__ptr)
  291. return retVal
  292. end
  293. function Entity:getYaw()
  294. local retVal = Polycore.Entity_getYaw(self.__ptr)
  295. return retVal
  296. end
  297. function Entity:getRoll()
  298. local retVal = Polycore.Entity_getRoll(self.__ptr)
  299. return retVal
  300. end
  301. function Entity:setRotationQuat(w, x, y, z)
  302. local retVal = Polycore.Entity_setRotationQuat(self.__ptr, w, x, y, z)
  303. end
  304. function Entity:getRotationQuat()
  305. local retVal = Polycore.Entity_getRotationQuat(self.__ptr)
  306. if Polycore.__ptr_lookup[retVal] ~= nil then
  307. return Polycore.__ptr_lookup[retVal]
  308. else
  309. Polycore.__ptr_lookup[retVal] = Quaternion("__skip_ptr__")
  310. Polycore.__ptr_lookup[retVal].__ptr = retVal
  311. return Polycore.__ptr_lookup[retVal]
  312. end
  313. end
  314. function Entity:lookAt(loc, upVector)
  315. local retVal = Polycore.Entity_lookAt(self.__ptr, loc.__ptr, upVector.__ptr)
  316. end
  317. function Entity:lookAtEntity(entity, upVector)
  318. local retVal = Polycore.Entity_lookAtEntity(self.__ptr, entity.__ptr, upVector.__ptr)
  319. end
  320. function Entity:getCombinedColor()
  321. local retVal = Polycore.Entity_getCombinedColor(self.__ptr)
  322. if Polycore.__ptr_lookup[retVal] ~= nil then
  323. return Polycore.__ptr_lookup[retVal]
  324. else
  325. Polycore.__ptr_lookup[retVal] = Color("__skip_ptr__")
  326. Polycore.__ptr_lookup[retVal].__ptr = retVal
  327. return Polycore.__ptr_lookup[retVal]
  328. end
  329. end
  330. function Entity:setColor(r, g, b, a)
  331. local retVal = Polycore.Entity_setColor(self.__ptr, r, g, b, a)
  332. end
  333. function Entity:setColorInt(r, g, b, a)
  334. local retVal = Polycore.Entity_setColorInt(self.__ptr, r, g, b, a)
  335. end
  336. function Entity:recalculateBBox()
  337. local retVal = Polycore.Entity_recalculateBBox(self.__ptr)
  338. end
  339. function Entity:getBBoxRadius()
  340. local retVal = Polycore.Entity_getBBoxRadius(self.__ptr)
  341. return retVal
  342. end
  343. function Entity:getCompoundBBoxRadius()
  344. local retVal = Polycore.Entity_getCompoundBBoxRadius(self.__ptr)
  345. return retVal
  346. end
  347. function Entity:setBBoxRadius(rad)
  348. local retVal = Polycore.Entity_setBBoxRadius(self.__ptr, rad)
  349. end
  350. function Entity:setMask(mask)
  351. local retVal = Polycore.Entity_setMask(self.__ptr, mask.__ptr)
  352. end
  353. function Entity:clearMask()
  354. local retVal = Polycore.Entity_clearMask(self.__ptr)
  355. end
  356. function Entity:setBlendingMode(newBl_endingMode)
  357. local retVal = Polycore.Entity_setBlendingMode(self.__ptr, newBl_endingMode)
  358. end
  359. function Entity:getChildCenter()
  360. local retVal = Polycore.Entity_getChildCenter(self.__ptr)
  361. if Polycore.__ptr_lookup[retVal] ~= nil then
  362. return Polycore.__ptr_lookup[retVal]
  363. else
  364. Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
  365. Polycore.__ptr_lookup[retVal].__ptr = retVal
  366. return Polycore.__ptr_lookup[retVal]
  367. end
  368. end
  369. function Entity:getEntityProp(propName)
  370. local retVal = Polycore.Entity_getEntityProp(self.__ptr, propName)
  371. return retVal
  372. end
  373. function Entity:doUpdates()
  374. local retVal = Polycore.Entity_doUpdates(self.__ptr)
  375. end
  376. function Entity:buildPositionMatrix()
  377. local retVal = Polycore.Entity_buildPositionMatrix(self.__ptr)
  378. if Polycore.__ptr_lookup[retVal] ~= nil then
  379. return Polycore.__ptr_lookup[retVal]
  380. else
  381. Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
  382. Polycore.__ptr_lookup[retVal].__ptr = retVal
  383. return Polycore.__ptr_lookup[retVal]
  384. end
  385. end
  386. function Entity:adjustMatrixForChildren()
  387. local retVal = Polycore.Entity_adjustMatrixForChildren(self.__ptr)
  388. end
  389. function Entity:setRenderer(r_enderer)
  390. local retVal = Polycore.Entity_setRenderer(self.__ptr, r_enderer.__ptr)
  391. end
  392. function Entity:__delete()
  393. Polycore.__ptr_lookup[self.__ptr] = nil
  394. Polycore.delete_Entity(self.__ptr)
  395. end