Entity.lua 14 KB

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