sets the ambient color in PShapeOpenGL when setting fill for the first time, fixes issue 1342

This commit is contained in:
codeanticode
2012-11-21 01:21:18 +00:00
parent 7637b7bcd1
commit 65f8e12c97
8 changed files with 40 additions and 12 deletions
@@ -419,7 +419,7 @@ public class PGraphics extends PImage implements PConstants {
public int ambientColor;
public float ambientR, ambientG, ambientB;
protected boolean setAmbient;
public boolean setAmbient;
public int specularColor;
public float specularR, specularG, specularB;
@@ -144,6 +144,7 @@ public class PShape implements PConstants {
protected int tintColor;
protected int ambientColor;
protected boolean setAmbient;
protected int specularColor;
protected int emissiveColor;
protected float shininess;
@@ -4734,6 +4734,8 @@ public class PGraphicsOpenGL extends PGraphics {
// default ambient color when the user doesn't specify
// it explicitly.
ambientFromCalc();
// ambientFromCalc sets setAmbient to true, but it hasn't been
// set by the user so put back to false.
setAmbient = false;
}
}
@@ -339,6 +339,7 @@ public class PShapeOpenGL extends PShape {
tint = pg.tint;
tintColor = pg.tintColor;
setAmbient = pg.setAmbient;
ambientColor = pg.ambientColor;
specularColor = pg.specularColor;
emissiveColor = pg.emissiveColor;
@@ -1265,6 +1266,15 @@ public class PShapeOpenGL extends PShape {
protected void fillFromCalc() {
fill = true;
updateFillColor(calcColor);
if (!setAmbient) {
// Setting the ambient color from the current fill
// is what the old P3D did and allows to have an
// default ambient color when the user doesn't specify
// it explicitly.
ambientFromCalc();
setAmbient = false;
}
}
@@ -1636,6 +1646,7 @@ public class PShapeOpenGL extends PShape {
protected void ambientFromCalc() {
updateAmbientColor(calcColor);
setAmbient = true;
}
+1 -1
View File
@@ -445,7 +445,7 @@ public class PGraphics extends PImage implements PConstants {
public int ambientColor;
public float ambientR, ambientG, ambientB;
protected boolean setAmbient;
public boolean setAmbient;
public int specularColor;
public float specularR, specularG, specularB;
+11 -10
View File
@@ -146,6 +146,7 @@ public class PShape implements PConstants {
protected int tintColor;
protected int ambientColor;
protected boolean setAmbient;
protected int specularColor;
protected int emissiveColor;
protected float shininess;
@@ -475,14 +476,14 @@ public class PShape implements PConstants {
}
/**
* @webref pshape:method
* @webref pshape:method
* @brief Starts a new contour
*/
public void beginContour() {
}
/**
* @webref pshape:method
* @webref pshape:method
* @brief Ends a contour
*/
public void endContour() {
@@ -505,7 +506,7 @@ public class PShape implements PConstants {
/**
* @webref pshape:method
* @brief Finishes the creation of a new PShape
* @brief Finishes the creation of a new PShape
*/
public void end() {
}
@@ -1296,7 +1297,7 @@ public class PShape implements PConstants {
// can't be just 'add' because that suggests additive geometry
/**
* @webref pshape:method
* @brief Adds a new child
* @brief Adds a new child
*/
public void addChild(PShape who) {
if (children == null) {
@@ -1460,7 +1461,7 @@ public class PShape implements PConstants {
}
/**
* @webref pshape:method
* @webref pshape:method
* @brief Returns the total number of vertices as an int
*/
public int getVertexCount() {
@@ -1469,7 +1470,7 @@ public class PShape implements PConstants {
/**
* @webref pshape:method
* @webref pshape:method
* @brief Returns the vertex at the index position
* @param index the location of the vertex
*/
@@ -1506,7 +1507,7 @@ public class PShape implements PConstants {
}
/**
* @webref pshape:method
* @webref pshape:method
* @brief Sets the vertex at the index position
* @param index the location of the vertex
* @param x the x value for the vertex
@@ -1519,7 +1520,7 @@ public class PShape implements PConstants {
/**
* @param z the z value for the vertex
*/
*/
public void setVertex(int index, float x, float y, float z) {
vertices[index][X] = x;
vertices[index][Y] = y;
@@ -1528,7 +1529,7 @@ public class PShape implements PConstants {
/**
* @param vec the PVector to define the x, y, z coordinates
*/
*/
public void setVertex(int index, PVector vec) {
vertices[index][X] = vec.x;
vertices[index][Y] = vec.y;
@@ -4721,6 +4721,8 @@ public class PGraphicsOpenGL extends PGraphics {
// default ambient color when the user doesn't specify
// it explicitly.
ambientFromCalc();
// ambientFromCalc sets setAmbient to true, but it hasn't been
// set by the user so put back to false.
setAmbient = false;
}
}
@@ -339,6 +339,7 @@ public class PShapeOpenGL extends PShape {
tint = pg.tint;
tintColor = pg.tintColor;
setAmbient = pg.setAmbient;
ambientColor = pg.ambientColor;
specularColor = pg.specularColor;
emissiveColor = pg.emissiveColor;
@@ -1265,6 +1266,15 @@ public class PShapeOpenGL extends PShape {
protected void fillFromCalc() {
fill = true;
updateFillColor(calcColor);
if (!setAmbient) {
// Setting the ambient color from the current fill
// is what the old P3D did and allows to have an
// default ambient color when the user doesn't specify
// it explicitly.
ambientFromCalc();
setAmbient = false;
}
}
@@ -1636,6 +1646,7 @@ public class PShapeOpenGL extends PShape {
protected void ambientFromCalc() {
updateAmbientColor(calcColor);
setAmbient = true;
}