mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
minor edits
This commit is contained in:
@@ -1894,7 +1894,7 @@ public class PGraphics extends PImage implements PConstants {
|
||||
// step along Y axis
|
||||
for (int i = 1; i < vres; i++) {
|
||||
float curradius = sinLUT[(int) angle % SINCOS_LENGTH];
|
||||
float currY = -cosLUT[(int) angle % SINCOS_LENGTH];
|
||||
float currY = cosLUT[(int) angle % SINCOS_LENGTH];
|
||||
for (int j = 0; j < ures; j++) {
|
||||
sphereX[currVert] = cx[j] * curradius;
|
||||
sphereY[currVert] = currY;
|
||||
@@ -1934,80 +1934,8 @@ public class PGraphics extends PImage implements PConstants {
|
||||
sphereDetail(30);
|
||||
}
|
||||
|
||||
edge(false);
|
||||
edge(false);
|
||||
|
||||
|
||||
float startLat = -90;
|
||||
float startLon = 0.0f;
|
||||
|
||||
float latInc = 180.0f / sphereDetailU;
|
||||
float lonInc = 360.0f / sphereDetailV;
|
||||
|
||||
float phi1, phi2;
|
||||
float theta1, theta2;
|
||||
float x0, y0, z0;
|
||||
float x1, y1, z1;
|
||||
float x2, y2, z2;
|
||||
float x3, y3, z3;
|
||||
float u1, v1, u2, v2, v3;
|
||||
|
||||
beginShape(TRIANGLES);
|
||||
|
||||
for (int col = 0; col < sphereDetailU; col++) {
|
||||
phi1 = (startLon + col * lonInc) * DEG_TO_RAD;
|
||||
phi2 = (startLon + (col + 1) * lonInc) * DEG_TO_RAD;
|
||||
for (int row = 0; row < sphereDetailV; row++) {
|
||||
theta1 = (startLat + row * latInc) * DEG_TO_RAD;
|
||||
theta2 = (startLat + (row + 1) * latInc) * DEG_TO_RAD;
|
||||
|
||||
x0 = PApplet.cos(phi1) * PApplet.cos(theta1);
|
||||
y0 = PApplet.sin(theta1);
|
||||
z0 = PApplet.sin(phi1) * PApplet.cos(theta1);
|
||||
|
||||
x1 = PApplet.cos(phi1) * PApplet.cos(theta2);
|
||||
y1 = PApplet.sin(theta2);
|
||||
z1 = PApplet.sin(phi1) * PApplet.cos(theta2);
|
||||
|
||||
x2 = PApplet.cos(phi2) * PApplet.cos(theta2);
|
||||
y2 = PApplet.sin(theta2);
|
||||
z2 = PApplet.sin(phi2) * PApplet.cos(theta2);
|
||||
|
||||
x3 = PApplet.cos(phi2) * PApplet.cos(theta1);
|
||||
y3 = PApplet.sin(theta1);
|
||||
z3 = PApplet.sin(phi2) * PApplet.cos(theta1);
|
||||
|
||||
u1 = PApplet.map(phi1, TWO_PI, 0, 0, 1);
|
||||
u2 = PApplet.map(phi2, TWO_PI, 0, 0, 1);
|
||||
v1 = PApplet.map(theta1, -HALF_PI, HALF_PI, 0, 1);
|
||||
v2 = PApplet.map(theta2, -HALF_PI, HALF_PI, 0, 1);
|
||||
v3 = PApplet.map(theta1, -HALF_PI, HALF_PI, 0, 1);
|
||||
|
||||
normal(x0, y0, z0);
|
||||
vertex(r * x0, r * y0, r * z0, u1, v1);
|
||||
|
||||
normal(x2, y2, z2);
|
||||
vertex(r * x2, r * y2, r * z2, u2, v2);
|
||||
|
||||
normal(x1, y1, z1);
|
||||
vertex(r * x1, r * y1, r * z1, u1, v2);
|
||||
|
||||
|
||||
|
||||
normal(x0, y0, z0);
|
||||
vertex(r * x0, r * y0, r * z0, u1, v1);
|
||||
|
||||
normal(x3, y3, z3);
|
||||
vertex(r * x3, r * y3, r * z3, u2, v3);
|
||||
|
||||
normal(x2, y2, z2);
|
||||
vertex(r * x2, r * y2, r * z2, u2, v2);
|
||||
}
|
||||
}
|
||||
|
||||
endShape();
|
||||
|
||||
|
||||
/*
|
||||
// 1st ring from south pole
|
||||
beginShape(TRIANGLE_STRIP);
|
||||
for (int i = 0; i < sphereDetailU; i++) {
|
||||
@@ -2061,7 +1989,6 @@ public class PGraphics extends PImage implements PConstants {
|
||||
normal(0, 1, 0);
|
||||
vertex(0, r, 0);
|
||||
endShape();
|
||||
*/
|
||||
|
||||
edge(true);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.nio.*;
|
||||
import java.util.*;
|
||||
|
||||
import processing.core.*;
|
||||
import processing.opengl.PGraphicsOpenGL.Tessellator.TessellatorCallback;
|
||||
|
||||
|
||||
// drawPixels is missing...calls to glDrawPixels are commented out
|
||||
|
||||
@@ -2462,106 +2462,16 @@ public class PGraphics extends PImage implements PConstants {
|
||||
edge(false);
|
||||
|
||||
|
||||
float startLat = -90;
|
||||
float startLon = 0.0f;
|
||||
|
||||
float latInc = 180.0f / sphereDetailU;
|
||||
float lonInc = 360.0f / sphereDetailV;
|
||||
|
||||
float phi1, phi2;
|
||||
float theta1, theta2;
|
||||
float x0, y0, z0;
|
||||
float x1, y1, z1;
|
||||
float x2, y2, z2;
|
||||
float x3, y3, z3;
|
||||
float u1, v1, u2, v2, v3;
|
||||
|
||||
beginShape(TRIANGLES);
|
||||
|
||||
for (int col = 0; col < sphereDetailU; col++) {
|
||||
phi1 = (startLon + col * lonInc) * DEG_TO_RAD;
|
||||
phi2 = (startLon + (col + 1) * lonInc) * DEG_TO_RAD;
|
||||
for (int row = 0; row < sphereDetailV; row++) {
|
||||
theta1 = (startLat + row * latInc) * DEG_TO_RAD;
|
||||
theta2 = (startLat + (row + 1) * latInc) * DEG_TO_RAD;
|
||||
|
||||
x0 = PApplet.cos(phi1) * PApplet.cos(theta1);
|
||||
y0 = PApplet.sin(theta1);
|
||||
z0 = PApplet.sin(phi1) * PApplet.cos(theta1);
|
||||
|
||||
x1 = PApplet.cos(phi1) * PApplet.cos(theta2);
|
||||
y1 = PApplet.sin(theta2);
|
||||
z1 = PApplet.sin(phi1) * PApplet.cos(theta2);
|
||||
|
||||
x2 = PApplet.cos(phi2) * PApplet.cos(theta2);
|
||||
y2 = PApplet.sin(theta2);
|
||||
z2 = PApplet.sin(phi2) * PApplet.cos(theta2);
|
||||
|
||||
x3 = PApplet.cos(phi2) * PApplet.cos(theta1);
|
||||
y3 = PApplet.sin(theta1);
|
||||
z3 = PApplet.sin(phi2) * PApplet.cos(theta1);
|
||||
|
||||
u1 = PApplet.map(phi1, TWO_PI, 0, 0, 1);
|
||||
u2 = PApplet.map(phi2, TWO_PI, 0, 0, 1);
|
||||
v1 = PApplet.map(theta1, -HALF_PI, HALF_PI, 0, 1);
|
||||
v2 = PApplet.map(theta2, -HALF_PI, HALF_PI, 0, 1);
|
||||
v3 = PApplet.map(theta1, -HALF_PI, HALF_PI, 0, 1);
|
||||
|
||||
if (textureImage != null) {
|
||||
normal(x0, y0, z0);
|
||||
vertex(r * x0, r * y0, r * z0, u1, v1);
|
||||
|
||||
normal(x2, y2, z2);
|
||||
vertex(r * x2, r * y2, r * z2, u2, v2);
|
||||
|
||||
normal(x1, y1, z1);
|
||||
vertex(r * x1, r * y1, r * z1, u1, v2);
|
||||
|
||||
normal(x0, y0, z0);
|
||||
vertex(r * x0, r * y0, r * z0, u1, v1);
|
||||
|
||||
normal(x3, y3, z3);
|
||||
vertex(r * x3, r * y3, r * z3, u2, v3);
|
||||
|
||||
normal(x2, y2, z2);
|
||||
vertex(r * x2, r * y2, r * z2, u2, v2);
|
||||
|
||||
} else {
|
||||
normal(x0, y0, z0);
|
||||
vertex(r * x0, r * y0, r * z0);
|
||||
|
||||
normal(x2, y2, z2);
|
||||
vertex(r * x2, r * y2, r * z2);
|
||||
|
||||
normal(x1, y1, z1);
|
||||
vertex(r * x1, r * y1, r * z1);
|
||||
|
||||
normal(x0, y0, z0);
|
||||
vertex(r * x0, r * y0, r * z0);
|
||||
|
||||
normal(x3, y3, z3);
|
||||
vertex(r * x3, r * y3, r * z3);
|
||||
|
||||
normal(x2, y2, z2);
|
||||
vertex(r * x2, r * y2, r * z2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endShape();
|
||||
|
||||
|
||||
/*
|
||||
// 1st ring from south pole
|
||||
beginShape(TRIANGLE_STRIP);
|
||||
for (int i = 0; i < sphereDetailU; i++) {
|
||||
normal(0, -1, 0);
|
||||
vertex(0, -r, 0);
|
||||
normal(sphereX[i], sphereY[i], sphereZ[i]);
|
||||
vertex(r * sphereX[i], r *sphereY[i], r * sphereZ[i]);
|
||||
vertex(r * sphereX[i], r * sphereY[i], r * sphereZ[i]);
|
||||
}
|
||||
normal(0, -1, 0);
|
||||
vertex(0, -1, 0);
|
||||
normal(0, -r, 0);
|
||||
vertex(0, -r, 0);
|
||||
normal(sphereX[0], sphereY[0], sphereZ[0]);
|
||||
vertex(r * sphereX[0], r * sphereY[0], r * sphereZ[0]);
|
||||
endShape();
|
||||
@@ -2585,7 +2495,7 @@ public class PGraphics extends PImage implements PConstants {
|
||||
v1 = v11;
|
||||
v2 = voff;
|
||||
normal(sphereX[v1], sphereY[v1], sphereZ[v1]);
|
||||
vertex(r * sphereX[v1], r * sphereY[v1], sphereZ[v1]);
|
||||
vertex(r * sphereX[v1], r * sphereY[v1], r * sphereZ[v1]);
|
||||
normal(sphereX[v2], sphereY[v2], sphereZ[v2]);
|
||||
vertex(r * sphereX[v2], r * sphereY[v2], r * sphereZ[v2]);
|
||||
endShape();
|
||||
@@ -2605,8 +2515,7 @@ public class PGraphics extends PImage implements PConstants {
|
||||
normal(0, 1, 0);
|
||||
vertex(0, r, 0);
|
||||
endShape();
|
||||
*/
|
||||
|
||||
|
||||
edge(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1148,6 +1148,7 @@ public class PShape implements PConstants {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: finish implementing partial updates in PShape3D
|
||||
protected void modified(int i0, int i1) {
|
||||
modified = true;
|
||||
@@ -1158,6 +1159,7 @@ public class PShape implements PConstants {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void notModified() {
|
||||
modified = false;
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
|
||||
@@ -1273,25 +1273,6 @@ public class PGL {
|
||||
}
|
||||
|
||||
|
||||
static public short makeIndex(int intIdx) {
|
||||
// The old hack to have unsigned shorts as indices using Java's
|
||||
// signed shorts:
|
||||
// When the index value is greater than 32767, subtracting 65536
|
||||
// will make it (as a short) to wrap around to the negative range, which
|
||||
// is all we need to later pass these numbers to opengl (which will
|
||||
// interpret them as unsigned shorts). See discussion here:
|
||||
// http://stackoverflow.com/questions/4331021/java-opengl-gldrawelements-with-32767-vertices
|
||||
//return 32767 < intIdx ? (short)(intIdx - 65536) : (short)intIdx;
|
||||
if (32767 < intIdx) {
|
||||
PGraphics.showWarning("P3D: More than 32767 vertices in a single shape, not all will be drawn.\n" +
|
||||
"Consider splitting your large shape into multiple smaller shapes.");
|
||||
return 32767;
|
||||
} else {
|
||||
return (short)intIdx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void enableTexturing(int target) {
|
||||
glEnable(target);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user