Browse Source

added color mult

ncannasse 11 years ago
parent
commit
fffee1e0f3
1 changed files with 24 additions and 2 deletions
  1. 24 2
      h3d/prim/BigPrimitive.hx

+ 24 - 2
h3d/prim/BigPrimitive.hx

@@ -106,7 +106,7 @@ class BigPrimitive extends Primitive {
 	}
 	}
 
 
 	@:noDebug
 	@:noDebug
-	public function addSub( buf : hxd.FloatBuffer, idx : hxd.IndexBuffer, startVert, startTri, nvert, triCount, dx : Float = 0. , dy : Float = 0., dz : Float = 0., rotation = 0., scale = 1., stride = -1, deltaU = 0., deltaV = 0. ) {
+	public function addSub( buf : hxd.FloatBuffer, idx : hxd.IndexBuffer, startVert, startTri, nvert, triCount, dx : Float = 0. , dy : Float = 0., dz : Float = 0., rotation = 0., scale = 1., stride = -1, deltaU = 0., deltaV = 0., color = 1. ) {
 		if( tmpBuf == null ) {
 		if( tmpBuf == null ) {
 			tmpBuf = new hxd.FloatBuffer();
 			tmpBuf = new hxd.FloatBuffer();
 			tmpIdx = new hxd.IndexBuffer();
 			tmpIdx = new hxd.IndexBuffer();
@@ -167,7 +167,7 @@ class BigPrimitive extends Primitive {
 				tmpBuf.push(tny);
 				tmpBuf.push(tny);
 				tmpBuf.push(nz);
 				tmpBuf.push(nz);
 				tmpBuf.push(buf[p++]);
 				tmpBuf.push(buf[p++]);
-			default:
+			case 8, 9, 10:
 				var nx = buf[p++];
 				var nx = buf[p++];
 				var ny = buf[p++];
 				var ny = buf[p++];
 				var nz = buf[p++];
 				var nz = buf[p++];
@@ -183,6 +183,28 @@ class BigPrimitive extends Primitive {
 
 
 				for( i in 8...this.stride )
 				for( i in 8...this.stride )
 					tmpBuf.push(buf[p++]);
 					tmpBuf.push(buf[p++]);
+
+			default:
+				var nx = buf[p++];
+				var ny = buf[p++];
+				var nz = buf[p++];
+				var tnx = nx * cr - ny * sr;
+				var tny = nx * sr + ny * cr;
+				tmpBuf.push(tnx);
+				tmpBuf.push(tny);
+				tmpBuf.push(nz);
+
+				// UV
+				tmpBuf.push(buf[p++] + deltaU);
+				tmpBuf.push(buf[p++] + deltaV);
+
+				// COLOR
+				tmpBuf.push(buf[p++] * color);
+				tmpBuf.push(buf[p++] * color);
+				tmpBuf.push(buf[p++] * color);
+
+				for( i in 11...this.stride )
+					tmpBuf.push(buf[p++]);
 			}
 			}
 		}
 		}
 		start -= startVert;
 		start -= startVert;