瀏覽代碼

minor changes

ncannasse 8 年之前
父節點
當前提交
1e7e373018
共有 3 個文件被更改,包括 31 次插入3 次删除
  1. 5 1
      h3d/prim/ModelCache.hx
  2. 22 0
      h3d/scene/Scene.hx
  3. 4 2
      h3d/shader/UVDelta.hx

+ 5 - 1
h3d/prim/ModelCache.hx

@@ -87,9 +87,13 @@ class ModelCache {
 		var a = anims.get(path);
 		if( a != null )
 			return a;
-		a = loadLibrary(anim).loadAnimation(name);
+		a = initAnimation(anim,name);
 		anims.set(path, a);
 		return a;
 	}
 
+	function initAnimation( anim : hxd.res.Model, name : String ) {
+		return loadLibrary(anim).loadAnimation(name);
+	}
+
 }

+ 22 - 0
h3d/scene/Scene.hx

@@ -257,6 +257,28 @@ class Scene extends Object implements h3d.IDrawable implements hxd.SceneEvents.I
 		return found;
 	}
 
+	/**
+		Only sync without rendering
+	**/
+	public function syncOnly( et : Float ) {
+		var engine = h3d.Engine.getCurrent();
+		setElapsedTime(et);
+		var t = engine.getCurrentTarget();
+		if( t == null )
+			camera.screenRatio = engine.width / engine.height;
+		else
+			camera.screenRatio = t.width / t.height;
+		camera.update();
+		ctx.camera = camera;
+		ctx.engine = engine;
+		ctx.scene = this;
+		ctx.start();
+		syncRec(ctx);
+		ctx.camera = null;
+		ctx.engine = null;
+		ctx.scene = null;
+	}
+
 	@:access(h3d.mat.Pass)
 	@:access(h3d.scene.RenderContext)
 	public function render( engine : h3d.Engine ) {

+ 4 - 2
h3d/shader/UVDelta.hx

@@ -4,15 +4,17 @@ class UVDelta extends hxsl.Shader {
 
 	static var SRC = {
 		@param var uvDelta : Vec2;
+		@param var uvScale : Vec2;
 		var calculatedUV : Vec2;
 		function vertex() {
-			calculatedUV += uvDelta;
+			calculatedUV = calculatedUV * uvScale + uvDelta;
 		}
 	};
 
-	public function new( dx = 0., dy = 0. ) {
+	public function new( dx = 0., dy = 0., sx = 1., sy = 1. ) {
 		super();
 		uvDelta.set(dx, dy);
+		uvScale.set(sx, sy);
 	}
 
 }