processing.opengl.PGraphics3D Java Examples
The following examples show how to use
processing.opengl.PGraphics3D.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Skylight_Capture1.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D canvas){ if(canvas == skylight.renderer.pg_render){ canvas.background(16); displaySamples(canvas); } // ground plane float sx = bounds[3] - bounds[0]; float sy = bounds[4] - bounds[1]; float sz = bounds[5] - bounds[2]; canvas.pushMatrix(); canvas.translate(0, 0, 20 + sz/2); canvas.rotateX(-PI/2); canvas.shape(group_cubes); canvas.popMatrix(); canvas.noStroke(); canvas.fill(16,64,180); // canvas.fill(180,120,64); // canvas.box(sx*1.5f, sy*1.5f, 10); canvas.box(sx, sy, 10); }
Example #2
Source File: DwHalfEdge.java From PixelFlow with MIT License | 6 votes |
private void displayQuads(PGraphics3D pg, DwHalfEdge.Edge edge){ DwStack<DwHalfEdge.Edge> stack = new DwStack<DwHalfEdge.Edge>(); stack.push(edge); float[][] verts = ifs.getVerts(); float[] v; pg.beginShape(PConstants.QUADS); while(!stack.isEmpty()){ edge = stack.pop(); if(edge != null && getFLAG_display(edge)){ // draw quad v = verts[edge.vert.idx]; edge = edge.next; pg.vertex(v[0], v[1], v[2]); v = verts[edge.vert.idx]; edge = edge.next; pg.vertex(v[0], v[1], v[2]); v = verts[edge.vert.idx]; edge = edge.next; pg.vertex(v[0], v[1], v[2]); v = verts[edge.vert.idx]; edge = edge.next; pg.vertex(v[0], v[1], v[2]); // recursively draw neighbors stack.push((edge = edge.next).pair); setFLAG_display(edge); stack.push((edge = edge.next).pair); setFLAG_display(edge); stack.push((edge = edge.next).pair); setFLAG_display(edge); stack.push((edge = edge.next).pair); setFLAG_display(edge); } } pg.endShape(); }
Example #3
Source File: DwHalfEdge.java From PixelFlow with MIT License | 6 votes |
private void displayPolygons(PGraphics3D pg, DwHalfEdge.Edge edge){ DwStack<DwHalfEdge.Edge> stack = new DwStack<DwHalfEdge.Edge>(); stack.push(edge); float[][] verts = ifs.getVerts(); float[] v; while(!stack.isEmpty()){ edge = stack.pop(); if(edge != null && getFLAG_display(edge)){ DwHalfEdge.Edge iter = edge; pg.beginShape(); do { v = verts[iter.vert.idx]; pg.vertex(v[0], v[1], v[2]); } while((iter = iter.next) != edge); pg.endShape(PConstants.CLOSE); // recursively draw neighbors do { setFLAG_display(iter); stack.push(iter.pair); } while((iter = iter.next) != edge); } } }
Example #4
Source File: Skylight_BulletPhysics_TowerDemolition.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D pg){ if(pg == skylight.renderer.pg_render){ pg.background(16); } if(pg == geombuffer.pg_geom){ pg.background(255, 255); pg.pgl.clearColor(1, 1, 1, 6000); pg.pgl.clear(PGL.COLOR_BUFFER_BIT); } pg.pushMatrix(); pg.applyMatrix(mat_scene_view); pg.shape(group_bulletbodies); pg.popMatrix(); }
Example #5
Source File: BloomSphere.java From PixelFlow with MIT License | 6 votes |
public void setup() { background(0); if(!START_FULLSCREEN){ surface.setLocation(viewport_x, viewport_y); } cam = new PeasyCam(this, 600); createMesh(5); context = new DwPixelFlow(this); context.print(); context.printGL(); pg_dst = (PGraphics3D) createGraphics(width, height, P3D); pg_luminance = (PGraphics3D) createGraphics(width, height, P3D); randomSeed(1); frameRate(60); }
Example #6
Source File: DwHalfEdge.java From PixelFlow with MIT License | 6 votes |
private void displayTriangles(PGraphics3D pg, DwHalfEdge.Edge edge){ DwStack<DwHalfEdge.Edge> stack = new DwStack<DwHalfEdge.Edge>(); stack.push(edge); float[][] verts = ifs.getVerts(); float[] v; pg.beginShape(PConstants.TRIANGLES); while(!stack.isEmpty()){ edge = stack.pop(); if(edge != null && getFLAG_display(edge)){ // draw triangle v = verts[edge.vert.idx]; edge = edge.next; pg.vertex(v[0], v[1], v[2]); v = verts[edge.vert.idx]; edge = edge.next; pg.vertex(v[0], v[1], v[2]); v = verts[edge.vert.idx]; edge = edge.next; pg.vertex(v[0], v[1], v[2]); // recursively draw neighbors stack.push((edge = edge.next).pair); setFLAG_display(edge); stack.push((edge = edge.next).pair); setFLAG_display(edge); stack.push((edge = edge.next).pair); setFLAG_display(edge); } } pg.endShape(); }
Example #7
Source File: Skylight_BulletPhysics_Basic.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D pg){ if(pg == skylight.renderer.pg_render){ pg.background(16); } if(pg == geombuffer.pg_geom){ pg.background(255, 255); pg.pgl.clearColor(1, 1, 1, 6000); pg.pgl.clear(PGL.COLOR_BUFFER_BIT); } pg.pushMatrix(); pg.applyMatrix(mat_scene_view); pg.shape(group_bulletbodies); pg.popMatrix(); }
Example #8
Source File: Softbody3D_ParticleCollisionSystem.java From PixelFlow with MIT License | 6 votes |
public void updateMouseInteractions(){ // update transformation stuff transform.useCurrentTransformationMatrix((PGraphics3D) this.g); if(!MOVE_PARTICLE){ findNearestParticle(mouseX, mouseY, SNAP_RADIUS); SNAP_PARTICLE = pnearest != null; } if(SNAP_PARTICLE){ mouse_screen[0] = mouseX; mouse_screen[1] = mouseY; mouse_screen[2] = pnearest.screen[2]; transform.screenToWorld(mouse_screen, mouse_world); if(MOVE_PARTICLE){ pnearest.particle.enable(false, false, false); pnearest.particle.moveTo(mouse_world, 0.1f); } } }
Example #9
Source File: Skylight_BulletPhysics_Breakable3.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D pg){ if(pg == skylight.renderer.pg_render){ pg.background(16); } if(pg == geombuffer.pg_geom){ pg.background(255, 255); pg.pgl.clearColor(1, 1, 1, 6000); pg.pgl.clear(PGL.COLOR_BUFFER_BIT); } pg.pushMatrix(); pg.applyMatrix(mat_scene_view); pg.shape(group_bulletbodies); pg.shape(group_collisions); pg.popMatrix(); }
Example #10
Source File: Skylight_BulletPhysics_Breakable_VideoExport.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D pg){ if(pg == skylight.renderer.pg_render){ pg.background(16); } if(pg == geombuffer.pg_geom){ pg.background(255, 255); pg.pgl.clearColor(1, 1, 1, 6000); pg.pgl.clear(PGL.COLOR_BUFFER_BIT); } pg.pushMatrix(); pg.applyMatrix(mat_scene_view); pg.shape(group_bulletbodies); pg.popMatrix(); }
Example #11
Source File: Skylight_Cubes.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D canvas){ if(canvas == skylight.renderer.pg_render){ canvas.background(16); displaySamples(canvas); } canvas.shape(group_cubes); // ground plane float sx = bounds[3] - bounds[0]; float sy = bounds[4] - bounds[1]; float sz = bounds[5] - bounds[2]; canvas.noStroke(); canvas.fill(16,64,180); // canvas.box(sx*1.5f, sy*1.5f, 10); canvas.box(sx, sy, 10); }
Example #12
Source File: Skylight_ClothSimulation.java From PixelFlow with MIT License | 6 votes |
public void displayGridXY(PGraphics3D canvas, int lines, float s){ if(shp_gridxy == null){ shp_gridxy = createShape(); shp_gridxy.beginShape(LINES); shp_gridxy.stroke(0); shp_gridxy.strokeWeight(0.3f); float d = lines*s; for(int i = 0; i <= lines; i++){ shp_gridxy.vertex(-d,-i*s,0); shp_gridxy.vertex(d,-i*s,0); shp_gridxy.vertex(-d,+i*s,0); shp_gridxy.vertex(d,+i*s,0); shp_gridxy.vertex(-i*s,-d,0); shp_gridxy.vertex(-i*s,d,0); shp_gridxy.vertex(+i*s,-d,0); shp_gridxy.vertex(+i*s,d,0); } shp_gridxy.endShape(); } canvas.shape(shp_gridxy); }
Example #13
Source File: Skylight_PoissonSphereSamples.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D canvas){ if(canvas == skylight.renderer.pg_render){ canvas.background(16); displaySamples(canvas); } canvas.shape(shp_samples_spheres); // ground plane float sx = bounds[3] - bounds[0]; float sy = bounds[4] - bounds[1]; float sz = bounds[5] - bounds[2]; canvas.noStroke(); canvas.fill(16,64,180); canvas.box(sx*1.5f, sy*1.5f, 10); }
Example #14
Source File: Skylight_Movie2.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D canvas){ if(canvas == skylight.renderer.pg_render){ canvas.background(16); displaySamples(canvas); } canvas.shape(group_cubes); // ground plane float sx = bounds[3] - bounds[0]; float sy = bounds[4] - bounds[1]; float sz = bounds[5] - bounds[2]; canvas.noStroke(); canvas.fill(16,64,180); // canvas.fill(180,120,64); // canvas.box(sx*1.5f, sy*1.5f, 10); canvas.box(sx, sy, 10); }
Example #15
Source File: Skylight_Movie1.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D canvas){ if(canvas == skylight.renderer.pg_render){ canvas.background(16); displaySamples(canvas); } canvas.shape(group_cubes); // ground plane float sx = bounds[3] - bounds[0]; float sy = bounds[4] - bounds[1]; float sz = bounds[5] - bounds[2]; canvas.noStroke(); canvas.fill(16,64,180); // canvas.fill(180,120,64); // canvas.box(sx*1.5f, sy*1.5f, 10); canvas.box(sx, sy, 10); }
Example #16
Source File: Skylight_BulletPhysics_MengerSponge.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D pg){ if(pg == skylight.renderer.pg_render){ pg.background(180); } if(pg == geombuffer.pg_geom){ pg.background(255, 255); pg.pgl.clearColor(1, 1, 1, 6000); pg.pgl.clear(PGL.COLOR_BUFFER_BIT); } pg.pushMatrix(); pg.applyMatrix(mat_scene_view); pg.shape(group_bulletbodies); pg.popMatrix(); }
Example #17
Source File: Skylight_Capture.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D canvas){ if(canvas == skylight.renderer.pg_render){ canvas.background(BACKGROUND_COLOR); } // draw shapes canvas.pushMatrix(); canvas.translate(0, 0, cube_size + cube_size * cube_numy /2 + 50); canvas.rotateX(-PI/2); if(group_cubes != null){ canvas.shape(group_cubes); } canvas.popMatrix(); // draw ground plane float sx = scene_bounds[3] - scene_bounds[0]; float sy = scene_bounds[4] - scene_bounds[1]; canvas.noStroke(); canvas.fill(255); canvas.ellipse(0,0, sx * SQRT2, sy * SQRT2); }
Example #18
Source File: Skylight_Movie.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D canvas){ if(canvas == skylight.renderer.pg_render){ canvas.background(BACKGROUND_COLOR); } // draw shapes canvas.pushMatrix(); canvas.translate(0, 0, cube_size + cube_size * cube_numy /2); canvas.rotateX(-PI/2); canvas.shape(group_cubes); canvas.popMatrix(); // draw ground plane float sx = scene_bounds[3] - scene_bounds[0]; float sy = scene_bounds[4] - scene_bounds[1]; canvas.noStroke(); canvas.fill(255); canvas.ellipse(0,0, sx * SQRT2, sy * SQRT2); }
Example #19
Source File: Skylight_BulletPhysics_CellFracture.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D pg){ if(pg == skylight.renderer.pg_render){ pg.background(16); } if(pg == geombuffer.pg_geom){ pg.background(255, 255); pg.pgl.clearColor(1, 1, 1, 6000); pg.pgl.clear(PGL.COLOR_BUFFER_BIT); } pg.pushMatrix(); pg.applyMatrix(mat_scene_view); pg.shape(group_bulletbodies); pg.popMatrix(); }
Example #20
Source File: Skylight_BulletPhysics_Cubes.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D pg){ if(pg == skylight.renderer.pg_render){ pg.background(16); } if(pg == geombuffer.pg_geom){ pg.background(255, 255); pg.pgl.clearColor(1, 1, 1, 6000); pg.pgl.clear(PGL.COLOR_BUFFER_BIT); } pg.pushMatrix(); pg.applyMatrix(mat_scene_view); pg.shape(group_bulletbodies); pg.popMatrix(); }
Example #21
Source File: Skylight_BulletPhysics_Breakable.java From PixelFlow with MIT License | 6 votes |
public void displayScene(PGraphics3D pg){ if(pg == skylight.renderer.pg_render){ pg.background(16); } if(pg == geombuffer.pg_geom){ pg.background(255, 255); pg.pgl.clearColor(1, 1, 1, 6000); pg.pgl.clear(PGL.COLOR_BUFFER_BIT); } pg.pushMatrix(); pg.applyMatrix(mat_scene_view); pg.shape(group_bulletbodies); pg.popMatrix(); }
Example #22
Source File: Skylight_Movie3.java From PixelFlow with MIT License | 5 votes |
public void displayScene(PGraphics3D canvas){ if(canvas == skylight.renderer.pg_render){ canvas.background(255); } // ground plane float sx = bounds[3] - bounds[0]; float sy = bounds[4] - bounds[1]; float sz = bounds[5] - bounds[2]; // sx *= 2; // sy *= 2; canvas.pushMatrix(); canvas.translate(0, 0, cube_size + cube_size * cube_numy /2); canvas.rotateX(-PI/2); canvas.shape(group_cubes); canvas.popMatrix(); // canvas.beginShape(QUAD); // canvas.texture(pg_src); // canvas.textureMode(NORMAL); // canvas.vertex(bounds[0], bounds[1], 20, 0,0); // canvas.vertex(bounds[3], bounds[1], 20, 1,0); // canvas.vertex(bounds[3], bounds[4], 20, 1,1); // canvas.vertex(bounds[0], bounds[4], 20, 0,1); // canvas.endShape(); canvas.noStroke(); canvas.fill(255); // canvas.fill(16,64,255); // canvas.fill(96,160,255); // canvas.fill(180,120,64); // canvas.fill(255,180,128); // canvas.box(sx*1.5f, sy*1.5f, 10); // canvas.box(sx, sy, 10); // canvas.rect(-sx/2, -sy/2, sx, sy); canvas.ellipse(0,0, sx * SQRT2, sy * SQRT2); }
Example #23
Source File: DwSkyLightRenderer.java From PixelFlow with MIT License | 5 votes |
public void update(){ DwUtils.copyMatrices((PGraphics3D) papplet.g, pg_render); geom.update(pg_render); sky.update(); sun.update(); float w = pg_render.width; float h = pg_render.height; float sky_int = sky.param.intensity; float sun_int = sun.param.intensity; float[] sky_col = sky.param.rgb; float[] sun_col = sun.param.rgb; pg_render.beginDraw(); pg_render.blendMode(PConstants.REPLACE); pg_render.clear(); pg_render.shader(shader); shader.set("wh", w, h); shader.set("tex_sky", sky.getSrc()); shader.set("tex_sun", sun.getSrc()); shader.set("mult_sun", sun_col[0] * sun_int, sun_col[1] * sun_int, sun_col[2] * sun_int); shader.set("mult_sky", sky_col[0] * sky_int, sky_col[1] * sky_int, sky_col[2] * sky_int); shader.set("gamma", param.gamma); scene_display.display(pg_render); pg_render.endDraw(); }
Example #24
Source File: DwScreenSpaceGeometryBuffer.java From PixelFlow with MIT License | 5 votes |
public void update(PGraphics3D pg_src){ resize(pg_src.width, pg_src.height); pg_geom.beginDraw(); updateMatrices(pg_src); pg_geom.blendMode(PConstants.REPLACE); pg_geom.clear(); pg_geom.shader(shader); pg_geom.noStroke(); scene_display.display(pg_geom); pg_geom.endDraw(); }
Example #25
Source File: Skylight_ClothSimulation.java From PixelFlow with MIT License | 5 votes |
public void updateMouseInteractions(){ // update transformation stuff transform.useCurrentTransformationMatrix((PGraphics3D) this.g); // deleting springs/constraints between particles if(DELETE_SPRINGS){ findParticlesWithinRadius(mouseX, mouseY, DELETE_RADIUS); for(DwParticle particle : particles_within_radius){ particle.enableAllSprings(false); particle.collision_group = physics.getNewCollisionGroupId(); particle.rad_collision = particle.rad; particle.all_springs_deactivated = true; } } if(!MOVE_PARTICLE){ findNearestParticle(mouseX, mouseY, SNAP_RADIUS); SNAP_PARTICLE = pnearest != null; } if(SNAP_PARTICLE){ mouse_screen[0] = mouseX; mouse_screen[1] = mouseY; mouse_screen[2] = pnearest.screen[2]; transform.screenToWorld(mouse_screen, mouse_world); if(MOVE_PARTICLE){ pnearest.particle.enable(false, false, false); pnearest.particle.moveTo(mouse_world, 0.1f); } } }
Example #26
Source File: AntiAliasingComparison.java From PixelFlow with MIT License | 5 votes |
public void displaySceneWrap(PGraphics3D canvas){ canvas.beginDraw(); DwUtils.copyMatrices((PGraphics3D) this.g, canvas); float BACKGROUND_COLOR_GAMMA = (float) (Math.pow(BACKGROUND_COLOR/255.0, gamma) * 255.0); // background canvas.blendMode(PConstants.BLEND); canvas.background(BACKGROUND_COLOR_GAMMA); displayScene(canvas); canvas.endDraw(); }
Example #27
Source File: Softbody3D_Playground.java From PixelFlow with MIT License | 5 votes |
public void updateMouseInteractions(){ // update transformation stuff transform.useCurrentTransformationMatrix((PGraphics3D) this.g); // deleting springs/constraints between particles if(DELETE_SPRINGS){ findParticlesWithinRadius(mouseX, mouseY, DELETE_RADIUS); for(DwParticle particle : particles_within_radius){ particle.enableAllSprings(false); particle.collision_group = physics.getNewCollisionGroupId(); particle.rad_collision = particle.rad; particle.all_springs_deactivated = true; } } if(!MOVE_PARTICLE){ findNearestParticle(mouseX, mouseY, SNAP_RADIUS); SNAP_PARTICLE = pnearest != null; } if(SNAP_PARTICLE){ mouse_screen[0] = mouseX; mouse_screen[1] = mouseY; mouse_screen[2] = pnearest.screen[2]; transform.screenToWorld(mouse_screen, mouse_world); if(MOVE_PARTICLE){ pnearest.particle.enable(false, false, false); pnearest.particle.moveTo(mouse_world, 0.1f); } } }
Example #28
Source File: AntiAliasingComparison.java From PixelFlow with MIT License | 5 votes |
public void setup() { surface.setResizable(true); surface.setLocation(viewport_x, viewport_y); // camera peasycam = new PeasyCam(this, -4.083, -6.096, 7.000, 1300); peasycam.setRotations(1.085, -0.477, 2.910); // processing font font48 = createFont("../data/SourceCodePro-Regular.ttf", 48); font12 = createFont("../data/SourceCodePro-Regular.ttf", 12); // main library context context = new DwPixelFlow(this); context.print(); context.printGL(); // callback for scene display (used in GBAA) DwSceneDisplay scene_display = new DwSceneDisplay() { @Override public void display(PGraphics3D canvas) { displayScene(canvas); } }; // AA post-processing modes fxaa = new FXAA(context); smaa = new SMAA(context); gbaa = new GBAA(context, scene_display); // magnifier int mag_wh = (int) (height/2.5f); magnifier = new DwMagnifier(this, 4, 0, height-mag_wh, mag_wh, mag_wh); frameRate(1000); }
Example #29
Source File: Skylight_ClothSimulation.java From PixelFlow with MIT License | 5 votes |
public void displayGizmo(PGraphics3D canvas, float s){ if(shp_gizmo == null){ shp_gizmo = createShape(); shp_gizmo.beginShape(LINES); shp_gizmo.strokeWeight(1); shp_gizmo.stroke(255,0,0); shp_gizmo.vertex(0,0,0); shp_gizmo.vertex(s,0,0); shp_gizmo.stroke(0,255,0); shp_gizmo.vertex(0,0,0); shp_gizmo.vertex(0,s,0); shp_gizmo.stroke(0,0,255); shp_gizmo.vertex(0,0,0); shp_gizmo.vertex(0,0,s); shp_gizmo.endShape(); } canvas.shape(shp_gizmo); }
Example #30
Source File: AntiAliasingComparison.java From PixelFlow with MIT License | 5 votes |
public void displayScene(PGraphics3D canvas){ // lights canvas.directionalLight(255, 255, 255, 200,600,400); canvas.directionalLight(255, 255, 255, -200,-600,-400); canvas.ambientLight(64, 64, 64); // canvas.shape(shape); sceneShape(canvas); }