Java Code Examples for processing.core.PMatrix3D#get()
The following examples show how to use
processing.core.PMatrix3D#get() .
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: Papart.java From PapARt with GNU Lesser General Public License v3.0 | 6 votes |
/** * Return the x,y positions of a 3D location projected onto a given * reference. The Z axis is the angle (in radians) given by the rotation of * the positionToFind. * * @param positionToFind * @param reference * @return */ public PVector projectPositionTo(PMatrix3D positionToFind, PaperScreen reference) { PMatrix3D referenceInv = reference.getLocation().get(); referenceInv.invert(); PMatrix3D relative = positionToFind.get(); relative.preApply(referenceInv); PMatrix3D positionToFind2 = positionToFind.get(); positionToFind2.translate(100, 0, 0); PMatrix3D relative2 = positionToFind2.get(); relative2.preApply(referenceInv); PVector out = new PVector(); float x = relative.m03 - relative2.m03; float y = relative.m13 - relative2.m13; out.z = PApplet.atan2(x, y); out.x = relative.m03; out.y = reference.drawingSize.y - relative.m13; return out; }
Example 2
Source File: Papart.java From PapARt with GNU Lesser General Public License v3.0 | 6 votes |
/** * Return the x,y positions of a 3D location projected onto a given * reference. The Z axis is the angle (in radians) given by the rotation of * the positionToFind. * * @param positionToFind * @param reference * @return */ public PVector projectPositionTo2D(PMatrix3D positionToFind, PMatrix3D reference, float referenceHeight) { PMatrix3D referenceInv = reference.get(); referenceInv.invert(); PMatrix3D relative = positionToFind.get(); relative.preApply(referenceInv); PMatrix3D positionToFind2 = positionToFind.get(); positionToFind2.translate(100, 0, 0); PMatrix3D relative2 = positionToFind2.get(); relative2.preApply(referenceInv); PVector out = new PVector(); float x = relative.m03 - relative2.m03; float y = relative.m13 - relative2.m13; out.z = PApplet.atan2(x, y); out.x = relative.m03; out.y = referenceHeight - relative.m13; return out; }
Example 3
Source File: PaperScreen.java From PapARt with GNU Lesser General Public License v3.0 | 6 votes |
/** * Activate/Desactivate the tracking. This is called when loadLocationFrom() * is called. * * @param manual true to activate, false to revert to tracking * @param loc forced location, or null to use the tracked location */ public void useManualLocation(boolean manual, PMatrix3D loc) { if (manual) { if (loc == null) { // System.err.println("Cannot set a null location."); loc = this.getLocation(cameraTracking); } this.useManualLocation(loc); this.manualLocation = loc.get(); } if (!manual) { this.useTracking(); this.manualLocation = new PMatrix3D(); } // TEST instead of blocking the update, just skip the use of the tracking. // if (this.useManualLocation) { // markerBoard.blockUpdate(cameraTracking, 10 * 60 * 60 * 1000); // ms // } else { // markerBoard.blockUpdate(cameraTracking, 0); // ms // } }
Example 4
Source File: PlaneCalibration.java From PapARt with GNU Lesser General Public License v3.0 | 6 votes |
/** * Get a plane from a 3D matrix. Here the size is not that important, might * be removed. * * @param mat * @param size * @return */ public static PlaneCalibration CreatePlaneCalibrationFrom(PMatrix3D mat, PVector size) { PMatrix3D matrix = mat.get(); PlaneCreator planeCreator = new PlaneCreator(); planeCreator.addPoint(new Vec3D(matrix.m03, matrix.m13, matrix.m23)); matrix.translate(size.x, 0, 0); planeCreator.addPoint(new Vec3D(matrix.m03, matrix.m13, matrix.m23)); matrix.translate(0, size.y, 0); planeCreator.addPoint(new Vec3D(matrix.m03, matrix.m13, matrix.m23)); planeCreator.setHeight(DEFAULT_PLANE_HEIGHT); assert (planeCreator.isComputed()); PlaneCalibration planeCalibration = planeCreator.getPlaneCalibration(); planeCalibration.flipNormal(); // planeCalibration.moveAlongNormal(DEFAULT_PLANE_SHIFT); assert (planeCalibration.isValid()); return planeCalibration; }
Example 5
Source File: ExtrinsicSnapshot.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
public ExtrinsicSnapshot(PMatrix3D cameraPaperCalibration, PMatrix3D projectorPaperCalibration, PMatrix3D kinectPaperCalibration) { if (cameraPaperCalibration != null) { mainCameraPaper = cameraPaperCalibration.get(); } if (projectorPaperCalibration != null) { projectorPaper = projectorPaperCalibration.get(); } if (kinectPaperCalibration != null) { kinectPaper = kinectPaperCalibration.get(); } }
Example 6
Source File: ARDisplay.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
/** * Set the extrinsics of the display. They are relative to the main camera. * * @param extr */ public void setExtrinsics(PMatrix3D extr) { extrinsics = extr.get(); extrinsicsInv = extr.get(); extrinsicsInv.invert(); this.hasExtrinsics = true; }
Example 7
Source File: HomographyCalibration.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
private void checkAndCreateMatrix(PMatrix3D inputMatrix) { if (this.pmatrix == null) { this.pmatrix = inputMatrix.get(); } else { this.pmatrix.set(inputMatrix); } }
Example 8
Source File: ProjectiveDeviceCalibration.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
public boolean isIdentity(PMatrix3D mat) { PMatrix3D identity = new PMatrix3D(); identity.reset(); float[] identityArray = new float[16]; float[] matArray = new float[16]; identity.get(identityArray); mat.get(matArray); return Arrays.equals(identityArray, matArray); }
Example 9
Source File: ExtrinsicCalibrator.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
public static PMatrix3D computeExtrinsics(PMatrix3D camPaper, PMatrix3D projPaper) { PMatrix3D extr = projPaper.get(); extr.invert(); extr.preApply(camPaper); extr.invert(); return extr; }
Example 10
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 11
Source File: DwSkyLightShader.java From PixelFlow with MIT License | 4 votes |
void setUniforms() { // 1) modelview (camera) -> model (world) PMatrix3D mat_modelviewInv = geombuffer.pg_geom.modelviewInv.get(); // camera -> world -> shadowmap PMatrix3D mat_shadow = shadowmap.getShadowmapMatrix(); mat_shadow.apply(mat_modelviewInv); mat_shadow.transpose(); // processing PMatrix3D mat_shadow_normal = mat_shadow.get(); mat_shadow_normal.invert(); mat_shadow_normal.transpose(); // processing PMatrix3D mat_shadow_normal_modelview = shadowmap.getModelView().get(); mat_shadow_normal_modelview.apply(mat_modelviewInv); mat_shadow_normal_modelview.transpose(); // processing mat_shadow_normal_modelview.invert(); mat_shadow_normal_modelview.transpose(); // processing PMatrix3D mat_shadow_normal_projection = shadowmap.getProjection().get(); mat_shadow_normal_projection.invert(); mat_shadow_normal_projection.transpose(); // processing // PMatrix3D mat_shadow_modelview = new PMatrix3D(shadowmap.pg_shadowmap.modelview); // mat_shadow_modelview.apply(mat_modelviewInv); // mat_shadow_modelview.transpose(); // 2) transform light direction into camera space = inverse-transpose-modelView * direction mat_modelviewInv.transpose(); PVector light_dir_cameraspace = mat_modelviewInv.mult(shadowmap.lightdir, null); light_dir_cameraspace.normalize(); // projection matrix of the geometry buffer PMatrix3D mat_projection = geombuffer.pg_geom.projection.get(); mat_projection.transpose(); // processing // temporal averaging float pass_mix = RENDER_PASS/(RENDER_PASS+1.0f); float w_shadow = shadowmap.pg_shadowmap.width; float h_shadow = shadowmap.pg_shadowmap.height; // shadow offset float shadow_map_size = Math.min(w_shadow, h_shadow); float shadow_bias_mag = 0.33f/shadow_map_size; // shadow_bias_mag = scene_scale/ shadow_map_size; // PMatrix3D mat_screen_to_eye = new PMatrix3D(); // mat_screen_to_eye.scale(w, h, 1); // mat_screen_to_eye.scale(0.5f); // mat_screen_to_eye.translate(1,1,1); // mat_screen_to_eye.apply(pg.projection); // mat_screen_to_eye.invert(); // mat_screen_to_eye.transpose(); // processing, row-col switch // 3) update shader uniforms shader.set("mat_projection" , mat_projection ); shader.set("mat_shadow" , mat_shadow ); shader.set("mat_shadow_normal_modelview" , mat_shadow_normal_modelview , true); shader.set("mat_shadow_normal_projection", mat_shadow_normal_projection, true); // shader.set("mat_shadow_normal", mat_shadow_normal); // shader.set("mat_screen_to_eye", mat_screen_to_eye); // shader.set("mat_shadow_modelview", mat_shadow_modelview); shader.set("dir_light", light_dir_cameraspace); shader.set("pass_mix", pass_mix); shader.set("wh_shadow", w_shadow, h_shadow); // should match the dimensions of the shading buffers shader.set("shadow_bias_mag", shadow_bias_mag); // getBuffer(buf_mat_projection , mat_projection ); // getBuffer(buf_mat_shadow , mat_shadow ); // getBuffer(buf_mat_shadow_normal_modelview , mat_shadow_normal_modelview , true); // getBuffer(buf_mat_shadow_normal_projection, mat_shadow_normal_projection, true); // // boolean transpose = !false; // shader_.uniformMatrix4fv("mat_projection" , 1, transpose, buf_mat_projection , 0); // shader_.uniformMatrix4fv("mat_shadow" , 1, transpose, buf_mat_shadow , 0); // shader_.uniformMatrix3fv("mat_shadow_normal_modelview" , 1, transpose, buf_mat_shadow_normal_modelview , 0); // shader_.uniformMatrix3fv("mat_shadow_normal_projection", 1, transpose, buf_mat_shadow_normal_projection, 0); // shader_.uniform3f ("dir_light", light_dir_cameraspace.x, light_dir_cameraspace.y, light_dir_cameraspace.z); // shader_.uniform1f ("pass_mix", pass_mix); // shader_.uniform2f ("wh_shadow", w_shadow, h_shadow); // shader_.uniform1f ("shadow_bias_mag", shadow_bias_mag); }
Example 12
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 13
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 14
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 15
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 16
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 17
Source File: PaperScreen.java From PapARt with GNU Lesser General Public License v3.0 | 2 votes |
/** * Get a copy of the overall transform (after tracking and second * transform). * * @param trackedLocation * @return */ public PMatrix3D getLocation(PMatrix3D trackedLocation) { PMatrix3D combinedTransfos = trackedLocation.get(); combinedTransfos.apply(extrinsics); return combinedTransfos; }