Java Code Examples for com.jme3.renderer.queue.RenderQueue#renderQueue()

The following examples show how to use com.jme3.renderer.queue.RenderQueue#renderQueue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PreDepthProcessor.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void postQueue(RenderQueue rq) {
    // lay depth first
    rm.setForcedMaterial(preDepth);
    rq.renderQueue(RenderQueue.Bucket.Opaque, rm, vp.getCamera(), false);
    rm.setForcedMaterial(null);

    rm.setForcedRenderState(forcedRS);
}
 
Example 2
Source File: PreDepthProcessor.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void postQueue(RenderQueue rq) {
    // lay depth first
    rm.setForcedMaterial(preDepth);
    rq.renderQueue(RenderQueue.Bucket.Opaque, rm, vp.getCamera(), false);
    rm.setForcedMaterial(null);

    rm.setForcedRenderState(forcedRS);
}
 
Example 3
Source File: RenderManager.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Render the given viewport queues.
 * <p>
 * Changes the {@link Renderer#setDepthRange(float, float) depth range}
 * appropriately as expected by each queue and then calls 
 * {@link RenderQueue#renderQueue(com.jme3.renderer.queue.RenderQueue.Bucket, com.jme3.renderer.RenderManager, com.jme3.renderer.Camera, boolean) }
 * on the queue. Makes sure to restore the depth range to [0, 1] 
 * at the end of the call.
 * Note that the {@link Bucket#Translucent translucent bucket} is NOT
 * rendered by this method. Instead the user should call 
 * {@link #renderTranslucentQueue(com.jme3.renderer.ViewPort) }
 * after this call.
 * 
 * @param vp the viewport of which queue should be rendered
 * @param flush If true, the queues will be cleared after
 * rendering.
 * 
 * @see RenderQueue
 * @see #renderTranslucentQueue(com.jme3.renderer.ViewPort) 
 */
public void renderViewPortQueues(ViewPort vp, boolean flush) {
    RenderQueue rq = vp.getQueue();
    Camera cam = vp.getCamera();
    boolean depthRangeChanged = false;

    // render opaque objects with default depth range
    // opaque objects are sorted front-to-back, reducing overdraw
    if (prof!=null) prof.vpStep(VpStep.RenderBucket, vp, Bucket.Opaque);
    rq.renderQueue(Bucket.Opaque, this, cam, flush);

    // render the sky, with depth range set to the farthest
    if (!rq.isQueueEmpty(Bucket.Sky)) {
        if (prof!=null) prof.vpStep(VpStep.RenderBucket, vp, Bucket.Sky);
        renderer.setDepthRange(1, 1);
        rq.renderQueue(Bucket.Sky, this, cam, flush);
        depthRangeChanged = true;
    }


    // transparent objects are last because they require blending with the
    // rest of the scene's objects. Consequently, they are sorted
    // back-to-front.
    if (!rq.isQueueEmpty(Bucket.Transparent)) {
        if (prof!=null) prof.vpStep(VpStep.RenderBucket, vp, Bucket.Transparent);
        if (depthRangeChanged) {
            renderer.setDepthRange(0, 1);
            depthRangeChanged = false;
        }

        rq.renderQueue(Bucket.Transparent, this, cam, flush);
    }

    if (!rq.isQueueEmpty(Bucket.Gui)) {
        if (prof!=null) prof.vpStep(VpStep.RenderBucket, vp, Bucket.Gui);
        renderer.setDepthRange(0, 0);
        setCamera(cam, true);
        rq.renderQueue(Bucket.Gui, this, cam, flush);
        setCamera(cam, false);
        depthRangeChanged = true;
    }

    // restore range to default
    if (depthRangeChanged) {
        renderer.setDepthRange(0, 1);
    }
}
 
Example 4
Source File: RenderManager.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Render the given viewport queues.
 * <p>
 * Changes the {@link Renderer#setDepthRange(float, float) depth range}
 * appropriately as expected by each queue and then calls 
 * {@link RenderQueue#renderQueue(com.jme3.renderer.queue.RenderQueue.Bucket, com.jme3.renderer.RenderManager, com.jme3.renderer.Camera, boolean) }
 * on the queue. Makes sure to restore the depth range to [0, 1] 
 * at the end of the call.
 * Note that the {@link Bucket#Translucent translucent bucket} is NOT
 * rendered by this method. Instead the user should call 
 * {@link #renderTranslucentQueue(com.jme3.renderer.ViewPort) }
 * after this call.
 * 
 * @param vp the viewport of which queue should be rendered
 * @param flush If true, the queues will be cleared after
 * rendering.
 * 
 * @see RenderQueue
 * @see #renderTranslucentQueue(com.jme3.renderer.ViewPort) 
 */
public void renderViewPortQueues(ViewPort vp, boolean flush) {
    RenderQueue rq = vp.getQueue();
    Camera cam = vp.getCamera();
    boolean depthRangeChanged = false;

    // render opaque objects with default depth range
    // opaque objects are sorted front-to-back, reducing overdraw
    rq.renderQueue(Bucket.Opaque, this, cam, flush);

    // render the sky, with depth range set to the farthest
    if (!rq.isQueueEmpty(Bucket.Sky)) {
        renderer.setDepthRange(1, 1);
        rq.renderQueue(Bucket.Sky, this, cam, flush);
        depthRangeChanged = true;
    }


    // transparent objects are last because they require blending with the
    // rest of the scene's objects. Consequently, they are sorted
    // back-to-front.
    if (!rq.isQueueEmpty(Bucket.Transparent)) {
        if (depthRangeChanged) {
            renderer.setDepthRange(0, 1);
            depthRangeChanged = false;
        }

        rq.renderQueue(Bucket.Transparent, this, cam, flush);
    }

    if (!rq.isQueueEmpty(Bucket.Gui)) {
        renderer.setDepthRange(0, 0);
        setCamera(cam, true);
        rq.renderQueue(Bucket.Gui, this, cam, flush);
        setCamera(cam, false);
        depthRangeChanged = true;
    }

    // restore range to default
    if (depthRangeChanged) {
        renderer.setDepthRange(0, 1);
    }
}
 
Example 5
Source File: RenderManager.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Renders the {@link Bucket#Translucent translucent queue} on the viewPort.
 * <p>
 * This call does nothing unless {@link #setHandleTranslucentBucket(boolean) }
 * is set to true. This method clears the translucent queue after rendering
 * it.
 * 
 * @param vp The viewport of which the translucent queue should be rendered.
 * 
 * @see #renderViewPortQueues(com.jme3.renderer.ViewPort, boolean) 
 * @see #setHandleTranslucentBucket(boolean) 
 */
public void renderTranslucentQueue(ViewPort vp) {
    if (prof!=null) prof.vpStep(VpStep.RenderBucket, vp, Bucket.Translucent);
    
    RenderQueue rq = vp.getQueue();
    if (!rq.isQueueEmpty(Bucket.Translucent) && handleTranlucentBucket) {
        rq.renderQueue(Bucket.Translucent, this, vp.getCamera(), true);
    }
}
 
Example 6
Source File: RenderManager.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 3 votes vote down vote up
/**
 * Renders the {@link Bucket#Translucent translucent queue} on the viewPort.
 * <p>
 * This call does nothing unless {@link #setHandleTranslucentBucket(boolean) }
 * is set to true. This method clears the translucent queue after rendering
 * it.
 * 
 * @param vp The viewport of which the translucent queue should be rendered.
 * 
 * @see #renderViewPortQueues(com.jme3.renderer.ViewPort, boolean) 
 * @see #setHandleTranslucentBucket(boolean) 
 */
public void renderTranslucentQueue(ViewPort vp) {
    RenderQueue rq = vp.getQueue();
    if (!rq.isQueueEmpty(Bucket.Translucent) && handleTranlucentBucket) {
        rq.renderQueue(Bucket.Translucent, this, vp.getCamera(), true);
    }
}