Entity.lua 14 KB

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