Matrix4.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. function Matrix4() {
  2. if(arguments[0] != "__skip_ptr__") {
  3. this.__ptr = Polycode.Matrix4()
  4. }
  5. }
  6. Duktape.fin(Matrix4.prototype, function (x) {
  7. if (x === Matrix4.prototype) {
  8. return;
  9. }
  10. Polycode.Matrix4__delete(x.__ptr)
  11. })
  12. Matrix4.prototype.identity = function() {
  13. Polycode.Matrix4_identity(this.__ptr)
  14. }
  15. Matrix4.prototype.rotateVector = function(v2) {
  16. var retVal = new Vector3("__skip_ptr__")
  17. retVal.__ptr = Polycode.Matrix4_rotateVector(this.__ptr, v2)
  18. return retVal
  19. }
  20. Matrix4.prototype.getPosition = function() {
  21. var retVal = new Vector3("__skip_ptr__")
  22. retVal.__ptr = Polycode.Matrix4_getPosition(this.__ptr)
  23. return retVal
  24. }
  25. Matrix4.prototype.multiplyWithPerspective = function(v2) {
  26. var retVal = new Vector3("__skip_ptr__")
  27. retVal.__ptr = Polycode.Matrix4_multiplyWithPerspective(this.__ptr, v2)
  28. return retVal
  29. }
  30. Matrix4.prototype.multVector3 = function(v2) {
  31. var retVal = new Vector3("__skip_ptr__")
  32. retVal.__ptr = Polycode.Matrix4_multVector3(this.__ptr, v2)
  33. return retVal
  34. }
  35. Matrix4.prototype.multVector4 = function(v2) {
  36. var retVal = new Vector4("__skip_ptr__")
  37. retVal.__ptr = Polycode.Matrix4_multVector4(this.__ptr, v2)
  38. return retVal
  39. }
  40. Matrix4.prototype.Translate = function(x,y,z) {
  41. Polycode.Matrix4_Translate(this.__ptr, x, y, z)
  42. }
  43. Matrix4.prototype.setPosition = function(x,y,z) {
  44. Polycode.Matrix4_setPosition(this.__ptr, x, y, z)
  45. }
  46. Matrix4.prototype.setScale = function(scale) {
  47. Polycode.Matrix4_setScale(this.__ptr, scale)
  48. }
  49. Matrix4.prototype.transpose = function() {
  50. var retVal = new Matrix4("__skip_ptr__")
  51. retVal.__ptr = Polycode.Matrix4_transpose(this.__ptr)
  52. return retVal
  53. }
  54. Matrix4.prototype.Inverse = function() {
  55. var retVal = new Matrix4("__skip_ptr__")
  56. retVal.__ptr = Polycode.Matrix4_Inverse(this.__ptr)
  57. return retVal
  58. }
  59. Matrix4.prototype.inverseAffine = function() {
  60. var retVal = new Matrix4("__skip_ptr__")
  61. retVal.__ptr = Polycode.Matrix4_inverseAffine(this.__ptr)
  62. return retVal
  63. }
  64. Matrix4.prototype.determinant = function() {
  65. return Polycode.Matrix4_determinant(this.__ptr)
  66. }
  67. Matrix4.prototype.setOrthoProjection = function(left,right,bottom,top,zNear,zFar) {
  68. Polycode.Matrix4_setOrthoProjection(this.__ptr, left, right, bottom, top, zNear, zFar)
  69. }
  70. Matrix4.prototype.setProjectionFrustum = function(left,right,bottom,top,zNear,zFar) {
  71. Polycode.Matrix4_setProjectionFrustum(this.__ptr, left, right, bottom, top, zNear, zFar)
  72. }
  73. Matrix4.prototype.setProjection = function(fov,aspect,zNear,zFar) {
  74. Polycode.Matrix4_setProjection(this.__ptr, fov, aspect, zNear, zFar)
  75. }