Nicolas Cannasse 13 yıl önce
ebeveyn
işleme
7fd2b804d2
4 değiştirilmiş dosya ile 37 ekleme ve 4 silme
  1. 2 0
      .gitignore
  2. 30 0
      README.md
  3. 4 2
      h3d/prim/Polygon.hx
  4. 1 2
      samples/Test.hx

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+
+/engine.swf

+ 30 - 0
README.md

@@ -0,0 +1,30 @@
+Haxe 3D Engine
+=========
+
+A lightweight 3D Engine for Haxe.
+
+Currently only supports Flash/Stage3D, but is abstracted to support other backends in the near future.
+
+In order to setup the engine, you can do :
+
+> var engine = new h3d.Engine();
+> engine.onReady = startMyApp;
+> engine.init();
+
+Then in your render loop you can do :
+
+> engine.begin();
+> ... render objects ...
+> engine.end()
+
+Objects can be created using a combination of a `h3d.mat.Material` (shader and blendmode) and `h3d.prim.Primitive` (geometry).
+
+You can look at available examples in `samples` directory.
+
+2D GPU Engine
+-------------
+
+The `h2d` package contains classes that provides a complete 2D API that is built on top of `h3d`, and is then GPU accelerated.
+
+It contains an object hierarchy which base class is `h2d.Sprite` and root is `h2d.Scene`
+

+ 4 - 2
h3d/prim/Polygon.hx

@@ -6,7 +6,7 @@ class Polygon extends Primitive {
 	public var normals : Array<Point>;
 	public var tangents : Array<Point>;
 	public var tcoords : Array<UV>;
-	public var idx : Array<UInt>;
+	public var idx : Array<Int>;
 		
 	public function new( points, ?idx ) {
 		this.points = points;
@@ -49,8 +49,10 @@ class Polygon extends Primitive {
 		}
 		buffer = engine.mem.allocVector(buf, size, idx == null ? 3 : 0);
 		
-		if( idx != null )
+		if( idx != null ) {
+			var idx : Array<UInt> = cast idx;
 			indexes = engine.mem.allocIndex(flash.Vector.ofArray(idx));
+		}
 	}
 
 

+ 1 - 2
samples/Test.hx

@@ -45,8 +45,7 @@ class Test {
 		obj = new h3d.Object(prim, new h3d.mat.Material(rgb));
 		var bmp = new flash.display.BitmapData(256, 256);
 		bmp.perlinNoise(64, 64, 3, 0, true, true, 7);
-		rgb.tex = e.mem.allocTexture(bmp.width, bmp.height);
-		rgb.tex.uploadMipMap(bmp);
+		rgb.tex = e.mem.makeTexture(bmp);
 		bmp.dispose();
 	}