Hi there ,
if i want to understand some parts of core Jme , is there a good reference for this context , because there are methods/Functions that runs maths & Jme Streams that i cannot understand even a little bit (because i am not a graphical programmer):
for example in this code:
what does this part does ? what are the OutputCapsule & InputCapsule ?
@Override
public void write(JmeExporter ex) throws IOException {
super.write(ex);
OutputCapsule oc = ex.getCapsule(this);
oc.write(lightPosition, "lightPosition", Vector3f.ZERO);
oc.write(nbSamples, "nbSamples", 50);
oc.write(blurStart, "blurStart", 0.02f);
oc.write(blurWidth, "blurWidth", 0.9f);
oc.write(lightDensity, "lightDensity", 1.4f);
oc.write(adaptative, "adaptative", true);
}
@Override
public void read(JmeImporter im) throws IOException {
super.read(im);
InputCapsule ic = im.getCapsule(this);
lightPosition = (Vector3f) ic.readSavable("lightPosition", Vector3f.ZERO);
nbSamples = ic.readInt("nbSamples", 50);
blurStart = ic.readFloat("blurStart", 0.02f);
blurWidth = ic.readFloat("blurWidth", 0.9f);
lightDensity = ic.readFloat("lightDensity", 1.4f);
adaptative = ic.readBoolean("adaptative", true);
}
& from where does these equations generally come from :
@Override
protected void postQueue(RenderQueue queue) {
getClipCoordinates(lightPosition, screenLightPos, viewPort.getCamera());
viewPort.getCamera().getViewMatrix().mult(lightPosition, viewLightPos);
if (adaptative) {
float densityX = 1f - FastMath.clamp(FastMath.abs(screenLightPos.x - 0.5f), 0, 1);
float densityY = 1f - FastMath.clamp(FastMath.abs(screenLightPos.y - 0.5f), 0, 1);
innerLightDensity = lightDensity * densityX * densityY;
} else {
innerLightDensity = lightDensity;
}
display = innerLightDensity != 0.0 && viewLightPos.z < 0;
}
private Vector3f getClipCoordinates(Vector3f worldPosition, Vector3f store, Camera cam) {
float w = cam.getViewProjectionMatrix().multProj(worldPosition, store);
store.divideLocal(w);
store.x = ((store.x + 1f) * (cam.getViewPortRight() - cam.getViewPortLeft()) / 2f + cam.getViewPortLeft());
store.y = ((store.y + 1f) * (cam.getViewPortTop() - cam.getViewPortBottom()) / 2f + cam.getViewPortBottom());
store.z = (store.z + 1f) / 2f;
return store;
}
i am not asking for somethings that are super detailed no … i want a general guide for these core codes or effects plugins in this case if exists hopefully, i hope you understand me .
Thank you !