private void renderBlast(GL2 gl) {
    GLU glu = new GLU();

    Shader shader = Shader.get("dissolve");
    if (shader != null) {
      shader.enable(gl);

      shader.setSampler(gl, "cloudSampler", 0);
      shader.setUniform(gl, "dissolveFactor", 1.0f - ((float) blastDuration / 60.0f));
    }

    gl.glEnable(GL2.GL_TEXTURE_2D);

    GLUquadric sphere = glu.gluNewQuadric();

    glu.gluQuadricDrawStyle(sphere, GLU.GLU_FILL);
    glu.gluQuadricTexture(sphere, true);

    gl.glPushMatrix();
    {
      noiseSampler.bind(gl);
      noiseSampler.setTexParameterf(gl, GL2.GL_TEXTURE_MAX_ANISOTROPY_EXT, 16);

      gl.glTranslatef(bound.c.x, bound.c.y, bound.c.z);

      glu.gluSphere(sphere, blastRadius, 24, 24);
    }
    gl.glPopMatrix();
  }
  @Override
  public void draw(GL2 gl, Object obj) {
    if (!(Force.class.isAssignableFrom(obj.getClass()))) return;

    Force force = (Force) obj;

    gl.glLineWidth(2.5f);
    gl.glColor3f(1.0f, 0f, 0f);
    gl.glBegin(GL.GL_LINES);
    gl.glVertex3d(
        force.getPointApplication().getX(),
        force.getPointApplication().getY(),
        force.getPointApplication().getZ());

    Vector3D finalPoint = force.getPointApplication().add(force.getForce());
    gl.glVertex3d(finalPoint.getX(), finalPoint.getY(), finalPoint.getZ());
    gl.glEnd();

    gl.glTranslated(
        force.getPointApplication().getX(),
        force.getPointApplication().getY(),
        force.getPointApplication().getZ());
    gl.glColor3f(1.0f, 0.0f, 0.0f);
    GLU glu = new GLU();
    GLUquadric q = glu.gluNewQuadric();
    glu.gluQuadricDrawStyle(q, GLU.GLU_FILL);
    glu.gluSphere(q, Force.originRadius, 5, 5);
    glu.gluDeleteQuadric(q);
  }
Exemple #3
0
  private void renderPin(GL gl, Coordinates position, float[] color, float size) {
    float height = heightmap.getHeight(projection.getGeoCoordinates(position));
    gl.glPushMatrix();
    double[] model = new double[16];
    gl.glGetDoublev(GL_MODELVIEW_MATRIX, model, 0);
    double zoomH =
        0.1 / Math.sqrt((model[0] * model[0]) + (model[1] * model[1]) + (model[2] * model[2]));
    double zoomZ =
        0.1 / Math.sqrt((model[8] * model[8]) + (model[9] * model[9]) + (model[10] * model[10]));
    gl.glTranslatef(position.getLongitude(), position.getLatitude(), height);
    gl.glScaled(zoomH * size, zoomH * size, zoomZ * size);
    gl.glDisable(GL_TEXTURE_2D);

    gl.glRotatef(20, 0.3f, 1, 0);

    GLU glu = new GLU();
    GLUquadric quadric = glu.gluNewQuadric();
    // glu.gluQuadricNormals(quadric, GLU.GLU_FLAT);
    gl.glColor3f(0.5f, 0.5f, 0.5f);
    gl.glEnable(GL_LIGHTING);
    glu.gluCylinder(quadric, 0.03, 0.03, 0.6f, 5, 1);
    gl.glTranslatef(0, 0, 0.6f);

    gl.glColor3f(color[0], color[1], color[2]);
    gl.glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
    glu.gluSphere(quadric, 0.12, 8, 8);
    // glu.gluCylinder(quadric, 0.2, 0.1, 0.5, 8, 1);
    gl.glDisable(GL_LIGHTING);
    glu.gluDeleteQuadric(quadric);
    gl.glPopMatrix();
  }
Exemple #4
0
  /** Draws a canonical circular particle. */
  private static void drawParticle(GL gl, Point3d p, double r) {
    double radius = r;

    double vectorY1 = p.y;
    double vectorX1 = p.x;
    double vectorZ1 = p.z;

    GLU glu = new GLU();
    GLUquadric quadratic = glu.gluNewQuadric();
    glu.gluQuadricNormals(quadratic, GLU.GLU_SMOOTH);
    glu.gluQuadricTexture(quadratic, true);

    gl.glPushMatrix();
    gl.glTranslated(p.x, p.y, p.z);
    glu.gluSphere(quadratic, radius, 12, 12);
    gl.glPopMatrix();
  }
Exemple #5
0
 @Override
 public void display(GLAutoDrawable dr) {
   GL2 gl = dr.getGL().getGL2();
   // Очиска экрана
   gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
   // Загрузка единичной матрицы
   gl.glLoadIdentity();
   // Определение точки и направления взгляда
   glu.gluLookAt(0f, 0f, 10f, 0f, 0f, -100f, 0f, 1f, 0f);
   // Загрузка текстуры в графическую память
   this.texture.bind(gl);
   GLUquadric ground = glu.gluNewQuadric();
   // enabling texturing on the quadric
   glu.gluQuadricTexture(ground, true);
   glu.gluSphere(ground, 1, 64, 64);
   glu.gluDeleteQuadric(ground);
 }