Java Code Examples for processing.core.PMatrix3D#scale()

The following examples show how to use processing.core.PMatrix3D#scale() . 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: DwShadowMap.java    From PixelFlow with MIT License 6 votes vote down vote up
public PMatrix3D getProjection(){
  pg_shadowmap.updateProjmodelview();

  // 1) create shadowmap matrix, 
  //    to transform positions from camera-space to the shadowmap-space (light-space)
  PMatrix3D mat_shadow = new PMatrix3D();
  // ndc (shadowmap) -> normalized (shadowmap) 
  //         [-1,+1] -> [0,1]
  mat_shadow.scale(0.5f);
  mat_shadow.translate(1,1,1);

  // model (world) -> modelview (shadowmap) -> ndc (shadowmap)
  mat_shadow.apply(pg_shadowmap.projection);
  
  return mat_shadow;
}
 
Example 2
Source File: DwShadowMap.java    From PixelFlow with MIT License 5 votes vote down vote up
public PMatrix3D getShadowmapMatrix(){
  // 1) create shadowmap matrix, 
  //    to transform positions from camera-space to the shadowmap-space (light-space)
  PMatrix3D mat_shadow = new PMatrix3D();
  // ndc (shadowmap) -> normalized (shadowmap) 
  //         [-1,+1] -> [0,1]
  mat_shadow.scale(0.5f);
  mat_shadow.translate(1,1,1);

  // model (world) -> modelview (shadowmap) -> ndc (shadowmap)
  mat_shadow.apply(pg_shadowmap.projmodelview);
  
  return mat_shadow;
}
 
Example 3
Source File: RSTTransform.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void applyTransformationTo(PMatrix3D matrix) {
    matrix.translate(sceneTranslate.x, sceneTranslate.y, sceneTranslate.z);
    matrix.rotateX(sceneRotateX);
    matrix.rotateY(sceneRotateY);
    matrix.rotateZ(sceneRotateZ);
    matrix.scale(sceneScale);
}
 
Example 4
Source File: MarkerBoardSvg.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void update(PMatrix3D newPos, int id) {
        PMatrix3D transfo = (PMatrix3D) transfos.get(id);
        fr.inria.papart.multitouch.OneEuroFilter filter[] = filters.get(id);

        if (filter == null) {
            transfo.set(newPos);
        } else {
            try {
                // Rotation
                transfo.m00 = (float) filter[0].filter(newPos.m00);
                transfo.m01 = (float) filter[1].filter(newPos.m01);
                transfo.m02 = (float) filter[2].filter(newPos.m02);
                transfo.m10 = (float) filter[3].filter(newPos.m10);
                transfo.m11 = (float) filter[4].filter(newPos.m11);
                transfo.m12 = (float) filter[5].filter(newPos.m12);
                transfo.m20 = (float) filter[6].filter(newPos.m20);
                transfo.m21 = (float) filter[7].filter(newPos.m21);
                transfo.m22 = (float) filter[8].filter(newPos.m22);

                // Translation
                transfo.m03 = (float) filter[9].filter(newPos.m03);
                transfo.m13 = (float) filter[10].filter(newPos.m13);
                transfo.m23 = (float) filter[11].filter(newPos.m23);
            } catch (Exception e) {
                System.out.println("Filtering error " + e);
            }
        }

//        float pageHeight = this.height;
        float pageHeight = markersFromSVG.getSheetHeight();

        // Invert the scales so that it fits Inkscape's view. 
        transfo.scale(1, -1, 1);
        transfo.translate(0, -pageHeight, 0);
    }
 
Example 5
Source File: Skylight_BulletPhysics_Cubes.java    From PixelFlow with MIT License 4 votes vote down vote up
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_CellFracture.java    From PixelFlow with MIT License 4 votes vote down vote up
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 7
Source File: Skylight_BulletPhysics_MengerSponge.java    From PixelFlow with MIT License 4 votes vote down vote up
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 8
Source File: Skylight_BulletPhysics_Breakable3.java    From PixelFlow with MIT License 4 votes vote down vote up
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 9
Source File: Skylight_BulletPhysics_TowerDemolition.java    From PixelFlow with MIT License 4 votes vote down vote up
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 10
Source File: Skylight_BulletPhysics_Basic.java    From PixelFlow with MIT License 4 votes vote down vote up
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 11
Source File: DwBoundingSphere.java    From PixelFlow with MIT License 4 votes vote down vote up
public PMatrix3D getUnitSphereMatrix(){
  PMatrix3D mat = new PMatrix3D();
  mat.scale(1.0f/rad);
  mat.translate(-pos[0], -pos[1], -pos[2]);
  return mat;
}
 
Example 12
Source File: PaperScreen.java    From PapARt with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Init VR rendering. The VR rendering creates a 3D "screen". It is used to
 * create 3D pop-up effects.
 *
 * @param cam Rendering origin.
 * @param userPos Position of the user, relative to the PaperScreen
 * @param nearPlane Close disance for OpengL in millimeters.
 * @param farPlane Far distance for OpenGL in millimeters.
 * @param isAnaglyph Use Anaglyph.
 * @param isLeft When analygph is it left or right, ignored otherwise.
 */
public void initDraw(Camera cam, PVector userPos, float nearPlane, float farPlane, boolean isAnaglyph, boolean isLeft) {

    PGraphicsOpenGL graphics = getGraphics();

    if (initPosM == null) {
        this.isOpenGL = true;
        // Transformation  Camera -> Marker

        initPosM = this.getLocation(cam);

        initPosM.translate(this.getRenderingSizeX() / 2, this.getRenderingSizeY() / 2);
        // All is relative to the paper's center. not the corner. 
        initPosM.scale(-1, 1, 1);

    }

    // get the current transformation... 
    PMatrix3D newPos = this.getLocation(cam);

    newPos.translate(this.getRenderingSizeX() / 2, this.getRenderingSizeY() / 2);
    newPos.scale(-1, 1, 1);

    newPos.invert();
    newPos.apply(initPosM);

    PVector user = new PVector();

    if (isAnaglyph && isLeft) {
        userPos.add(-halfEyeDist * 2, 0, 0);
    }
    newPos.mult(userPos, user);
    PVector paperCameraPos = user;

    // Camera must look perpendicular to the screen. 
    graphics.camera(paperCameraPos.x, paperCameraPos.y, paperCameraPos.z,
            paperCameraPos.x, paperCameraPos.y, 0,
            0, 1, 0);

    // http://www.gamedev.net/topic/597564-view-and-projection-matrices-for-vr-window-using-head-tracking/
    float nearFactor = nearPlane / paperCameraPos.z;

    float left = nearFactor * (-drawingSize.x / 2f - paperCameraPos.x);
    float right = nearFactor * (drawingSize.x / 2f - paperCameraPos.x);
    float top = nearFactor * (drawingSize.y / 2f - paperCameraPos.y);
    float bottom = nearFactor * (-drawingSize.y / 2f - paperCameraPos.y);

    graphics.frustum(left, right, bottom, top, nearPlane, farPlane);
    graphics.projection.m11 = -graphics.projection.m11;

    // No detection?
    PMatrix3D transformation = this.getLocation(cam);
    if (transformation.m03 == 0 && transformation.m13 == 0 && transformation.m23 == 0) {
        resetPos();
    }
}
 
Example 13
Source File: MarkerBoardARToolKitPlus.java    From PapARt with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void update(ARToolKitPlus.ARMultiMarkerInfoT multiMarkerConfig, int id) {
        fr.inria.papart.multitouch.OneEuroFilter filter[] = filters.get(id);

        PMatrix3D inputMatrix = new PMatrix3D();

        if (filter == null) {
            inputMatrix.m00 = multiMarkerConfig.trans().get(0);
            inputMatrix.m01 = multiMarkerConfig.trans().get(1);
            inputMatrix.m02 = multiMarkerConfig.trans().get(2);
            inputMatrix.m03 = multiMarkerConfig.trans().get(3);

            inputMatrix.m10 = multiMarkerConfig.trans().get(4);
            inputMatrix.m11 = multiMarkerConfig.trans().get(5);
            inputMatrix.m12 = multiMarkerConfig.trans().get(6);
            inputMatrix.m13 = multiMarkerConfig.trans().get(7);

            inputMatrix.m20 = multiMarkerConfig.trans().get(8);
            inputMatrix.m21 = multiMarkerConfig.trans().get(9);
            inputMatrix.m22 = multiMarkerConfig.trans().get(10);
            inputMatrix.m23 = multiMarkerConfig.trans().get(11);
        } else {
            try {
                inputMatrix.m00 = (float) filter[0].filter(multiMarkerConfig.trans().get(0));
                inputMatrix.m01 = (float) filter[1].filter(multiMarkerConfig.trans().get(1));
                inputMatrix.m02 = (float) filter[2].filter(multiMarkerConfig.trans().get(2));
                inputMatrix.m03 = (float) filter[3].filter(multiMarkerConfig.trans().get(3));

                inputMatrix.m10 = (float) filter[4].filter(multiMarkerConfig.trans().get(4));
                inputMatrix.m11 = (float) filter[5].filter(multiMarkerConfig.trans().get(5));
                inputMatrix.m12 = (float) filter[6].filter(multiMarkerConfig.trans().get(6));
                inputMatrix.m13 = (float) filter[7].filter(multiMarkerConfig.trans().get(7));

                inputMatrix.m20 = (float) filter[8].filter(multiMarkerConfig.trans().get(8));
                inputMatrix.m21 = (float) filter[9].filter(multiMarkerConfig.trans().get(9));
                inputMatrix.m22 = (float) filter[10].filter(multiMarkerConfig.trans().get(10));
                inputMatrix.m23 = (float) filter[11].filter(multiMarkerConfig.trans().get(11));
            } catch (Exception e) {
                System.out.println("Filtering error " + e);
            }
        }

//        inputMatrix.translate(0, height / 2, 0);
//        inputMatrix.scale(1, -1, 1);
//        inputMatrix.translate(0, -height / 2, 0);
        // Invert the scales so that it fits Inkscape's view. 
        
        inputMatrix.scale(1, -1, 1);
        inputMatrix.translate(0, -markerBoardSize.y, 0);

        PMatrix3D transfo = transfos.get(id);
        transfo.set(inputMatrix);
//    Z negation ?
//        tmp.scale(1, 1, -1);
//        transfo[11] = -transfo[11];
    }