I made these two classes for the multipass rendering that got spawned from this thread: http://www.java-gaming.org/forums/index.php?topic=10611.0
MultiPassView.java
import java.util.ArrayList;
import com.xith3d.render.jogl.*;
import com.xith3d.scenegraph.*;
public class MultiPassView extends View {
private CanvasPeerImpl m_peerImpl;
private ArrayList<RenderPass> m_renderPasses;
private BranchGroup m_sceneGraph;
public MultiPassView(CanvasPeerImpl peerImpl, Locale locale) {
super();
m_peerImpl = peerImpl;
m_renderPasses = new ArrayList<RenderPass>(128);
m_sceneGraph = new BranchGroup();
m_sceneGraph.setPickable(true);
locale.addBranchGraph(m_sceneGraph);
}
public void addRenderPass(RenderPass pass) {
if (m_renderPasses.size() == 0) {
m_renderPasses.add(pass);
} else {
switch (pass.getZAlignment()) {
default:
case RenderPass.ALIGN_Z_FAR :
m_renderPasses.add(0, pass);
break;
case RenderPass.ALIGN_Z_CLOSE :
m_renderPasses.add(m_renderPasses.size() - 1, pass);
break;
case RenderPass.ALIGN_Z_CLOSEST :
m_renderPasses.add(pass);
break;
}
}
m_sceneGraph.addChild(pass.getNode());
}
public void removeRenderPass(RenderPass pass) {
int index = m_renderPasses.indexOf(pass);
m_renderPasses.set(index, null);
m_sceneGraph.removeChild(pass.getNode());
}
public void renderAll() {
for (int i = 0; i < m_renderPasses.size(); i++) {
// get render pass
RenderPass pass = m_renderPasses.get(i);
// set node
pass.getNode().setRenderable(true);
// set projection policy
if (pass.getProjectionPolicy() == View.PARALLEL_PROJECTION) {
setProjectionPolicy(View.PARALLEL_PROJECTION);
} else {
setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
}
// set clear buffer state
if (i == 0) {
m_peerImpl.setDisableClearBuffer(false);
} else {
m_peerImpl.setDisableClearBuffer(true);
}
// set force swap state
if (i < m_renderPasses.size() - 1) {
m_peerImpl.setForceNoSwap(true);
} else {
m_peerImpl.setForceNoSwap(false);
}
// render
renderOnce();
// unset node
pass.getNode().setRenderable(false);
}
}
}
and
RenderPass.java
import com.xith3d.scenegraph.Node;
/**
* @author Jaakko
*
*/
public class RenderPass {
public static final int ALIGN_Z_FAR = 0;
public static final int ALIGN_Z_CLOSE = 1;
public static final int ALIGN_Z_CLOSEST = 2;
private int m_projectionPolicy;
private float m_nearClip;
private float m_farClip;
private Node m_node;
private int m_zAlignment;
/**
*
*/
public RenderPass(int projectionPolicy, float nearClip, float farClip, Node node) {
this(projectionPolicy, nearClip, farClip, node, ALIGN_Z_CLOSE);
}
/**
*
*/
public RenderPass(int projectionPolicy, float nearClip, float farClip, Node node, int zAlignment) {
m_projectionPolicy = projectionPolicy;
m_nearClip = nearClip;
m_farClip = farClip;
m_node = node;
m_zAlignment = zAlignment;
m_node.setRenderable(false);
}
/**
* @return Returns the zAlignment.
*/
public int getZAlignment() {
return m_zAlignment;
}
/**
* @param alignment The zAlignment to set.
*/
public void setZAlignment(int zAlignment) {
m_zAlignment = zAlignment;
}
/**
* @return Returns the farClip.
*/
public float getFarClip() {
return m_farClip;
}
/**
* @param clip The farClip to set.
*/
public void setFarClip(float clip) {
m_farClip = clip;
}
/**
* @return Returns the nearClip.
*/
public float getNearClip() {
return m_nearClip;
}
/**
* @param clip The nearClip to set.
*/
public void setNearClip(float clip) {
m_nearClip = clip;
}
/**
* @return Returns the node.
*/
public Node getNode() {
return m_node;
}
/**
* @param m_node The node to set.
*/
public void setNode(Node node) {
m_node = node;
}
/**
* @return Returns the projectionPolicy.
*/
public int getProjectionPolicy() {
return m_projectionPolicy;
}
/**
* @param policy The projectionPolicy to set.
*/
public void setProjectionPolicy(int policy) {
m_projectionPolicy = policy;
}
}
Now can I add them as a new package to the toolkit?
I’ll provide good javadoc comments and make a test program as required.