Exemple #1
0
 private void mouseToWorldCoord(
     int x,
     int y,
     int[] viewport,
     float[] proj,
     Load2Dfloat data,
     Tiledboard board,
     boolean heightctrl) {
   posx = (proj[1] - proj[0]) / viewport[2] * (x - viewport[0]) + proj[0];
   posy = (-proj[3] + proj[2]) / viewport[3] * (y - viewport[1]) + proj[3];
   System.out.println("light " + posx + " " + posy);
   // scene.setlightpos(0, (float)posx, (float)posy);
   double rad = Math.acos(posx / Math.sqrt(posx * posx + posy * posy));
   if (posy < 0) rad = 2 * Math.PI - rad;
   double r = Math.sqrt(32);
   scene.setlightpospolar(0, r, rad);
   scene.setlightdirectionrotate(rad);
   // 高さ自動調整
   // float heighttmp=0;
   // if(heightctrl)heighttmp = mouseToHeight(posx, posy, data, board);
   // scene.setLightCircleLookOutside(posx,posy,height+heighttmp,angle,1,1,scene.lightCount());
   posx = (double) x / viewport[2] * 2 * Math.PI;
   posx = 2 * Math.PI * 0.8;
   // scene.setLightCircleLookInside(posx, height);
 }
Exemple #2
0
  public void rendering(GL2GL3 gl) {
    updateCanvasSize(gl);
    currentSO.rendering(gl);
    currentSO.iterate(gl);
    if (switched) {
      scene.shader1f(gl, gamma, "gamma");
      scene.shader1f(gl, heightscale, "heightscale");
      scene.shadowmapshader1f(gl, heightscale, "heightscale");

      switched = false;
    }
    // screenshot("SS/ipsj2/", 1024, 1024);
  }
Exemple #3
0
  public void init(GL2GL3 gl) {
    timer.init(gl);

    smapfbo = new FBO(gl);

    texviewer = new TexViewer();
    texviewer.init(gl);

    fxaa = new Filter("resources/ShaderSource/FXAA/vert.c", "resources/ShaderSource/FXAA/frag.c");
    fxaa.init(gl);

    // String filepath = "/home/michael/zheng/Programs/WeatherData/2009100718/";
    String filepath = "/home/michael/zheng/Programs/WeatherData/2009100818/";
    // String filepath = "/home/michael/zheng/Programs/WeatherData/2008061418/";

    // initTestData(gl);

    scene = new Scene1();
    scene.initShadowmap(gl, 2, SHADOWMAPWIDTH, SHADOWMAPHEIGHT);
    for (int i = 0; i < scene.lightCount(); i++) {
      scene.lights.get(i).init(gl);
      //      float angle = 2 * (float)Math.PI * i / (scene.lightCount() - 1);
      //      //scene.lights.get(i).lookat(3, 3, i + 1, 0, 0, 0, 0, 1, 0);
      //      scene.lights.get(i).lookat(6*(float)Math.sin(angle), 6*(float)Math.cos(angle), 8,
      //          0, 0, 0, 0, 1, 0);
      //      scene.lights.get(i).perspectivef(120f, 1, 0.1f, 50f);
    }
    scene.lights.get(0).lookatd(4, 4, 10, 0, 0, 0, 0, 1, 0);
    // scene.lights.get(0).lookatd(0, 0, 50, 0, 0, 0, 0, 1, 0);
    scene.lights.get(0).orthof(-4, 4, -4, 4, 0, 60);
    scene.lights.get(0).setattr(0, 1);
    scene.lights.get(0).setintensity(1.25);

    //    scene.lights.get(2).lookatd(4, 4, 10, 0, 0, 0, 0, 1, 0);
    //    scene.lights.get(2).orthof(-5, 5, -5, 5, 0, 30);

    scene.lights.get(1).lookatd(4, -4, 10, 0, 0, 0, 0, 1, 0);
    scene.lights.get(1).orthof(-4, 4, -4, 4, 0, 100);

    //    scene.lights.get(2).lookatd(0, 0, 50, 0, 0, 0, 0, 1, 0);
    //    scene.lights.get(2).orthof(-5, 5, -5, 5, 0, 100);

    shader =
        new Shader(
            "resources/ShaderSource/BaseShaders/SimpleShader/vert.c",
            null,
            null,
            null,
            "resources/ShaderSource/BaseShaders/SimpleShader/frag.c");
    shader.init(gl);

    shadowmapping =
        new Shader(
            "resources/ShaderSource/ShadowMapping/vert.c",
            null,
            null,
            "resources/ShaderSource/ShadowMapping/geom.c",
            "resources/ShaderSource/ShadowMapping/fragsimple.c");
    shadowmapping.init(gl);
    shadowmapping.use(gl);

    // tess evalシェーダーはシャドウマップのものを使う
    shadowmappingtess =
        new Shader(
            "resources/ShaderSource/ShadowMapping/vert.c",
            "resources/ShaderSource/ShadowMapping/ctrl.c",
            "resources/ShaderSource/BaseShaders/Shadowmap/eval.c",
            "resources/ShaderSource/ShadowMapping/geom.c",
            "resources/ShaderSource/ShadowMapping/frag.c");
    shadowmappingtess.init(gl);

    tex =
        new Tex2D(
            GL2.GL_RGBA,
            GL2.GL_RGBA,
            GL2.GL_FLOAT,
            1024,
            1024,
            GL2.GL_LINEAR,
            GL2.GL_REPEAT,
            GL2.GL_REPEAT,
            null,
            "testimage");

    tex.init(gl);
    tbs = new TexBindSet(tex);
    tbs.bind(gl);

    //    scene.updateligths(gl, shadowmapping);
    //    scene.lookat(0, 0, 30, 0, 0, 0, 0, 1, 0);
    //    scene.orthof(proj[0], proj[1], proj[2], proj[3], 0, 100);

    // initの場所はあとで調整
    scene.init(gl, shadowmapping, shadowmappingtess);
    // 円柱オフ
    scene.shader1i(gl, 0, "offheight");

    fbo = new FBO(gl);
    fbo.attachTexture(gl, tbs);
    fbo.attachDepthRBO(gl, 1024, 1024);
    // */
    initSceneOrganizer(gl);
    Ctrlpanel.currentSO = currentSO;
  }