浏览代码

added Object.getRelPos()

Nicolas Cannasse 4 年之前
父节点
当前提交
4e9d404861
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      h3d/scene/Object.hx

+ 12 - 0
h3d/scene/Object.hx

@@ -552,6 +552,18 @@ class Object implements hxd.impl.Serializable {
 		return absPos;
 	}
 
+	/**
+		Returns the position matrix relative to another scene object
+	**/
+	public function getRelPos( obj : Object ) {
+		if( obj == null )
+			return getAbsPos();
+		syncPos();
+		var m = new h3d.Matrix();
+		m.multiply(absPos, obj.getInvPos());
+		return m;
+	}
+
 	/**
 		Tell if the object is a Mesh.
 	**/