mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 21:59:20 +01:00
PShape3D (optionally) uses fill/tint/noTint settings now, instead of per-vertex colouring only.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user