コード例 #1
0
  @Override
  public boolean gluProject(
      float objX,
      float objY,
      float objZ,
      float[] model,
      int modelOffset,
      float[] project,
      int projectOffset,
      int[] view,
      int viewOffset,
      float[] win,
      int winOffset) {
    modelb.clear();
    modelb.put(model, modelOffset, 16);
    projectb.clear();
    projectb.put(project, projectOffset, 16);
    viewb.clear();
    viewb.put(view, viewOffset, 4);
    winb.clear();

    boolean result =
        org.lwjgl.util.glu.GLU.gluProject(objX, objY, objZ, modelb, projectb, viewb, winb);
    win[winOffset] = winb.get(0);
    win[winOffset + 1] = winb.get(1);
    win[winOffset + 2] = winb.get(2);
    return result;
  }
コード例 #2
0
ファイル: BrainModel.java プロジェクト: nahid204/VisUserStudy
  public Point2D[] project(
      int tube, float[] modelMatrix, float[] projectionMatrix, int[] viewport, int step) {
    GLU glu = new GLU();

    FloatBuffer modelbuf = BufferUtils.createFloatBuffer(16);
    modelbuf.put(modelMatrix);
    modelbuf.rewind();
    FloatBuffer projbuf = BufferUtils.createFloatBuffer(16);
    projbuf.put(projectionMatrix);
    projbuf.rewind();
    IntBuffer viewportbuf = BufferUtils.createIntBuffer(4);
    viewportbuf.put(viewport);
    viewportbuf.rewind();

    Point2D[] projectedSegments =
        new Point2D[(int) Math.ceil(tubes[tube].segments.length / (double) step)];

    int cnt = 0;
    for (int j = 0; j < tubes[tube].segments.length; j = j + step) {
      FloatBuffer result = BufferUtils.createFloatBuffer(3);

      glu.gluProject(
          tubes[tube].segments[j].x,
          tubes[tube].segments[j].y,
          tubes[tube].segments[j].z,
          modelbuf,
          projbuf,
          viewportbuf,
          result);

      Point2D p = new Point2D.Double(result.get(0), viewport[3] - result.get(1) - 1);

      projectedSegments[cnt++] = p;
    }

    return projectedSegments;
  }