use of com.jme3.renderer.Renderer in project jmonkeyengine by jMonkeyEngine.
the class BasicShadowRenderer method postQueue.
public void postQueue(RenderQueue rq) {
for (Spatial scene : viewPort.getScenes()) {
ShadowUtil.getGeometriesInCamFrustum(scene, viewPort.getCamera(), ShadowMode.Receive, lightReceivers);
}
// update frustum points based on current camera
Camera viewCam = viewPort.getCamera();
ShadowUtil.updateFrustumPoints(viewCam, viewCam.getFrustumNear(), viewCam.getFrustumFar(), 1.0f, points);
Vector3f frustaCenter = new Vector3f();
for (Vector3f point : points) {
frustaCenter.addLocal(point);
}
frustaCenter.multLocal(1f / 8f);
// update light direction
shadowCam.setProjectionMatrix(null);
shadowCam.setParallelProjection(true);
// shadowCam.setFrustumPerspective(45, 1, 1, 20);
shadowCam.lookAtDirection(direction, Vector3f.UNIT_Y);
shadowCam.update();
shadowCam.setLocation(frustaCenter);
shadowCam.update();
shadowCam.updateViewProjection();
// render shadow casters to shadow map
ShadowUtil.updateShadowCamera(viewPort, lightReceivers, shadowCam, points, shadowOccluders, shadowMapSize);
if (shadowOccluders.size() == 0) {
noOccluders = true;
return;
} else {
noOccluders = false;
}
Renderer r = renderManager.getRenderer();
renderManager.setCamera(shadowCam, false);
renderManager.setForcedMaterial(preshadowMat);
r.setFrameBuffer(shadowFB);
r.clearBuffers(true, true, true);
viewPort.getQueue().renderShadowQueue(shadowOccluders, renderManager, shadowCam, true);
r.setFrameBuffer(viewPort.getOutputFrameBuffer());
renderManager.setForcedMaterial(null);
renderManager.setCamera(viewCam, false);
}
use of com.jme3.renderer.Renderer in project jmonkeyengine by jMonkeyEngine.
the class PssmShadowRenderer method displayShadowMap.
//debug only : displays depth shadow maps
protected void displayShadowMap(Renderer r) {
Camera cam = viewPort.getCamera();
renderManager.setCamera(cam, true);
int h = cam.getHeight();
for (int i = 0; i < dispPic.length; i++) {
dispPic[i].setPosition((128 * i) + (150 + 64 * (i + 1)), h / 20f);
dispPic[i].setWidth(128);
dispPic[i].setHeight(128);
dispPic[i].updateGeometricState();
renderManager.renderGeometry(dispPic[i]);
}
renderManager.setCamera(cam, false);
}
use of com.jme3.renderer.Renderer in project jmonkeyengine by jMonkeyEngine.
the class OGLESContext method initInThread.
protected void initInThread() {
created.set(true);
logger.fine("OGLESContext create");
logger.log(Level.FINE, "Running on thread: {0}", Thread.currentThread().getName());
// Setup unhandled Exception Handler
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread thread, Throwable thrown) {
listener.handleError("Exception thrown in " + thread.toString(), thrown);
}
});
timer = new NanoTimer();
Object gl = new AndroidGL();
// gl = GLTracer.createGlesTracer((GL)gl, (GLExt)gl);
// gl = new GLDebugES((GL)gl, (GLExt)gl);
renderer = new GLRenderer((GL) gl, (GLExt) gl, (GLFbo) gl);
renderer.initialize();
JmeSystem.setSoftTextDialogInput(this);
needClose.set(false);
}
use of com.jme3.renderer.Renderer in project jmonkeyengine by jMonkeyEngine.
the class FilterPostProcessor method initialize.
public void initialize(RenderManager rm, ViewPort vp) {
renderManager = rm;
renderer = rm.getRenderer();
viewPort = vp;
fsQuad = new Picture("filter full screen quad");
fsQuad.setWidth(1);
fsQuad.setHeight(1);
if (fbFormat == Format.RGB111110F && !renderer.getCaps().contains(Caps.PackedFloatTexture)) {
fbFormat = Format.RGB8;
}
Camera cam = vp.getCamera();
//save view port diensions
left = cam.getViewPortLeft();
right = cam.getViewPortRight();
top = cam.getViewPortTop();
bottom = cam.getViewPortBottom();
originalWidth = cam.getWidth();
originalHeight = cam.getHeight();
//first call to reshape
reshape(vp, cam.getWidth(), cam.getHeight());
}
use of com.jme3.renderer.Renderer in project jmonkeyengine by jMonkeyEngine.
the class FilterPostProcessor method postFrame.
public void postFrame(FrameBuffer out) {
FrameBuffer sceneBuffer = renderFrameBuffer;
if (renderFrameBufferMS != null && !renderer.getCaps().contains(Caps.OpenGL32)) {
renderer.copyFrameBuffer(renderFrameBufferMS, renderFrameBuffer, true);
} else if (renderFrameBufferMS != null) {
sceneBuffer = renderFrameBufferMS;
}
renderFilterChain(renderer, sceneBuffer);
renderer.setFrameBuffer(outputBuffer);
//viewport can be null if no filters are enabled
if (viewPort != null) {
renderManager.setCamera(viewPort.getCamera(), false);
}
}
Aggregations