System.err.println("translate " + translate.get(0) + ", " + translate.get(1));
}
} else {
translate = BufferIO._wrapd(new double[]{0, 0});
}
DoubleBuffer eqr = null, eqEye = null;
DoubleBuffer rotationFX = null, rotationFX_mirror = null;
if ((transform & GLHandler._GL_TRANSFORM_ROTATE_BIT) != 0 && rotate != null) {
rotate = BufferIO._wrapd(new double[]{rotate.get(0), 0, 0});
if (isDebugEnabled()) {
System.err.println("rotate " + rotate.get(0));
}
} else {
rotate = BufferIO._wrapd(new double[]{0, 0, 0});
}
rotationFX = rotationFX_mirror = rotate;
FloatBuffer colorBlend = fx_color != null ? BufferIO._wrapf(fx_color.getRGBComponents(new float[4])) : null;
FloatBuffer alphaBlend = BufferIO._wrapf(new float[]{1, 1, 1, 1});
long now = System.currentTimeMillis();
final Rectangle fxBounds = texBounds.getBounds();
Rectangle backgroundClip = new Rectangle(Math.round((float) gld._GLZRatio(z) * gld.getWidth()), Math.round((float) gld._GLZRatio(z) * gld.getHeight()));
backgroundClip.setLocation(-Math.round(.5f * (backgroundClip.width - gld.getWidth())), -Math.round(.5f * (backgroundClip.height - gld.getHeight())));
/**
* retrieve all fx enum fields
*/
fx &= gfx._FX.bitRangeFields() | gfx._FX_EXT.bitRangeFields() | gfx._FX_ORIENT.bitRangeFields() | gfx._FX_PASS.bitRangeFields();
/*
*
*/
if (fx != gfx.FX_NONE) {
if (isDebugEnabled()) {
System.err.print("GLFX ");
for (gfx select : gfx.values()) {
if ((select.bit() & fx) != 0) {
System.err.print("fx " + select.toString());
}
}
System.err.println();
}
}
/**
* OVERALL FX SETTINGS SCROLLING
*/
if ((fx & gfx.FX_SCROLLING.bit()) != 0) {
if (!(FX_lastTransformScrolling.get(mySp.getUID()) instanceof AffineTransform)) {
FX_lastTransformScrolling.put(mySp.getUID(), new AffineTransform());
}
if (!(FX_lastTransformTime.get(mySp.getUID()) instanceof Long)) {
FX_lastTransformTime.put(mySp.getUID(), now);
}
double translateH, translateV;
translateH = (fx & gfx.FX_HORIZONTAL.bit()) != 0 ? FX_overallSPEED * (now - FX_lastTransformTime.get(mySp.getUID())) : 0f;
translateV = (fx & gfx.FX_VERTICAL.bit()) != 0 ? FX_overallSPEED * (now - FX_lastTransformTime.get(mySp.getUID())) : 0f;
FX_lastTransformScrolling.get(mySp.getUID()).setToTranslation(-((Math.abs(FX_lastTransformScrolling.get(mySp.getUID()).getTranslateX()) + translateH) % -texBounds.width), -((Math.abs(FX_lastTransformScrolling.get(mySp.getUID()).getTranslateY()) + translateV) % texBounds.height));
fx_tx.preConcatenate(FX_lastTransformScrolling.get(mySp.getUID()));
fx_tx_mirror.preConcatenate(FX_lastTransformScrolling.get(mySp.getUID()));
FX_lastTransformTime.put(mySp.getUID(), now);
}
/**
* OVERALL FX SETTINGS ROTATION
*/
if ((fx & gfx.FX_ROTATION.bit()) != 0) {
if (!(FX_lastTransformTime.get(mySp.getUID()) instanceof Long)) {
FX_lastTransformTime.put(mySp.getUID(), now);
}
float lastTransformTheta = FX_lastTransformTheta.containsKey(mySp.getUID()) ? FX_lastTransformTheta.get(mySp.getUID()) : (1f - 1f / 360f) * 360f;
float rotationSpeed = FX_overallRADIALSPEED * 360f / (2f * (float) Math.PI);
if ((fx - (fx & (bits._getAllBits() | bits._getAllBitRanges()))) != 0) {
rotationSpeed = fx - (fx & (bits._getAllBits() | bits._getAllBitRanges()));
rotationSpeed /= 1000f;
}
lastTransformTheta -= (float) (now - FX_lastTransformTime.get(mySp.getUID())) * rotationSpeed;
lastTransformTheta = lastTransformTheta % 360f;
FX_lastTransformTheta.put(mySp.getUID(), lastTransformTheta);
FX_lastTransformTime.put(mySp.getUID(), now);
rotationFX = BufferIO._wrapd(new double[]{lastTransformTheta, texBounds.getCenterX(), texBounds.getCenterY()});
rotationFX_mirror = rotationFX;
}
/**
* OVERALL FX SETTINGS REFLEXION
*/
if ((fx & gfx.FX_REFLEXION.bit()) != 0) {
assert (fx & (gfx.FX_TOP.bit() | gfx.FX_BOTTOM.bit() | gfx.FX_LEFT.bit() | gfx.FX_RIGHT.bit())) != 0 : "no orientation defined FX_BOTTOM, TOP etc.";
if ((fx & (gfx.FX_1ST_PASS.bit() | gfx.FX_2ND_PASS.bit())) != 0) {
if ((fx & (gfx.FX_TOP.bit() | gfx.FX_BOTTOM.bit())) != 0) {
fx_tx_mirror.scale(1., -1.);
/*
* Clip Plane Equations
*/
if ((fx & gfx.FX_BOTTOM.bit()) != 0) {
eqr = BufferIO._wrapd(new double[]{0.0f, 1, 0.0f, -(fx_loc.y)});
eqEye = RenderingSceneGL._GL_getLookAt_plane(gld.getSize(), gld.getZDepth(), BufferIO._wrapf(new float[]{0, 1, 0}));
} else {
eqr = BufferIO._wrapd(new double[]{0.0f, -1, 0.0f, -(fx_loc.y)});
eqEye = RenderingSceneGL._GL_getLookAt_plane(gld.getSize(), gld.getZDepth(), BufferIO._wrapf(new float[]{0, -1, 0}));
}
fx_tx_mirror.translate(0, -2. * eqr.get(3));
}
if ((fx & (gfx.FX_LEFT.bit() | gfx.FX_RIGHT.bit())) != 0) {
fx_tx_mirror.scale(-1., 1.);
/*
* Clip Plane Equations
*/
if ((fx & gfx.FX_RIGHT.bit()) != 0) {
eqr = BufferIO._wrapd(new double[]{1, 0f, 0.0f, -(fx_loc.x)});
eqEye = RenderingSceneGL._GL_getLookAt_plane(gld.getSize(), gld.getZDepth(), BufferIO._wrapf(new float[]{1, 0, 0}));
} else {
eqr = BufferIO._wrapd(new double[]{-1, 0f, 0.0f, -(fx_loc.x)});
eqEye = RenderingSceneGL._GL_getLookAt_plane(gld.getSize(), gld.getZDepth(), BufferIO._wrapf(new float[]{-1, 0, 0}));
}
fx_tx_mirror.translate(-2. * eqr.get(3), 0);
}
} else {
if ((fx & (gfx.FX_TOP.bit() | gfx.FX_BOTTOM.bit())) != 0) {
/*
* Clip Plane Equations
*/
if ((fx & gfx.FX_BOTTOM.bit()) != 0) {
eqr = BufferIO._wrapd(new double[]{0.0f, -1, 0.0f, (fx_loc.y)});
} else {
eqr = BufferIO._wrapd(new double[]{0.0f, 1, 0.0f, (fx_loc.y)});
}
}
if ((fx & (gfx.FX_LEFT.bit() | gfx.FX_RIGHT.bit())) != 0) {
/*
* Clip Plane Equations
*/
if ((fx & gfx.FX_RIGHT.bit()) != 0) {
eqr = BufferIO._wrapd(new double[]{-1, 0f, 0.0f, (fx_loc.x)});
} else {
eqr = BufferIO._wrapd(new double[]{1, 0f, 0.0f, (fx_loc.x)});
}
}
}
/**
* FX SETTINGS SHADOW
*/
} else if ((fx & gfx.FX_SHADOW.bit()) != 0) {
assert (fx & (gfx.FX_TOP.bit() | gfx.FX_BOTTOM.bit() | gfx.FX_LEFT.bit() | gfx.FX_RIGHT.bit())) != 0 : "no orientation defined FX_BOTTOM, TOP etc.";
if ((fx & (gfx.FX_TOP.bit() | gfx.FX_BOTTOM.bit())) != 0) {
/*
* Clip Plane Equations
*/
if ((fx & gfx.FX_BOTTOM.bit()) != 0) {
eqr = BufferIO._wrapd(new double[]{0.0f, 1, 0.0f, -fx_loc.y});
} else {
eqr = BufferIO._wrapd(new double[]{0.0f, -1, 0.0f, -fx_loc.y});
}
}
if ((fx & (gfx.FX_LEFT.bit() | gfx.FX_RIGHT.bit())) != 0) {
/*
* Clip Plane Equations
*/
if ((fx & gfx.FX_RIGHT.bit()) != 0) {
eqr = BufferIO._wrapd(new double[]{1, 0f, 0.0f, -fx_loc.x});
} else {
eqr = BufferIO._wrapd(new double[]{-1, 0f, 0.0f, -fx_loc.x});
}
}
}
/**
* FX GL BLOCK begin
*/
boolean fxPushBlockInit = !_fxPushBlock.isOn();
if (fxPushBlockInit) {
_fxPushBlock.begin();
GLHandler._GLpushAttrib(GL11.GL_ENABLE_BIT);
}
Util.checkGLError();
/**
* 1ST AND 2ND PASSES
*/
if ((fx & (gfx.FX_1ST_PASS.bit() | gfx.FX_2ND_PASS.bit())) != 0) {
if ((fx & gfx.FX_1ST_PASS.bit()) != 0) {
if ((fx & gfx.FX_REFLEXION.bit()) != 0) {
GL11.glEnable(GL11.GL_CLIP_PLANE0);
GL11.glClipPlane(GL11.GL_CLIP_PLANE0, eqr);
GL11.glEnable(GL11.GL_CLIP_PLANE1);
GL11.glClipPlane(GL11.GL_CLIP_PLANE1, eqEye);
GL11.glDisable(GL11.GL_DEPTH_TEST);
Util.checkGLError();
}
}
if ((fx & gfx.FX_2ND_PASS.bit()) != 0) {
if ((fx & gfx.FX_SHADOW.bit()) != 0) {
GLHandler.stView.push();
/**
* column-major matrix to cast shadows onto the selected
* plane
*/
DoubleBuffer shadowCasting = BufferIO._wrapd(new double[]{-eqr.get(3), 0, 0, eqr.get(0), 0, -eqr.get(3), 0, eqr.get(1), 0, 0, -eqr.get(3), eqr.get(2), 0, 0, 0, 0});
GL11.glMultMatrix(shadowCasting);
/**
* translate to make the light source 0,0,0,1
*/
FloatBuffer lightPos = BufferIO._newf(4);