Преглед на файлове

added function to compute normal transformation matrix

Max Limper преди 7 години
родител
ревизия
8ddb07f614
променени са 1 файла, в които са добавени 18 реда и са изтрити 0 реда
  1. 18 0
      src/Math/babylon.math.ts

+ 18 - 0
src/Math/babylon.math.ts

@@ -3352,6 +3352,23 @@
 
             return true;
         }
+
+        /**
+         * Returns a new Matrix which is the normal matrix computed from the current one (using values from identity matrix for fourth row and column).  
+         */
+        public toNormalMatrix(): Matrix {
+            var result = Matrix.Identity();
+            this.invertToRef(result)
+            result.transpose();
+            var m = result.m;
+            Matrix.FromValuesToRef(
+                m[0], m[1], m[2],  0,
+                m[4], m[5], m[6],  0,
+                m[8], m[9], m[10], 0,
+                0,    0,    0,     1, result);
+            return result;
+        }
+
         /**
          * Returns a new Matrix as the extracted rotation matrix from the current one.  
          */
@@ -3360,6 +3377,7 @@
             this.getRotationMatrixToRef(result);
             return result;
         }
+       
         /**
          * Extracts the rotation matrix from the current one and sets it as the passed "result".  
          * Returns the current Matrix.