From 73a8a43ef74f3b68252db11a959a8824e63a08fc Mon Sep 17 00:00:00 2001 From: codeanticode Date: Mon, 27 Sep 2010 08:13:30 +0000 Subject: [PATCH] Added setColor method in PShape3D to color all the vertices at once --- .../core/src/processing/core/PShape3D.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/android/core/src/processing/core/PShape3D.java b/android/core/src/processing/core/PShape3D.java index 67693d2d3..6d613f90f 100644 --- a/android/core/src/processing/core/PShape3D.java +++ b/android/core/src/processing/core/PShape3D.java @@ -558,6 +558,33 @@ public class PShape3D extends PShape implements PConstants { return res; } + + + public void setColor(int c) { + int a = (c >> 24) & 0xFF; + int r = (c >> 16) & 0xFF; + int g = (c >> 8) & 0xFF; + int b = (c >> 0) & 0xFF; + + setColor(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f); + } + + + public void setColor(float r, float g, float b) { + setColor(r, g, b, 1.0f); + } + + + public void setColor(float r, float g, float b, float a) { + firstUpdateIdx = 0; + lastUpdateIdx = numVertices - 1; + for (int i = 0; i < numVertices; i++) { + colorArray[4 * i + 0] = r; + colorArray[4 * i + 1] = g; + colorArray[4 * i + 2] = b; + colorArray[4 * i + 3] = a; + } + } public void setColor(int idx, int c) {