From ab35091cafbed3657a92bbcdf90085abae6853b9 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Fri, 25 Jun 2010 00:24:06 +0000 Subject: [PATCH] PShape3D (optionally) uses fill/tint/noTint settings now, instead of per-vertex colouring only. --- .../core/src/processing/core/PShape3D.java | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/android/core/src/processing/core/PShape3D.java b/android/core/src/processing/core/PShape3D.java index 7a334a171..d388876b7 100644 --- a/android/core/src/processing/core/PShape3D.java +++ b/android/core/src/processing/core/PShape3D.java @@ -87,6 +87,7 @@ public class PShape3D extends PShape implements PConstants { protected float ptDistAtt[] = { 1.0f, 0.0f, 0.01f, 1.0f }; protected boolean texCoordSet = false; + protected boolean vertexColor = true; // TODO: consider implementing simple depth sorting for particle systems, // and a more intutive way to implement the api for enabling/disabling depth masking. @@ -612,6 +613,11 @@ public class PShape3D extends PShape implements PConstants { } } + + public void vertexColor(boolean v) { + vertexColor = v; + } + //////////////////////////////////////////////////////////// @@ -1880,12 +1886,14 @@ public class PShape3D extends PShape implements PConstants { gl.glEnableClientState(GL11.GL_NORMAL_ARRAY); gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, glNormalBufferID[0]); gl.glNormalPointer(GL11.GL_FLOAT, 0, 0); + + if (vertexColor) { + // TODO: properly handle emissive and specular colors (really?)... + gl.glEnableClientState(GL11.GL_COLOR_ARRAY); + gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, glColorBufferID[0]); + gl.glColorPointer(4, GL11.GL_FLOAT, 0, 0); + } - // TODO: properly handle emissive and specular colors... - gl.glEnableClientState(GL11.GL_COLOR_ARRAY); - gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, glColorBufferID[0]); - gl.glColorPointer(4, GL11.GL_FLOAT, 0, 0); - gl.glEnableClientState(GL11.GL_VERTEX_ARRAY); gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, glVertexBufferID[0]); gl.glVertexPointer(3, GL11.GL_FLOAT, 0, 0); @@ -1935,6 +1943,18 @@ public class PShape3D extends PShape implements PConstants { } } + if (!vertexColor) { + if (tex == null) { + gl.glColor4f(g.fillR, g.fillG, g.fillB, g.fillA); + }else { + if (g.tint) { + gl.glColor4f(g.tintR, g.tintG, g.tintB, g.tintA); + } else { + gl.glColor4f(1, 1, 1, 1); + } + } + } + // Last transformation: inversion of coordinate to make compatible with Processing's inverted Y axis. gl.glPushMatrix(); gl.glScalef(1, -1, 1);