Last active
November 23, 2019 14:01
-
-
Save companje/2b8d95e6f4261afe8a1d5eb28134c9cd to your computer and use it in GitHub Desktop.
Tip: distortion when drawing markers on a sphere
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
When you want to draw markers on a sphere keep in mind that 3D markers (like spheres and boxes) are distorted because you see their top as well as their sides instead of just their top. | |
*/ | |
perspective(atan(r/distToCam)*2, wdh, distToCam, 10000); //fov=35deg //atan(hd2/distToCam)*2 | |
camera(0, 0, -distToCam, 0, 0, 0, 0, 1, 0); | |
scale(-1, 1, 1); | |
background(0); | |
pushMatrix(); | |
rotateX(HALF_PI); | |
noFill(); | |
stroke(128); | |
hint(ENABLE_DEPTH_TEST); | |
sphere(r * globeScaler); | |
hint(DISABLE_DEPTH_TEST); | |
popMatrix(); | |
fill(255); //, 0, 0); | |
noStroke(); | |
for (float a=-HALF_PI; a<=HALF_PI; a+=PI/30) { | |
pushMatrix(); | |
rotateY(a); | |
translate(0, 0, r * globeScaler); | |
ellipse(0,0,40,40); | |
popMatrix(); | |
pushMatrix(); | |
rotateX(a); | |
translate(0, 0, r * globeScaler); | |
ellipse(0,0,40,40); | |
popMatrix(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
unwanted:
desired: