예제 #1
0
    @Override
    public void updatePosition() {
      double x0 = getXFor(id, lastActive), x1 = getXFor(id, active);
      double dx = MathUtils.lerp(x0, x1, transitProgress);
      double scale;

      if (isFrom()) {
        alpha = MathUtils.lerp(MAX_ALPHA, MIN_ALPHA, transitProgress);
        scale = MathUtils.lerp(MAX_SCALE, MIN_SCALE, transitProgress);
      } else if (isTo()) {
        alpha = MathUtils.lerp(MIN_ALPHA, MAX_ALPHA, transitProgress);
        scale = MathUtils.lerp(MIN_SCALE, MAX_SCALE, transitProgress);
      } else {
        alpha = MIN_ALPHA;
        scale = MIN_SCALE;
      }

      widget.transform.x = dx;
      widget.transform.scale = scale;

      DrawTexture.get(widget).color.a = alpha;
      widget.dirty = true;
    }
예제 #2
0
  @Override
  public void doRender(Entity ent, double x, double y, double z, float a, float b) {
    IRay ray = (IRay) ent;

    GL11.glPushMatrix();

    double length = ray.getLength();
    double fix = ray.getStartFix();

    Vec3 vo;
    if (ray.needsViewOptimize()) vo = ViewOptimize.getFixVector(ray);
    else vo = vec(0, 0, 0);
    // Rotate fix vector to world coordinate
    vo.rotateAroundY(MathUtils.toRadians(270 - ent.rotationYaw));

    Vec3 start = vec(0, 0, 0),
        end = add(start, multiply(new Motion3D(ent, true).getMotionVec(), length));
    start = add(start, vo);

    x += start.xCoord;
    y += start.yCoord;
    z += start.zCoord;

    Vec3 delta = subtract(end, start);
    double dxzsq = delta.xCoord * delta.xCoord + delta.zCoord * delta.zCoord;
    double npitch = MathUtils.toAngle(Math.atan2(delta.yCoord, Math.sqrt(dxzsq)));
    double nyaw = MathUtils.toAngle(Math.atan2(delta.xCoord, delta.zCoord));

    GL11.glTranslated(x, y, z);
    GL11.glRotated(-90 + nyaw, 0, 1, 0);
    GL11.glRotated(npitch, 0, 0, 1);
    GL11.glTranslated(fix, 0, 0);
    draw(ent, ray.getLength() - fix);

    GL11.glPopMatrix();
  }