@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);
  }
Ejemplo n.º 2
0
  /** ***************************************************** */
  public void draw(GL2 gl, GLU glu, Camera cam) {
    if (transform != null) transform.execute(gl);
    gl.glTranslatef(x, y, z);

    applyMaterial(gl);
    gl.glLineWidth(wfwidth);

    // Draw
    GLUquadric qobj = glu.gluNewQuadric();

    if (facestatus) {
      if (wfstatus) {
        gl.glEnable(GL2.GL_POLYGON_OFFSET_FILL);
        gl.glPolygonOffset(1.0f, 1.0f);
      }

      gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL);
      gl.glNormal3f(norm.x, norm.y, norm.z);
      gl.glColor4f(color.r, color.g, color.b, color.a);
      glu.gluDisk(qobj, radiusInner, radiusOuter, slices, loops);

      if (wfstatus) gl.glDisable(GL2.GL_POLYGON_OFFSET_FILL);
    }
    if (wfstatus) {
      gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
      gl.glNormal3f(norm.x, norm.y, norm.z);
      gl.glColor4f(wfcolor.r, wfcolor.g, wfcolor.b, wfcolor.a);
      glu.gluDisk(qobj, radiusInner, radiusOuter, slices, loops);
    }
  }
Ejemplo n.º 3
0
  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();
  }
Ejemplo n.º 4
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();
  }
Ejemplo n.º 5
0
  @Override
  public void drawCD(double internalRadius, double externalRadius, int slices, int rings) {
    GLUquadric quadratic = glu.gluNewQuadric();

    glu.gluDisk(
        quadratic, Math.max(internalRadius * scaleX, 1), externalRadius * scaleX, slices, rings);

    glu.gluDeleteQuadric(quadratic);
  }
Ejemplo n.º 6
0
 public void render(GLAutoDrawable drawable) {
   GL2 gl = drawable.getGL().getGL2();
   gl.glPushMatrix();
   gl.glTranslated(
       body.getPosition().get0(), body.getPosition().get1(), body.getPosition().get2());
   GLUquadric bulletGeom = glu.gluNewQuadric();
   glu.gluQuadricDrawStyle(bulletGeom, GLU.GLU_FILL);
   glu.gluQuadricNormals(bulletGeom, GLU.GLU_SMOOTH);
   glu.gluDisk(bulletGeom, 0.3, 0.4, 5, 5);
   gl.glPopMatrix();
 }
Ejemplo n.º 7
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();
  }
Ejemplo n.º 8
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);
 }
Ejemplo n.º 9
0
 public BaconTable(GLU glu) {
   quadric = glu.gluNewQuadric();
   glu.gluQuadricDrawStyle(quadric, GLU.GLU_FILL); // GLU_POINT, GLU_LINE, GLU_FILL, GLU_SILHOUETTE
   glu.gluQuadricNormals(quadric, GLU.GLU_NONE); // GLU_NONE, GLU_FLAT, or GLU_SMOOTH
   glu.gluQuadricTexture(quadric, true); // false, or true to generate texture coordinates
 }