tRenderer.getCamera().setLocation(cam.getLocation()); tRenderer.getCamera().setDirection(cam.getDirection()); tRenderer.getCamera().setUp(cam.getUp()); tRenderer.getCamera().setLeft(cam.getLeft()); tRenderer.getCamera().setProjectionMatrix(cam.getProjectionMatrix()); texArray.add(textureDepth); tRenderer.getCamera().update(); tRenderer.getCamera().getModelViewMatrix(); tRenderer.getCamera().getProjectionMatrix();
private void updateCameraFrustum() { final double width = _corners[2].subtractLocal(_corners[1]).length() / 2.0; final double height = _corners[1].subtractLocal(_corners[0]).length() / 2.0; _tRenderer.getCamera().setFrustum(_nearPlane, _farPlane, -width, width, height, -height); }
/** * Update the shadow map. * * @param index * shadow map texture index to update */ private void updateShadowMap(final int index, final Renderer r) { if (shadowRenderCallback != null) { shadowRenderCallback.onRender(index, r, this, _shadowMapRenderer.getCamera()); } r.setRenderLogic(logic); if (!_useSceneTexturing) { Mesh.RENDER_VERTEX_ONLY = true; } _shadowMapRenderer.render(_occluderNodes, _shadowMapTexture[index], Renderer.BUFFER_COLOR_AND_DEPTH); if (!_useSceneTexturing) { Mesh.RENDER_VERTEX_ONLY = false; } r.setRenderLogic(null); }
protected void render(final Renderer renderer, final Camera camera, final List<Spatial> spatials, final Spatial spatial, final EnumMap<StateType, RenderState> enforcedStates) { final TextureRenderer texRend = TextureRendererPool.fetch(_width, _height, renderer); if (!_texSetup) { texRend.setupTexture(_texture); _texSetup = true; } // set desired bg color texRend.setBackgroundColor(_backgroundColor); // setup camera if (camera != null) { texRend.getCamera().setFrame(camera); texRend.getCamera().setFrustum(camera); texRend.getCamera().setProjectionMode(camera.getProjectionMode()); } texRend.enforceStates(enforcedStates); // draw to texture if (spatial != null) { texRend.render(spatial, _texture, Renderer.BUFFER_COLOR_AND_DEPTH); } else { texRend.render(spatials, _texture, Renderer.BUFFER_COLOR_AND_DEPTH); } texRend.clearEnforcedStates(); TextureRendererPool.release(texRend); }
public void updateCamera() { if (isSupported()) { tRenderer.getCamera().setFrustum(cam.getFrustumNear(), cam.getFrustumFar(), cam.getFrustumLeft(), cam.getFrustumRight(), cam.getFrustumTop(), cam.getFrustumBottom()); } }
tRenderer.getCamera().setLocation(camReflectPos); tRenderer.getCamera().setDirection(camReflectDir); tRenderer.getCamera().setUp(camReflectUp); tRenderer.getCamera().setLeft(camReflectLeft); } else { tRenderer.getCamera().setLocation(cam.getLocation()); tRenderer.getCamera().setDirection(cam.getDirection()); tRenderer.getCamera().setUp(cam.getUp()); tRenderer.getCamera().setLeft(cam.getLeft()); skyBox.setTranslation(tRenderer.getCamera().getLocation()); skyBox.updateGeometricState(0.0f); skyBox.getSceneHints().setCullHint(CullHint.Never); tRenderer.getCamera().setProjectionMode(ProjectionMode.Custom); tRenderer.getCamera().setProjectionMatrix(cam.getProjectionMatrix()); tRenderer.render(skyBox, texArray, Renderer.BUFFER_COLOR_AND_DEPTH);
/** * Update texture matrix. * * @param index * the index */ private void updateTextureMatrix(final int index) { // Create a matrix going from light to camera space final Camera cam = ContextManager.getCurrentContext().getCurrentCamera(); _shadowMatrix.set(cam.getModelViewMatrix()).invertLocal(); _shadowMatrix.multiplyLocal(_shadowMapRenderer.getCamera().getModelViewProjectionMatrix()).multiplyLocal( SCALE_BIAS_MATRIX); _shadowMapTexture[index].setTextureMatrix(_shadowMatrix); }
private void modifyProjectionMatrix(final Vector4 clipPlane) { // Get the current projection matrix projectionMatrix = cam.getProjectionMatrix().toArray(projectionMatrix); // Get the inverse transpose of the current modelview matrix final ReadOnlyMatrix4 modelViewMatrixInvTrans = tRenderer.getCamera().getModelViewMatrix().invert(tmpMatrix) .transposeLocal(); modelViewMatrixInvTrans.applyPre(clipPlane, clipPlane); // Calculate the clip-space corner point opposite the clipping plane // as (sgn(clipPlane.x), sgn(clipPlane.y), 1, 1) and // transform it into camera space by multiplying it // by the inverse of the projection matrix cornerPoint.setX((sign(clipPlane.getX()) + projectionMatrix[8]) / projectionMatrix[0]); cornerPoint.setY((sign(clipPlane.getY()) + projectionMatrix[9]) / projectionMatrix[5]); cornerPoint.setZ(-1.0); cornerPoint.setW((1.0 + projectionMatrix[10]) / projectionMatrix[14]); // Calculate the scaled plane vector final Vector4 scaledPlaneVector = clipPlane.multiply((2.0 / clipPlane.dot(cornerPoint)), cornerPoint); // Replace the third row of the projection matrix projectionMatrix[2] = scaledPlaneVector.getX(); projectionMatrix[6] = scaledPlaneVector.getY(); projectionMatrix[10] = scaledPlaneVector.getZ() + 1.0; projectionMatrix[14] = scaledPlaneVector.getW(); // Load it back into OpenGL final Matrix4 newProjectionMatrix = tmpMatrix.fromArray(projectionMatrix); tRenderer.getCamera().setProjectionMatrix(newProjectionMatrix); }
_tRenderer.getCamera().getScreenCoordinates(_corners[i], _corners[i]); _minMaxScreenPos.set(_minScreenPos.getX(), _maxScreenPos.getY()); _tRenderer.getCamera().getWorldCoordinates(_maxScreenPos, _minZ, _corners[0]); _tRenderer.getCamera().getWorldCoordinates(_maxMinScreenPos, _minZ, _corners[1]); _tRenderer.getCamera().getWorldCoordinates(_minScreenPos, _minZ, _corners[2]); _tRenderer.getCamera().getWorldCoordinates(_minMaxScreenPos, _minZ, _corners[3]); _center.set(_corners[0]).addLocal(_corners[1]).addLocal(_corners[2]).addLocal(_corners[3]).multiplyLocal(0.25); _lastCamDir.set(_center).subtractLocal(_tRenderer.getCamera().getLocation()); _lastCamDist = _nearPlane = _lastCamDir.length(); _farPlane = _nearPlane + _extents.length() * 2.0;
@Override public void draw(final Renderer r) { if (_timer != null && _redrawRate > 0) { _elapsed += _timer.getTimePerFrame(); } if (_tRenderer == null) { init(r); } if (_cam == null) { _cam = Camera.getCurrentCamera(); _tRenderer.getCamera().setFrustum(_cam.getFrustumNear(), _cam.getFrustumFar(), _cam.getFrustumLeft(), _cam.getFrustumRight(), _cam.getFrustumTop(), _cam.getFrustumBottom()); _tRenderer.getCamera().setFrame(_cam.getLocation(), _cam.getLeft(), _cam.getUp(), _cam.getDirection()); } if (_doUpdate && (!_haveDrawn || shouldDoUpdate(_cam)) && _targetScene.getWorldBound() != null) { final BoundingVolume b = _targetScene.getWorldBound(); _center.set(b.getCenter()); updateCameraLookat(); calculateImposter(); updateCameraLookat(); updateCameraFrustum(); renderImposter(); _haveDrawn = true; } _imposterQuad.draw(r); }
final Camera shadowCam = _shadowMapRenderer.getCamera();
_shadowMapRenderer.getCamera().setProjectionMode(ProjectionMode.Parallel);
tRenderer.getCamera().setFrustum(cam.getFrustumNear(), cam.getFrustumFar(), cam.getFrustumLeft(), cam.getFrustumRight(), cam.getFrustumTop(), cam.getFrustumBottom());
drawFrustum(r, _shadowMapRenderer.getCamera(), new ColorRGBA(1, 1, (iSplit + 1) / (float) _numOfSplits, 1), (short) 0xFFFF, true);
final Camera shadowCam = _shadowMapRenderer.getCamera();
tRenderer.getCamera().setFrustum(cam.getFrustumNear(), cam.getFrustumFar(), cam.getFrustumLeft(), cam.getFrustumRight(), cam.getFrustumTop(), cam.getFrustumBottom());