Пример #1
0
 public void lookThrough() {
   position.setX(position.getX() + velocity.getX());
   position.setY(position.getY() + velocity.getY());
   position.setZ(position.getZ() + velocity.getZ());
   GL11.glRotatef(pitch, 1.0f, 0.0f, 0.0f);
   GL11.glRotatef(yaw, 0.0f, 1.0f, 0.0f);
   GL11.glTranslatef(position.x, position.y, position.z);
 }
Пример #2
0
  public boolean equals(Object obj) {
    if (!obj.getClass().getName().endsWith("Vertex")) {
      return false;
    }

    Vertex otherVert = (Vertex) obj;
    // Compare position
    Vector3f otherPos = otherVert.getPosition();
    if (position.getX() != otherPos.getX()) {
      return false;
    }
    if (position.getY() != otherPos.getY()) {
      return false;
    }
    if (position.getZ() != otherPos.getZ()) {
      return false;
    }
    // Compare Unwrap
    Vector2f otherUnwrap = otherVert.getUnwrap();
    if (unwrap.getX() != otherUnwrap.getX()) {
      return false;
    }
    if (unwrap.getY() != otherUnwrap.getY()) {
      return false;
    }
    // Compare Normal
    boolean hasNormal = hasNormal();
    boolean otherHasNormal = otherVert.hasNormal();
    if (hasNormal != otherHasNormal) {
      return false;
    } // One has normal, the other one doesn't
    if (hasNormal == false) {
      return true;
    } // Since both are same, both don't have a normal
    Vector3f otherNormal = otherVert.getNormal();
    if (normal.getX() != otherNormal.getX()) {
      return false;
    }
    if (normal.getY() != otherNormal.getY()) {
      return false;
    }
    if (normal.getZ() != otherNormal.getZ()) {
      return false;
    }
    // All clear
    return true;
  }
Пример #3
0
  public AbstractEntity(Model m) {

    super(m.getBounds());
    this.m = m;
    Vector3f myMin = b.getMin();
    this.origin = new Vector3f(-myMin.getX(), -myMin.getY(), -myMin.getZ());
    this.angle = 0;
  }
Пример #4
0
  private void setupLightViewMatrix() {

    viewMatrix = new Matrix4f();

    Matrix4f.rotate((float) (Math.PI / 2), new Vector3f(1, 0, 0), viewMatrix, viewMatrix);

    Matrix4f.translate(
        new Vector3f(
            lightSourcePosition.getX(), -lightSourcePosition.getY(), lightSourcePosition.getZ()),
        viewMatrix,
        viewMatrix);
  }
Пример #5
0
  private void setupViewMatrix(boolean reverseY) {

    viewMatrix = new Matrix4f();

    Matrix4f.rotate(
        (reverseY ? -1 : 1) * cameraAngle.getY(), new Vector3f(1, 0, 0), viewMatrix, viewMatrix);

    Matrix4f.rotate(cameraAngle.getX(), new Vector3f(0, 1, 0), viewMatrix, viewMatrix);

    Matrix4f.translate(
        reverseY ? new Vector3f(cameraPos.getX(), -cameraPos.getY(), cameraPos.getZ()) : cameraPos,
        viewMatrix,
        viewMatrix);
  }
Пример #6
0
  @Override
  public void draw() {

    if (m != null) {
      Vector3f min = b.getMin();
      Vector3f max = b.getMax();
      glPushMatrix();
      glTranslatef(origin.getX() + min.x, origin.getY() + min.y, origin.getZ() + min.z);
      glRotatef(angle, 0, 1, 0);
      m.draw();
      glPopMatrix();
      glDisable(GL_CULL_FACE);
      glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
      glBegin(GL_QUADS);

      glVertex3f(min.getX(), min.getY(), min.getZ());
      glVertex3f(max.getX(), min.getY(), min.getZ());
      glVertex3f(max.getX(), max.getY(), min.getZ());
      glVertex3f(min.getX(), max.getY(), min.getZ());

      glVertex3f(min.getX(), min.getY(), max.getZ());
      glVertex3f(max.getX(), min.getY(), max.getZ());
      glVertex3f(max.getX(), max.getY(), max.getZ());
      glVertex3f(min.getX(), max.getY(), max.getZ());

      glVertex3f(min.getX(), min.getY(), min.getZ());
      glVertex3f(min.getX(), min.getY(), max.getZ());
      glVertex3f(min.getX(), max.getY(), max.getZ());
      glVertex3f(min.getX(), max.getY(), min.getZ());

      glVertex3f(max.getX(), min.getY(), min.getZ());
      glVertex3f(max.getX(), min.getY(), max.getZ());
      glVertex3f(max.getX(), max.getY(), max.getZ());
      glVertex3f(max.getX(), max.getY(), min.getZ());

      glVertex3f(max.getX(), min.getY(), min.getZ());
      glVertex3f(min.getX(), min.getY(), min.getZ());
      glVertex3f(min.getX(), min.getY(), max.getZ());
      glVertex3f(max.getX(), min.getY(), max.getZ());

      glVertex3f(max.getX(), max.getY(), min.getZ());
      glVertex3f(min.getX(), max.getY(), min.getZ());
      glVertex3f(min.getX(), max.getY(), max.getZ());
      glVertex3f(max.getX(), max.getY(), max.getZ());

      glEnd();
      glEnable(GL_CULL_FACE);
      glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    }
  }
Пример #7
0
 public float[] getIJK() {
   return new float[] {normal.getX(), normal.getY(), normal.getZ()};
 }
Пример #8
0
 public Vector3f getNormal() {
   return new Vector3f(normal.getX(), normal.getY(), normal.getZ());
 }
Пример #9
0
 public float[] getXYZW() {
   return new float[] {position.getX(), position.getY(), position.getZ(), 1f};
 }
Пример #10
0
 public Vector3f getPosition() {
   return new Vector3f(position.getX(), position.getY(), position.getZ());
 }