Bladeren bron

added Matrix.getDirection and Camera.setTransform

Nicolas Cannasse 4 jaren geleden
bovenliggende
commit
4e6211ed05
2 gewijzigde bestanden met toevoegingen van 12 en 0 verwijderingen
  1. 5 0
      h3d/Camera.hx
  2. 7 0
      h3d/Matrix.hx

+ 5 - 0
h3d/Camera.hx

@@ -288,6 +288,11 @@ class Camera {
 		m._44 = 1;
 		m._44 = 1;
 	}
 	}
 
 
+	public function setTransform( m : Matrix ) {
+		pos.set(m._41, m._42, m._43);
+		target.load(pos.add(m.getDirection()));
+	}
+
 	function makeFrustumMatrix( m : Matrix ) {
 	function makeFrustumMatrix( m : Matrix ) {
 		m.zero();
 		m.zero();
 
 

+ 7 - 0
h3d/Matrix.hx

@@ -549,6 +549,13 @@ class Matrix {
 		return [_11, _12, _13, _14, _21, _22, _23, _24, _31, _32, _33, _34, _41, _42, _43, _44];
 		return [_11, _12, _13, _14, _21, _22, _23, _24, _31, _32, _33, _34, _41, _42, _43, _44];
 	}
 	}
 
 
+	public function getDirection() {
+		var q = new h3d.Quat();
+		q.initRotateMatrix(this);
+		q.normalize();
+		return q.getDirection();
+	}
+
 	/**
 	/**
 		Extracts Euler rotation angles from rotation matrix
 		Extracts Euler rotation angles from rotation matrix
 	**/
 	**/