コード例 #1
0
  public void update(Camera camera, Perspective3D perspective3d) {

    Point3d cameraPoint = camera.getPoint();
    Vector3d cameraRotation = camera.getAngle();

    Perspective3D perspective = perspective3d;

    EastNorth eastNorth = perspective.toEastNorth(cameraPoint.x, -cameraPoint.z);

    Projection proj = Main.getProjection();

    LatLon latLon = proj.eastNorth2latlon(eastNorth);

    // XXX update cache
    this.photo.setLat(latLon.lat());
    this.photo.setLon(latLon.lon());
    this.photo.setHeight(cameraPoint.y);

    this.photo.setRotate(cameraRotation.x, cameraRotation.y, cameraRotation.z);
  }
コード例 #2
0
  public void draw(GL2 gl, Camera camera, Perspective3D perspective3d) {
    Photo photo = this.photo;

    gl.glDisable(GL2.GL_DEPTH_TEST);
    gl.glColor4f(
        (float) 255 / 255, (float) 255 / 255, (float) 255 / 255, (float) photo.getTransparent());

    // Enable Alpha Blending (disable alpha testing)
    gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
    gl.glEnable(GL2.GL_BLEND);

    gl.glDisable(GL2.GL_LIGHTING);
    gl.glEnable(GL2.GL_TEXTURE_2D);

    // XXX
    String textureName = photo.getPath();

    TextureCoords tc = new TextureCoords(0, 0, 1, 1);
    if (textureName != null) {
      Texture texture = this.textureCacheService.getTexture(gl, textureName);

      //            // switch to texture mode and push a new matrix on the stack
      //            gl.glMatrixMode(GL2.GL_TEXTURE);
      //            gl.glPushMatrix();
      //
      //            // check to see if the texture needs flipping
      //            if (texture.getMustFlipVertically()) {
      //                gl.glScaled(1, -1, 1);
      //                gl.glTranslated(0, -1, 0);
      //            }
      //
      //            // switch to modelview matrix and push a new matrix on the stack
      //            gl.glMatrixMode(GL2.GL_MODELVIEW);
      //            gl.glPushMatrix();
      //
      //            // This is required to repeat textures
      //            gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
      //            gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);

      // enable, bind
      texture.enable(gl);
      texture.bind(gl);

      tc = texture.getImageTexCoords();
    }

    gl.glBegin(GL2.GL_POLYGON);
    //        gl.glColor3f((float)123/256, (float)111/256, (float)100/255);
    //        gl.glColor3f((float) 255/255, (float)255/255, (float)255/255);

    LatLon ll = new LatLon(photo.getLat(), photo.getLon());

    Projection proj = Main.getProjection();

    EastNorth eastNorth = proj.latlon2eastNorth(ll);

    double x = perspective3d.calcX(eastNorth.east());
    double y = photo.getHeight();
    double z = -perspective3d.calcY(eastNorth.north());

    Vector3d angle = photo.getRotate();

    double distance = 500d;

    double width = distance * Math.sin(photo.getAngleWitht() / 2d);
    double height = distance * Math.sin(photo.getAngleHeigth() / 2d);

    Vector3d p1 = new Vector3d(distance, -height, -width);
    Vector3d p2 = new Vector3d(distance, -height, width);
    Vector3d p3 = new Vector3d(distance, height, width);
    Vector3d p4 = new Vector3d(distance, height, -width);

    p1 = transform(angle, p1);
    p2 = transform(angle, p2);
    p3 = transform(angle, p3);
    p4 = transform(angle, p4);

    Point3d c = camera.getPoint();

    // gl.glColor4f((float) 255/255, (float)255/255, (float)255/255, (float) 128/255);
    gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_BLEND);

    gl.glTexCoord2d(tc.left(), tc.bottom());
    gl.glVertex3d(p1.x + x, p1.y + y, p1.z + z);
    gl.glTexCoord2d(tc.right(), tc.bottom());
    gl.glVertex3d(p2.x + x, p2.y + y, p2.z + z);
    gl.glTexCoord2d(tc.right(), tc.top());
    gl.glVertex3d(p3.x + x, p3.y + y, p3.z + z);
    gl.glTexCoord2d(tc.left(), tc.top());
    gl.glVertex3d(p4.x + x, p4.y + y, p4.z + z);

    gl.glEnd();

    gl.glColor3f((float) 0 / 255, (float) 0 / 255, (float) 255 / 255);

    gl.glPushMatrix();

    gl.glTranslated(x, 0.1, z);

    gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);

    DrawUtil.drawDotY(gl, 0.5, 12);
    gl.glPopMatrix();

    if (textureName != null) {
      Texture texture = this.textureCacheService.getTexture(gl, textureName);

      Texture t = this.textureCacheService.getTexture(gl, textureName);
      // this.textures.get(mesh.materialID);// .get(mesh.materialID);
      if (t != null) {
        t.disable(gl);
      }

      gl.glMatrixMode(GL2.GL_TEXTURE);
      gl.glPopMatrix();

      gl.glMatrixMode(GL2.GL_MODELVIEW);
      gl.glPopMatrix();
    }

    gl.glDisable(GL2.GL_TEXTURE_2D);

    gl.glColor4f((float) 255 / 255, (float) 255 / 255, (float) 255 / 255, (float) 255 / 255);

    gl.glDisable(GL2.GL_BLEND);
    gl.glEnable(GL2.GL_DEPTH_TEST);
  }