예제 #1
0
  /** paint the portal using gl. */
  public void paint(GL gl, GLDrawable glc) {

    if (fill != null) {
      setColor(gl, fill);
      gl.glDisable(GL.GL_TEXTURE_2D);
    }
    gl.glLineWidth(lineWidth());
    gl.glBegin(GL.GL_LINES); // draw each wall
    for (int i = 0; i < pts2d.size(); i++) {
      Point2D p = (Point2D) (pts2d.get(i));
      gl.glVertex2d(p.x, p.y);
    }
    gl.glEnd();

    if (pts2d.size() == 4) {
      /* Connect mid point of the two line segments with dotted line*/
      gl.glLineStipple(1, (short) 0x0F0F);
      gl.glEnable(GL.GL_LINE_STIPPLE);
      gl.glLineWidth(1);
      gl.glBegin(GL.GL_LINES);
      Point2D mid = pts2d.get(0).interp(pts2d.get(1), 0.5);
      gl.glVertex2d(mid.x, mid.y);
      mid = pts2d.get(2).interp(pts2d.get(3), 0.5);
      gl.glVertex2d(mid.x, mid.y);
      gl.glEnd();
      gl.glDisable(GL.GL_LINE_STIPPLE);
    }
  }
예제 #2
0
파일: Line3D.java 프로젝트: blickly/ptii
  public void fire() throws IllegalActionException {
    if (_debugging) {
      _debug("Called fire()");
    }

    ArrayToken lineStartToken = ((ArrayToken) lineStart.getToken());
    ArrayToken lineEndToken = ((ArrayToken) lineEnd.getToken());
    ArrayToken rgbColorValue = ((ArrayToken) rgbColor.getToken());
    DoubleToken widthValue = (DoubleToken) width.getToken();

    GL gl = ((GRODirector) getDirector()).getGL();

    gl.glLineWidth((float) widthValue.doubleValue());
    gl.glBegin(GL.GL_LINES);

    gl.glColor3d(
        ((DoubleToken) rgbColorValue.getElement(0)).doubleValue(),
        ((DoubleToken) rgbColorValue.getElement(1)).doubleValue(),
        ((DoubleToken) rgbColorValue.getElement(2)).doubleValue());

    // origin of the line
    gl.glVertex3d(
        ((DoubleToken) lineStartToken.getElement(0)).doubleValue(),
        ((DoubleToken) lineStartToken.getElement(1)).doubleValue(),
        ((DoubleToken) lineStartToken.getElement(2)).doubleValue());

    // ending point of the line
    gl.glVertex3d(
        ((DoubleToken) lineEndToken.getElement(0)).doubleValue(),
        ((DoubleToken) lineEndToken.getElement(1)).doubleValue(),
        ((DoubleToken) lineEndToken.getElement(2)).doubleValue());

    gl.glEnd();
  }
예제 #3
0
파일: GOut.java 프로젝트: krvd/hnh_union
 public void line(Coord c1, Coord c2, double w) {
   texsel(-1);
   gl.glLineWidth((float) w);
   gl.glBegin(GL.GL_LINES);
   glcolor();
   vertex(c1);
   vertex(c2);
   gl.glEnd();
   checkerr();
 }
예제 #4
0
 private void drawLine(GL gl, float size, Node[] line) {
   gl.glLineWidth(size);
   gl.glPointSize(size);
   gl.glBegin(GL.GL_LINE_STRIP);
   for (Node pos : line) {
     drawVertex(gl, getLocalCoordinates(pos.getPos()));
   }
   gl.glEnd();
   gl.glBegin(GL.GL_POINTS);
   for (Node pos : line) {
     drawVertex(gl, getLocalCoordinates(pos.getPos()));
   }
   gl.glEnd();
 }
예제 #5
0
  public void display(GLCanvas canvas) {
    GL gl = canvas.getGL();

    //
    // render the simulation
    //
    try {
      sim.update();
    } catch (Exception e) {
      Log.println("[Editor] exception in simulation update/calculate paths: " + e.getMessage());
      e.printStackTrace();
    }
    renderer.render(sim, canvas);

    //
    // render the grid
    //
    gl.glColor4f(0.4f, 0.4f, 0.4f, 0.4f);
    gl.glEnable(GL.GL_BLEND);
    gl.glBegin(GL.GL_LINES);
    for (int x = 0; x < 100; x++) {
      gl.glVertex2f(
          -50 * Constants.PLANET_MAX_SIZE * 4 + x * Constants.PLANET_MAX_SIZE * 4,
          -50 * Constants.PLANET_MAX_SIZE * 4);
      gl.glVertex2f(
          -50 * Constants.PLANET_MAX_SIZE * 4 + x * Constants.PLANET_MAX_SIZE * 4,
          50 * Constants.PLANET_MAX_SIZE * 4);
    }

    for (int x = 0; x < 100; x++) {
      gl.glVertex2f(
          -50 * Constants.PLANET_MAX_SIZE * 4,
          -50 * Constants.PLANET_MAX_SIZE * 4 + x * Constants.PLANET_MAX_SIZE * 4);
      gl.glVertex2f(
          +50 * Constants.PLANET_MAX_SIZE * 4,
          -50 * Constants.PLANET_MAX_SIZE * 4 + x * Constants.PLANET_MAX_SIZE * 4);
    }
    gl.glDisable(GL.GL_BLEND);
    gl.glEnd();

    //
    // render rectangle selection
    //
    if (drag_start != null && drag_end != null && selected_planets.size() == 0) {
      gl.glLineWidth(2);
      gl.glColor4f(1, 1, 1, 1);
      Widget.renderOutlinedQuad(
          drag_start.x, drag_start.y, drag_end.x - drag_start.x, -(drag_end.y - drag_start.y));
      gl.glLineWidth(1);
    }

    //
    // render reference system
    //
    gl.glColor3f(1, 1, 1);
    gl.glBegin(GL.GL_LINES);
    gl.glColor3f(1, 0, 0);
    gl.glVertex2f(Constants.PLANET_MAX_SIZE * 50, 0);
    gl.glVertex2f(-Constants.PLANET_MAX_SIZE * 50, 0);
    gl.glColor3f(0, 1, 0);
    gl.glVertex2f(0, Constants.PLANET_MAX_SIZE * 50);
    gl.glVertex2f(0, -Constants.PLANET_MAX_SIZE * 50);
    gl.glEnd();

    try {
      Thread.sleep(5);
    } catch (InterruptedException e) {
    }

    //
    // check mouse over planet
    //
    if (sim.getPlanet(
                renderer.getCamera().getScreenToWorldX(mouse_pos.x),
                renderer.getCamera().getScreenToWorldY(mouse_pos.y))
            != null
        && !this.wasGuiIntersected(mouse_pos.x, mouse_pos.y)
        && drag_start != null) for (WorldAlignementContainer cont : conts) cont.setVisible(false);
    else for (WorldAlignementContainer cont : conts) cont.setVisible(true);
  }
예제 #6
0
  /** ******************************************************************* */
  public void draw(GL gl, GLU glu, Camera cam) {
    doTransform(gl, glu, cam);

    applyMaterial(gl); // TODO: shall we avoid calling this @ each draw?
    Coord3d norm = Normal.compute(points.get(0).xyz, points.get(1).xyz, points.get(2).xyz);

    // Draw content of polygon

    if (gl.isGL2()) {

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

        gl.getGL2().glBegin(GL2.GL_POLYGON);
        for (Point p : points) {
          if (mapper != null) {
            Color c = mapper.getColor(p.xyz); // TODO: should store
            // result in the
            // point color
            gl.getGL2().glColor4f(c.r, c.g, c.b, c.a);
          } else gl.getGL2().glColor4f(p.rgb.r, p.rgb.g, p.rgb.b, p.rgb.a);
          gl.getGL2().glVertex3f(p.xyz.x, p.xyz.y, p.xyz.z);
          gl.getGL2().glNormal3f(norm.x, norm.y, norm.z);
        }
        gl.getGL2().glEnd();
        if (wfstatus) gl.glDisable(GL2.GL_POLYGON_OFFSET_FILL);
      }

      // Draw edge of polygon
      if (wfstatus) {
        gl.getGL2().glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);

        gl.glEnable(GL2.GL_POLYGON_OFFSET_FILL);
        gl.glPolygonOffset(1.0f, 1.0f);

        gl.getGL2().glColor4f(wfcolor.r, wfcolor.g, wfcolor.b, 1); // wfcolor.a);
        gl.glLineWidth(wfwidth);

        gl.getGL2().glBegin(GL2.GL_POLYGON);
        for (Point p : points) {
          gl.getGL2().glVertex3f(p.xyz.x, p.xyz.y, p.xyz.z);
          gl.getGL2().glNormal3f(norm.x, norm.y, norm.z);
        }
        gl.getGL2().glEnd();
        gl.glDisable(GL2.GL_POLYGON_OFFSET_FILL);
      }
    } else {

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

        GLES2CompatUtils.glBegin(GL2.GL_POLYGON);
        for (Point p : points) {
          if (mapper != null) {
            Color c = mapper.getColor(p.xyz); // TODO: should store
            // result in the
            // point color
            GLES2CompatUtils.glColor4f(c.r, c.g, c.b, c.a);
          } else GLES2CompatUtils.glColor4f(p.rgb.r, p.rgb.g, p.rgb.b, p.rgb.a);
          GLES2CompatUtils.glVertex3f(p.xyz.x, p.xyz.y, p.xyz.z);
          GLES2CompatUtils.glNormal3f(norm.x, norm.y, norm.z);
        }
        GLES2CompatUtils.glEnd();
        if (wfstatus) gl.glDisable(GL2.GL_POLYGON_OFFSET_FILL);
      }

      // Draw edge of polygon
      if (wfstatus) {
        GLES2CompatUtils.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);

        gl.glEnable(GL2.GL_POLYGON_OFFSET_FILL);
        gl.glPolygonOffset(1.0f, 1.0f);

        GLES2CompatUtils.glColor4f(wfcolor.r, wfcolor.g, wfcolor.b, 1); // wfcolor.a);
        gl.glLineWidth(wfwidth);

        GLES2CompatUtils.glBegin(GL2.GL_POLYGON);
        for (Point p : points) {
          GLES2CompatUtils.glVertex3f(p.xyz.x, p.xyz.y, p.xyz.z);
          GLES2CompatUtils.glNormal3f(norm.x, norm.y, norm.z);
        }
        GLES2CompatUtils.glEnd();
        gl.glDisable(GL2.GL_POLYGON_OFFSET_FILL);
      }
    }

    /*
     * // Drawbarycenter Point b = new Point(getBarycentre(), Color.BLUE);
     * b.setWidth(5); b.draw(gl,glu,cam);
     */

  }