@Property(category = PropertyCategory.SECONDARY, description = "intensity of the light")
private double intensity;
@Override
protected void performPixelTransformation(WFImage pImg) {
SimpleImage img = (SimpleImage) pImg;
int intensity = (int) (this.intensity * (double) VPREC + 0.5);
int amount = (int) (this.amount * (double) VPREC + 0.5);
int left = this.left;
int top = this.top;
int width = pImg.getImageWidth();
int height = pImg.getImageHeight();
Buffer heightMapBuffer = this.heightMap;
SimpleImage heightMap = heightMapBuffer.getImage();
int bwidth = heightMap.getImageWidth();
int bheight = heightMap.getImageHeight();
/* compute the light-vector */
int plCosA, lvx, lvy, lvz;
{
double lx = 0.0 - (double) lightX;
double ly = 0.0 - (double) lightY;
double lz = (double) 0.0 - (double) lightZ;
double r = Math.sqrt(lx * lx + ly * ly + lz * lz);
if (r != (float) 0.0) {
lx /= r;
ly /= r;
lz /= r;
}
else {
lx = (double) 0.0;
ly = (double) 0.0;
lz = (double) 1.0;
}
lvx = (int) (lx * (double) VPREC + 0.5);
lvy = (int) (ly * (double) VPREC + 0.5);
lvz = (int) (lz * (double) VPREC + 0.5);
int nz = 0 - VPREC;
int nx = 0;
int ny = 0;
plCosA = ((lvx * nx + VPREC2) >> SPREC) + ((lvy * ny + VPREC2) >> SPREC)
+ ((lvz * nz + VPREC2) >> SPREC);
plCosA = (plCosA * intensity + VPREC2) >> SPREC;
if (plCosA < 0)
plCosA = 0 - plCosA;
else
plCosA = 0;
}
int x1 = -VPREC;
int y1 = -VPREC;
int x2 = VPREC;
int y2 = -VPREC;
int x3 = -VPREC;
int y3 = VPREC;
int x4 = VPREC;
int y4 = VPREC;
int x5 = 0;
int y5 = 0;
int a1x = x5 - x1;
int a1y = y5 - y1;
int b1x = x5 - x2;
int b1y = y5 - y2;
int a2x = x5 - x2;
int a2y = y5 - y2;
int b2x = x5 - x4;
int b2y = y5 - y4;
int a3x = x5 - x4;
int a3y = y5 - y4;
int b3x = x5 - x3;
int b3y = y5 - y3;
int a4x = x5 - x3;
int a4y = y5 - y3;
int b4x = x5 - x1;
int b4y = y5 - y1;
Pixel sPixel = new Pixel();
Pixel hPixel = new Pixel();
Pixel hLUPixel = new Pixel();
Pixel hRUPixel = new Pixel();
Pixel hLBPixel = new Pixel();
Pixel hRBPixel = new Pixel();
for (int i = 0; i < height; i++) {
int biy = i - top;
for (int j = 0; j < width; j++) {
int bix = j - left;
int z1, z2, z3, z4, z5;
if ((bix >= 0) && (bix < bwidth) && (biy >= 0) && (biy < bheight)) {
hPixel.setARGBValue(heightMap.getARGBValue(bix, biy));
hLUPixel.setARGBValue(heightMap.getARGBValueIgnoreBounds(bix - 1, biy - 1));
hRUPixel.setARGBValue(heightMap.getARGBValueIgnoreBounds(bix + 1, biy - 1));
hLBPixel.setARGBValue(heightMap.getARGBValueIgnoreBounds(bix - 1, biy + 1));
hRBPixel.setARGBValue(heightMap.getARGBValueIgnoreBounds(bix + 1, biy + 1));
z5 = 0 - ((int) (hPixel.r) << SPREC) / 255;
if (biy > 0) {
if (bix > 0)
z1 = 0 - ((int) (hLUPixel.r) << SPREC) / 255;