Entity.lua 13 KB

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