Java Code Examples for processing.opengl.PGraphics3D#beginDraw()
The following examples show how to use
processing.opengl.PGraphics3D#beginDraw() .
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: DepthOfField_Demo.java From PixelFlow with MIT License | 5 votes |
public void displaySceneWrap(PGraphics3D canvas){ canvas.beginDraw(); DwUtils.copyMatrices((PGraphics3D) this.g, canvas); // background canvas.blendMode(PConstants.BLEND); canvas.background(2); displayScene(canvas); canvas.endDraw(); }
Example 2
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 3
Source File: Skylight_BulletPhysics_Cubes.java From PixelFlow with MIT License | 4 votes |
public void setup() { surface.setLocation(viewport_x, viewport_y); float SCENE_SCALE = 1000; // for screenshot capture = new DwFrameCapture(this, "examples/"); font12 = createFont("../data/SourceCodePro-Regular.ttf", 12); cam = new PeasyCam(this, 0, 0, 0, SCENE_SCALE); perspective(60 * DEG_TO_RAD, width/(float)height, 2, SCENE_SCALE * 250); group_bulletbodies = createShape(GROUP); physics = new BPhysics(); // no bounding box physics.world.setGravity(new Vector3f(0, 0, -50)); pg_render = (PGraphics3D) createGraphics(width, height, P3D); pg_render.smooth(0); pg_render.beginDraw(); pg_render.endDraw(); // compute scene bounding-sphere DwBoundingSphere scene_bs = new DwBoundingSphere(); scene_bs.set(0, 0, 200, 450); PMatrix3D mat_bs = scene_bs.getUnitSphereMatrix(); // matrix, to place (centering, scaling) the scene in the viewport mat_scene_view = new PMatrix3D(); mat_scene_view.scale(SCENE_SCALE); mat_scene_view.apply(mat_bs); // matrix, to place the scene in the skylight renderer mat_scene_bounds = mat_scene_view.get(); mat_scene_bounds.invert(); mat_scene_bounds.preApply(mat_bs); // callback for rendering the scene DwSceneDisplay scene_display = new DwSceneDisplay(){ @Override public void display(PGraphics3D canvas) { displayScene(canvas); } }; // library context context = new DwPixelFlow(this); context.print(); context.printGL(); // postprocessing filters filter = DwFilter.get(context); // init skylight renderer skylight = new DwSkyLight(context, scene_display, mat_scene_bounds); // parameters for sky-light skylight.sky.param.iterations = 50; skylight.sky.param.solar_azimuth = 0; skylight.sky.param.solar_zenith = 0; skylight.sky.param.sample_focus = 1; // full sphere sampling skylight.sky.param.intensity = 1.0f; skylight.sky.param.rgb = new float[]{1,1,1}; skylight.sky.param.shadowmap_size = 512; // quality vs. performance // parameters for sun-light skylight.sun.param.iterations = 50; skylight.sun.param.solar_azimuth = 35; skylight.sun.param.solar_zenith = 70; skylight.sun.param.sample_focus = 0.1f; skylight.sun.param.intensity = 1.0f; skylight.sun.param.rgb = new float[]{1,1,1}; skylight.sun.param.shadowmap_size = 512; // postprocessing AA smaa = new SMAA(context); pg_aa = (PGraphics3D) createGraphics(width, height, P3D); pg_aa.smooth(0); pg_aa.textureSampling(5); dof = new DepthOfField(context); geombuffer = new DwScreenSpaceGeometryBuffer(context, scene_display); pg_tmp = (PGraphics3D) createGraphics(width, height, P3D); pg_tmp.smooth(0); DwUtils.changeTextureFormat(pg_tmp, GL2.GL_RGBA16F, GL2.GL_RGBA, GL2.GL_FLOAT); // fresh start reset(); createFractureShape(); frameRate(60); }
Example 4
Source File: Skylight_BulletPhysics_CellFracture.java From PixelFlow with MIT License | 4 votes |
public void setup() { surface.setLocation(viewport_x, viewport_y); float SCENE_SCALE = 1000; // for screenshot capture = new DwFrameCapture(this, "examples/"); font12 = createFont("../data/SourceCodePro-Regular.ttf", 12); cam = new PeasyCam(this, 0, 0, 0, SCENE_SCALE); perspective(60 * DEG_TO_RAD, width/(float)height, 2, SCENE_SCALE * 250); group_bulletbodies = createShape(GROUP); physics = new BPhysics(); // no bounding box physics.world.setGravity(new Vector3f(0, 0, -100)); pg_render = (PGraphics3D) createGraphics(width, height, P3D); pg_render.smooth(0); pg_render.beginDraw(); pg_render.endDraw(); // compute scene bounding-sphere DwBoundingSphere scene_bs = new DwBoundingSphere(); scene_bs.set(0, 0, 200, 450); PMatrix3D mat_bs = scene_bs.getUnitSphereMatrix(); // matrix, to place (centering, scaling) the scene in the viewport mat_scene_view = new PMatrix3D(); mat_scene_view.scale(SCENE_SCALE); mat_scene_view.apply(mat_bs); // matrix, to place the scene in the skylight renderer mat_scene_bounds = mat_scene_view.get(); mat_scene_bounds.invert(); mat_scene_bounds.preApply(mat_bs); // callback for rendering the scene DwSceneDisplay scene_display = new DwSceneDisplay(){ @Override public void display(PGraphics3D canvas) { displayScene(canvas); } }; // library context context = new DwPixelFlow(this); context.print(); context.printGL(); // postprocessing filters filter = DwFilter.get(context); // init skylight renderer skylight = new DwSkyLight(context, scene_display, mat_scene_bounds); // parameters for sky-light skylight.sky.param.iterations = 50; skylight.sky.param.solar_azimuth = 0; skylight.sky.param.solar_zenith = 0; skylight.sky.param.sample_focus = 1; // full sphere sampling skylight.sky.param.intensity = 1.0f; skylight.sky.param.rgb = new float[]{1,1,1}; skylight.sky.param.shadowmap_size = 512; // quality vs. performance // parameters for sun-light skylight.sun.param.iterations = 50; skylight.sun.param.solar_azimuth = 35; skylight.sun.param.solar_zenith = 65; skylight.sun.param.sample_focus = 0.1f; skylight.sun.param.intensity = 1.0f; skylight.sun.param.rgb = new float[]{1,1,1}; skylight.sun.param.shadowmap_size = 512; // postprocessing AA smaa = new SMAA(context); pg_aa = (PGraphics3D) createGraphics(width, height, P3D); pg_aa.smooth(0); pg_aa.textureSampling(5); dof = new DepthOfField(context); geombuffer = new DwScreenSpaceGeometryBuffer(context, scene_display); pg_tmp = (PGraphics3D) createGraphics(width, height, P3D); pg_tmp.smooth(0); DwUtils.changeTextureFormat(pg_tmp, GL2.GL_RGBA16F, GL2.GL_RGBA, GL2.GL_FLOAT); // fresh start reset(); createFractureShape(); frameRate(60); }
Example 5
Source File: Skylight_BulletPhysics_MengerSponge.java From PixelFlow with MIT License | 4 votes |
public void setup() { surface.setLocation(viewport_x, viewport_y); float SCENE_SCALE = 1000; // for screenshot capture = new DwFrameCapture(this, "examples/"); font12 = createFont("../data/SourceCodePro-Regular.ttf", 12); cam = new PeasyCam(this, 0, 0, 0, SCENE_SCALE); perspective(60 * DEG_TO_RAD, width/(float)height, 2, SCENE_SCALE * 250); group_bulletbodies = createShape(GROUP); physics = new BPhysics(); // no bounding box physics.world.setGravity(new Vector3f(0, 0, -50)); pg_render = (PGraphics3D) createGraphics(width, height, P3D); pg_render.smooth(0); pg_render.beginDraw(); pg_render.endDraw(); // compute scene bounding-sphere DwBoundingSphere scene_bs = new DwBoundingSphere(); scene_bs.set(0, 0, 200, 450); PMatrix3D mat_bs = scene_bs.getUnitSphereMatrix(); // matrix, to place (centering, scaling) the scene in the viewport mat_scene_view = new PMatrix3D(); mat_scene_view.scale(SCENE_SCALE); mat_scene_view.apply(mat_bs); // matrix, to place the scene in the skylight renderer mat_scene_bounds = mat_scene_view.get(); mat_scene_bounds.invert(); mat_scene_bounds.preApply(mat_bs); // callback for rendering the scene DwSceneDisplay scene_display = new DwSceneDisplay(){ @Override public void display(PGraphics3D canvas) { displayScene(canvas); } }; // library context context = new DwPixelFlow(this); context.print(); context.printGL(); // postprocessing filters filter = DwFilter.get(context); // init skylight renderer skylight = new DwSkyLight(context, scene_display, mat_scene_bounds); // parameters for sky-light skylight.sky.param.iterations = 50; skylight.sky.param.solar_azimuth = 0; skylight.sky.param.solar_zenith = 0; skylight.sky.param.sample_focus = 1; // full sphere sampling skylight.sky.param.intensity = 1.0f; skylight.sky.param.rgb = new float[]{1,1,1}; skylight.sky.param.shadowmap_size = 512; // quality vs. performance // parameters for sun-light skylight.sun.param.iterations = 50; skylight.sun.param.solar_azimuth = 35; skylight.sun.param.solar_zenith = 70; skylight.sun.param.sample_focus = 0.1f; skylight.sun.param.intensity = 1.0f; skylight.sun.param.rgb = new float[]{1,1,1}; skylight.sun.param.shadowmap_size = 512; // postprocessing AA smaa = new SMAA(context); pg_aa = (PGraphics3D) createGraphics(width, height, P3D); pg_aa.smooth(0); pg_aa.textureSampling(5); dof = new DepthOfField(context); geombuffer = new DwScreenSpaceGeometryBuffer(context, scene_display); pg_tmp = (PGraphics3D) createGraphics(width, height, P3D); pg_tmp.smooth(0); DwUtils.changeTextureFormat(pg_tmp, GL2.GL_RGBA16F, GL2.GL_RGBA, GL2.GL_FLOAT); // fresh start reset(); createFractureShape(); frameRate(60); }
Example 6
Source File: Skylight_BulletPhysics_Breakable3.java From PixelFlow with MIT License | 4 votes |
public void setup() { surface.setLocation(viewport_x, viewport_y); float SCENE_SCALE = 1000; // for screenshot capture = new DwFrameCapture(this, "examples/"); font12 = createFont("../data/SourceCodePro-Regular.ttf", 12); cam = new PeasyCam(this, 0, 0, 0, SCENE_SCALE); perspective(60 * DEG_TO_RAD, width/(float)height, 2, SCENE_SCALE * 250); group_bulletbodies = createShape(GROUP); physics = new MyBPhysics(); // no bounding box physics.world.setGravity(new Vector3f(0, 0, -100)); pg_render = (PGraphics3D) createGraphics(width, height, P3D); pg_render.smooth(0); pg_render.beginDraw(); pg_render.endDraw(); // compute scene bounding-sphere DwBoundingSphere scene_bs = new DwBoundingSphere(); scene_bs.set(0, 0, 200, 450); PMatrix3D mat_bs = scene_bs.getUnitSphereMatrix(); // matrix, to place (centering, scaling) the scene in the viewport mat_scene_view = new PMatrix3D(); mat_scene_view.scale(SCENE_SCALE); mat_scene_view.apply(mat_bs); // matrix, to place the scene in the skylight renderer mat_scene_bounds = mat_scene_view.get(); mat_scene_bounds.invert(); mat_scene_bounds.preApply(mat_bs); // callback for rendering the scene DwSceneDisplay scene_display = new DwSceneDisplay(){ @Override public void display(PGraphics3D canvas) { displayScene(canvas); } }; // library context context = new DwPixelFlow(this); context.print(); context.printGL(); // postprocessing filters filter = DwFilter.get(context); // init skylight renderer skylight = new DwSkyLight(context, scene_display, mat_scene_bounds); // parameters for sky-light skylight.sky.param.iterations = 50; skylight.sky.param.solar_azimuth = 0; skylight.sky.param.solar_zenith = 0; skylight.sky.param.sample_focus = 1; // full sphere sampling skylight.sky.param.intensity = 1.0f; skylight.sky.param.rgb = new float[]{1,1,1}; skylight.sky.param.shadowmap_size = 512; // quality vs. performance // parameters for sun-light skylight.sun.param.iterations = 50; skylight.sun.param.solar_azimuth = 35; skylight.sun.param.solar_zenith = 65; skylight.sun.param.sample_focus = 0.1f; skylight.sun.param.intensity = 1.0f; skylight.sun.param.rgb = new float[]{1,1,1}; skylight.sun.param.shadowmap_size = 512; // postprocessing AA smaa = new SMAA(context); pg_aa = (PGraphics3D) createGraphics(width, height, P3D); pg_aa.smooth(0); pg_aa.textureSampling(5); dof = new DepthOfField(context); geombuffer = new DwScreenSpaceGeometryBuffer(context, scene_display); pg_tmp = (PGraphics3D) createGraphics(width, height, P3D); pg_tmp.smooth(0); DwUtils.changeTextureFormat(pg_tmp, GL2.GL_RGBA16F, GL2.GL_RGBA, GL2.GL_FLOAT); // fresh start reset(); createFractureShape(); frameRate(60); }
Example 7
Source File: Skylight_BulletPhysics_TowerDemolition.java From PixelFlow with MIT License | 4 votes |
public void setup() { surface.setLocation(viewport_x, viewport_y); float SCENE_SCALE = 1000; capture = new DwFrameCapture(this, "examples/"); font12 = createFont("../data/SourceCodePro-Regular.ttf", 12); font96 = createFont("../data/SourceCodePro-Regular.ttf", 32); cam = new PeasyCam(this, 0, 0, 0, SCENE_SCALE); perspective(60 * DEG_TO_RAD, width/(float)height, 2, SCENE_SCALE * 250); group_bulletbodies = createShape(GROUP); // Vector3f min = new Vector3f(-300, -300, 0); // Vector3f max = new Vector3f(+300, +300, +1000); // physics = new BPhysics(min, max); physics = new BPhysics(); // no bounding box physics.world.setGravity(new Vector3f(0, 0, -30)); pg_render = (PGraphics3D) createGraphics(width, height, P3D); pg_render.smooth(0); pg_render.beginDraw(); pg_render.endDraw(); // compute scene bounding-sphere DwBoundingSphere scene_bs = new DwBoundingSphere(); scene_bs.set(0, 0, 200, 450); PMatrix3D mat_bs = scene_bs.getUnitSphereMatrix(); // matrix, to place (centering, scaling) the scene in the viewport mat_scene_view = new PMatrix3D(); mat_scene_view.scale(SCENE_SCALE); mat_scene_view.apply(mat_bs); // matrix, to place the scene in the skylight renderer mat_scene_bounds = mat_scene_view.get(); mat_scene_bounds.invert(); mat_scene_bounds.preApply(mat_bs); // callback for rendering the scene DwSceneDisplay scene_display = new DwSceneDisplay(){ @Override public void display(PGraphics3D canvas) { displayScene(canvas); } }; // library context context = new DwPixelFlow(this); context.print(); context.printGL(); // postprocessing filters filter = DwFilter.get(context); // init skylight renderer skylight = new DwSkyLight(context, scene_display, mat_scene_bounds); // parameters for sky-light skylight.sky.param.iterations = 50; skylight.sky.param.solar_azimuth = 0; skylight.sky.param.solar_zenith = 0; skylight.sky.param.sample_focus = 1; // full sphere sampling skylight.sky.param.intensity = 1.0f; skylight.sky.param.rgb = new float[]{1,1,1}; skylight.sky.param.shadowmap_size = 512; // quality vs. performance // parameters for sun-light skylight.sun.param.iterations = 50; skylight.sun.param.solar_azimuth = 35; skylight.sun.param.solar_zenith = 65; skylight.sun.param.sample_focus = 0.1f; skylight.sun.param.intensity = 1.0f; skylight.sun.param.rgb = new float[]{1,1,1}; skylight.sun.param.shadowmap_size = 512; // postprocessing AA smaa = new SMAA(context); pg_aa = (PGraphics3D) createGraphics(width, height, P3D); pg_aa.smooth(0); pg_aa.textureSampling(5); dof = new DepthOfField(context); geombuffer = new DwScreenSpaceGeometryBuffer(context, scene_display); pg_tmp = (PGraphics3D) createGraphics(width, height, P3D); pg_tmp.smooth(0); DwUtils.changeTextureFormat(pg_tmp, GL2.GL_RGBA16F, GL2.GL_RGBA, GL2.GL_FLOAT); // fresh start reset(); createBuildings(BUILDING); frameRate(60); }
Example 8
Source File: Skylight_BulletPhysics_Basic.java From PixelFlow with MIT License | 4 votes |
public void setup() { surface.setLocation(viewport_x, viewport_y); float SCENE_SCALE = 1000; capture = new DwFrameCapture(this, "examples/"); font12 = createFont("../data/SourceCodePro-Regular.ttf", 12); cam = new PeasyCam(this, 0, 0, 0, SCENE_SCALE); perspective(60 * DEG_TO_RAD, width/(float)height, 2, SCENE_SCALE * 250); group_bulletbodies = createShape(GROUP); // Vector3f min = new Vector3f(-200, -200, 0); // Vector3f max = new Vector3f(+200, +200, +400); // physics = new BPhysics(min, max); physics = new BPhysics(); // no bounding box physics.world.setGravity(new Vector3f(0, 0, -300)); pg_render = (PGraphics3D) createGraphics(width, height, P3D); pg_render.smooth(0); pg_render.beginDraw(); pg_render.endDraw(); // compute scene bounding-sphere DwBoundingSphere scene_bs = new DwBoundingSphere(); scene_bs.set(0, 0, 200, 450); PMatrix3D mat_bs = scene_bs.getUnitSphereMatrix(); // matrix, to place (centering, scaling) the scene in the viewport mat_scene_view = new PMatrix3D(); mat_scene_view.scale(SCENE_SCALE); mat_scene_view.apply(mat_bs); // matrix, to place the scene in the skylight renderer mat_scene_bounds = mat_scene_view.get(); mat_scene_bounds.invert(); mat_scene_bounds.preApply(mat_bs); // callback for rendering the scene DwSceneDisplay scene_display = new DwSceneDisplay(){ @Override public void display(PGraphics3D canvas) { displayScene(canvas); } }; // library context context = new DwPixelFlow(this); context.print(); context.printGL(); // postprocessing filters filter = DwFilter.get(context); // init skylight renderer skylight = new DwSkyLight(context, scene_display, mat_scene_bounds); // parameters for sky-light skylight.sky.param.iterations = 50; skylight.sky.param.solar_azimuth = 0; skylight.sky.param.solar_zenith = 0; skylight.sky.param.sample_focus = 1; // full sphere sampling skylight.sky.param.intensity = 1.0f; skylight.sky.param.rgb = new float[]{1,1,1}; skylight.sky.param.shadowmap_size = 512; // quality vs. performance // parameters for sun-light skylight.sun.param.iterations = 50; skylight.sun.param.solar_azimuth = 35; skylight.sun.param.solar_zenith = 65; skylight.sun.param.sample_focus = 0.1f; skylight.sun.param.intensity = 1.0f; skylight.sun.param.rgb = new float[]{1,1,1}; skylight.sun.param.shadowmap_size = 512; // postprocessing AA smaa = new SMAA(context); pg_aa = (PGraphics3D) createGraphics(width, height, P3D); pg_aa.smooth(0); pg_aa.textureSampling(5); dof = new DepthOfField(context); geombuffer = new DwScreenSpaceGeometryBuffer(context, scene_display); pg_tmp = (PGraphics3D) createGraphics(width, height, P3D); pg_tmp.smooth(0); DwUtils.changeTextureFormat(pg_tmp, GL2.GL_RGBA16F, GL2.GL_RGBA, GL2.GL_FLOAT); // fresh start reset(); frameRate(60); }
Example 9
Source File: DwSkyLightShader.java From PixelFlow with MIT License | 4 votes |
public void updateStep(){ if(param.intensity <= 0){ return; } if(shadowmap.pg_shadowmap.width != param.shadowmap_size){ shadowmap.resize(param.shadowmap_size); } // 1) shadow pass generateSampleDirection(); shadowmap.update(); PGraphics3D pg_dst = getDst(); PGraphics3D pg_src = getSrc(); float w = pg_dst.width; float h = pg_dst.height; // 2.1) render pass pg_dst.beginDraw(); pg_dst.blendMode(PConstants.REPLACE); pg_dst.shader(shader); setUniforms(); shader.set("wh" , w, h); shader.set("tex_src" , pg_src); shader.set("tex_shadow" , shadowmap.pg_shadowmap); shader.set("tex_geombuffer", geombuffer.pg_geom); pg_dst.resetMatrix(); pg_dst.resetProjection(); pg_dst.noStroke(); pg_dst.fill(255); pg_dst.rect(-1,-1,2,2); pg_dst.endDraw(); DwUtils.swap(pg_shading); // Texture tex_shadowmap = shadowmap.pg_shadowmap.getTexture(); // Texture tex_geombuffer = geombuffer.pg_geom.getTexture(); // // context.begin(); // context.beginDraw(tex_shading.dst); // shader_.begin(); // setUniforms(); // shader_.uniform2f ("wh" , w, h); // shader_.uniformTexture("tex_src" , tex_shading.src); // shader_.uniformTexture("tex_shadow" , tex_shadowmap.glName); // shader_.uniformTexture("tex_geombuffer", tex_geombuffer.glName); // shader_.drawFullScreenQuad(); // shader_.end(); // context.endDraw(); // context.end(); // // tex_shading.swap(); // // DwFilter.get(context).copy.apply(tex_shading.src, pg_src); RENDER_PASS++; }