|
@@ -2,7 +2,13 @@ package h3d.prim;
|
|
|
|
|
|
class Grid extends Polygon {
|
|
|
|
|
|
+ var width : Int;
|
|
|
+ var height : Int;
|
|
|
+
|
|
|
public function new( width : Int, height : Int, cellWidth = 1., cellHeight = 1. ) {
|
|
|
+ this.width = width;
|
|
|
+ this.height = height;
|
|
|
+
|
|
|
var idx = new hxd.IndexBuffer();
|
|
|
for( y in 0...height )
|
|
|
for( x in 0...width ) {
|
|
@@ -20,4 +26,20 @@ class Grid extends Polygon {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ override function addUVs() {
|
|
|
+ unindex();
|
|
|
+ uvs = [];
|
|
|
+ for( y in 0...height ) {
|
|
|
+ for( x in 0...width ) {
|
|
|
+ uvs.push(new UV(x/width, y/height));
|
|
|
+ uvs.push(new UV((x+1)/width, y/height));
|
|
|
+ uvs.push(new UV(x/width, (y+1)/height));
|
|
|
+
|
|
|
+ uvs.push(new UV((x+1)/width, y/height));
|
|
|
+ uvs.push(new UV((x+1)/width, (y+1)/height));
|
|
|
+ uvs.push(new UV(x/width, (y+1)/height));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|