Skip to content

Commit 798e112

Browse files
committed
corrected normals in TexturedSphere example
1 parent 08be890 commit 798e112

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

content/examples/Topics/Textures/TextureSphere/TextureSphere.pde

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ void draw() {
5353
height/2/tan(PI*30.0 / 180.0),
5454
width, height/2.0, 0,
5555
0, 1, 0);
56-
56+
5757
pushMatrix();
58-
translate(width/2, height/2, 0);
58+
translate(width/2, height/2, 0);
5959
textureSphere(200, 200, 200, img);
6060
popMatrix();
6161
}
@@ -112,16 +112,15 @@ void textureSphere(float rx, float ry, float rz, PImage t) {
112112
float multxz=multXZ[i];
113113
float multxzPlus=multXZ[i+1];
114114

115-
for (int j=0; j<numPointsW; j++) { // For all the pts in the ring
116-
normal(coorX[j]*multxz, coory, coorZ[j]*multxz);
115+
for (int j=0; j<numPointsW; j++) { // For all the pts in the ring
116+
normal(-coorX[j]*multxz, -coory, -coorZ[j]*multxz);
117117
vertex(coorX[j]*multxz*rx, coory*ry, coorZ[j]*multxz*rz, u, v);
118-
normal(coorX[j]*multxzPlus, cooryPlus, coorZ[j]*multxzPlus);
118+
normal(-coorX[j]*multxzPlus, -cooryPlus, -coorZ[j]*multxzPlus);
119119
vertex(coorX[j]*multxzPlus*rx, cooryPlus*ry, coorZ[j]*multxzPlus*rz, u, v+changeV);
120120
u+=changeU;
121121
}
122122
v+=changeV;
123123
u=0;
124124
}
125125
endShape();
126-
}
127-
126+
}

0 commit comments

Comments
 (0)