Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PShader depthOfFieldShader;
- PImage texture;
- PImage starsTexture;
- PImage overlay;
- PShape globe;
- PShape starsGlobe;
- float distance = 900;
- Line[] lines = new Line[1000];
- void setup() {
- size(1920, 1080, P3D);
- smooth(4);
- //pixelDensity(2);
- //depthOfFieldShader = loadShader("depthOfFieldShader.glsl");
- texture = loadImage("globe.png");
- globe = createShape(SPHERE, 300);
- //globe.setFill(color(255, 255, 255, 220));
- globe.setTexture(texture);
- //globe.setTint(color(255, 255, 255, 10));
- globe.setStroke(false);
- //starsTexture = loadImage("starsTexture.png");
- starsGlobe = createShape(SPHERE, 3000);
- starsGlobe.setFill(false);
- starsGlobe.setTexture(starsTexture);
- starsGlobe.setStroke(color(210, 29, 105, 10));
- overlay = loadImage("0 Initial Globe.png");
- createSomeLines();
- }
- void draw() {
- background(255);
- fill(255);
- // draw anything 3d
- //camera(frameCount, mouseY/2, (height/2) / tan(PI/6), width/2, height/2, 0, 0, 1, 0);
- float x = cos(0.001 * frameCount) * distance;
- float y = (-distance / 2) + mouseY / 2;
- float z = sin(0.001 * frameCount) * distance;
- translate(width/2, height/2, -100);
- camera(x,y,z, 0,0,0, 0,1,0);
- //lights();
- //spotLight(255, 255, 255, width/2, height/2, 400, 0, 0, -1, PI/4, 2);
- //hint(DISABLE_DEPTH_TEST);
- shape(globe);
- shape(starsGlobe);
- //drawDebugLines();
- drawLines();
- // draw anything 2d
- camera();
- fill(150);
- //text(round(frameRate), 10, 15);
- image(overlay, 0, 0, width, height);
- //println(frameCount);
- //String pngName = String.format("_export/outer-sphere-%04d.png", frameCount);
- //save(pngName);
- }
- void mouseClicked() {
- createSomeLines();
- }
- void createSomeLines() {
- for (int i = 0; i < lines.length; i++) {
- Line line = new Line(random(600) - 300, random(600) - 300, random(600) - 300);
- lines[i] = line;
- }
- }
- void drawLines() {
- strokeWeight(1);
- for (int i = 0; i < lines.length; i++) {
- stroke(lines[i].strokeColor);
- line(0, 0, 0, lines[i].x, lines[i].y, lines[i].z);
- }
- }
- void drawDebugLines() {
- strokeWeight(1);
- stroke(255, 0, 0);
- line(0, 0, 0, 600, 0, 0);
- stroke(0, 255, 0);
- line(0, 0, 0, 0, 600, 0);
- stroke(0, 0, 255);
- line(0, 0, 0, 0, 0, 600);
- noStroke();
- }
- class Line {
- float x;
- float y;
- float z;
- color strokeColor;
- Line(float _x, float _y, float _z) {
- x = _x;
- y = _y;
- z = _z;
- int colorChoice = round(random(3));
- if (colorChoice > 0) {
- strokeColor = color(0, 155, 220);
- } else {
- strokeColor = color(210, 29, 105);
- }
- }
- }
Add Comment
Please, Sign In to add comment