Want more features on Pastebin? Sign Up, it's FREE!
Guest

Matrix4f NIO naive

By: a guest on Jul 24th, 2011  |  syntax: Java 5  |  size: 2.62 KB  |  views: 134  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public void mul4f(Matrix4fBuffer leftM, Matrix4fBuffer rightM) {
  2.         final FloatBuffer left = leftM.buffer;
  3.         final FloatBuffer right = rightM.buffer;
  4.  
  5.         float m00 = left.get(0) * right.get(0) + left.get(1) * right.get(4) + left.get(2) * right.get(8) + left.get(3) * right.get(12);
  6.         float m10 = left.get(0) * right.get(1) + left.get(1) * right.get(5) + left.get(2) * right.get(9) + left.get(3) * right.get(13);
  7.         float m20 = left.get(0) * right.get(2) + left.get(1) * right.get(6) + left.get(2) * right.get(10) + left.get(3) * right.get(14);
  8.         float m30 = left.get(0) * right.get(3) + left.get(1) * right.get(7) + left.get(2) * right.get(11) + left.get(3) * right.get(15);
  9.  
  10.         float m01 = left.get(4) * right.get(0) + left.get(5) * right.get(4) + left.get(6) * right.get(8) + left.get(7) * right.get(12);
  11.         float m11 = left.get(4) * right.get(1) + left.get(5) * right.get(5) + left.get(6) * right.get(9) + left.get(7) * right.get(13);
  12.         float m21 = left.get(4) * right.get(2) + left.get(5) * right.get(6) + left.get(6) * right.get(10) + left.get(7) * right.get(14);
  13.         float m31 = left.get(4) * right.get(3) + left.get(5) * right.get(7) + left.get(6) * right.get(11) + left.get(7) * right.get(15);
  14.  
  15.         float m02 = left.get(8) * right.get(0) + left.get(9) * right.get(4) + left.get(10) * right.get(8) + left.get(11) * right.get(12);
  16.         float m12 = left.get(8) * right.get(1) + left.get(9) * right.get(5) + left.get(10) * right.get(9) + left.get(11) * right.get(13);
  17.         float m22 = left.get(8) * right.get(2) + left.get(9) * right.get(6) + left.get(10) * right.get(10) + left.get(11) * right.get(14);
  18.         float m32 = left.get(8) * right.get(3) + left.get(9) * right.get(7) + left.get(10) * right.get(11) + left.get(11) * right.get(15);
  19.  
  20.         float m03 = left.get(12) * right.get(0) + left.get(13) * right.get(4) + left.get(14) * right.get(8) + left.get(15) * right.get(12);
  21.         float m13 = left.get(12) * right.get(1) + left.get(13) * right.get(5) + left.get(14) * right.get(9) + left.get(15) * right.get(13);
  22.         float m23 = left.get(12) * right.get(2) + left.get(13) * right.get(6) + left.get(14) * right.get(10) + left.get(15) * right.get(14);
  23.         float m33 = left.get(12) * right.get(3) + left.get(13) * right.get(7) + left.get(14) * right.get(11) + left.get(15) * right.get(15);
  24.  
  25.         final FloatBuffer buffer = this.buffer;
  26.  
  27.         buffer.put(0, m00);
  28.         buffer.put(1, m10);
  29.         buffer.put(2, m20);
  30.         buffer.put(3, m30);
  31.  
  32.         buffer.put(4, m01);
  33.         buffer.put(5, m11);
  34.         buffer.put(6, m21);
  35.         buffer.put(7, m31);
  36.  
  37.         buffer.put(8, m02);
  38.         buffer.put(9, m12);
  39.         buffer.put(10, m22);
  40.         buffer.put(11, m32);
  41.  
  42.         buffer.put(12, m03);
  43.         buffer.put(13, m13);
  44.         buffer.put(14, m23);
  45.         buffer.put(15, m33);
  46. }
clone this paste RAW Paste Data