@Override public Vec3f getMin(Vec3f min) { if (min == null) { min = new Vec3f(); } min.x = minX; min.y = minY; min.z = 0.0f; return min; }
@Override public Vec3f getMax(Vec3f max) { if (max == null) { max = new Vec3f(); } max.x = maxX; max.y = maxY; max.z = 0.0f; return max; }
public int generateBumpPixel(BufferedImage image, int x, int y, float a) { Vec3f S = new Vec3f(); Vec3f T = new Vec3f(); Vec3f N = new Vec3f(); S.x = 1; S.y = 0; S.z = a * getHeight(image, x + 1, y) - a * getHeight(image, x - 1, y); T.x = 0; T.y = 1; T.z = a * getHeight(image, x, y + 1) - a * getHeight(image, x, y - 1); float den = (float) Math.sqrt(S.z * S.z + T.z * T.z + 1); N.x = -S.z; N.y = -T.z; N.z = 1; N.divideLocal(den); return vectorToColor(N.x, N.y, N.z); }