Hey folks i tried somthing which maybe is a little bit beyond my skills but anyway i think its a nice feature.
i tried to copy somehow the main stuff from the renderer.cameraman Test and to create a camera class so here is the code:
import com.jme.image.Texture;
import com.jme.math.Vector3f;
import com.jme.renderer.TextureRenderer;
import com.jme.scene.CameraNode;
import com.jme.scene.Node;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.LightState;
import com.jme.scene.state.TextureState;
import com.jme.scene.state.ZBufferState;
import com.jme.system.DisplaySystem;
public class InGameCam {
private CameraNode camNode;
private DisplaySystem display;
private TextureRenderer tRenderer;
private float lastRend = 1;
private float throttle = 1/30f;
private Texture fakeTex;
public InGameCam(DisplaySystem display,int sizeX, int sizeY) {
this.display = display;
fakeTex = new Texture();
tRenderer = display.createTextureRenderer(sizeX,sizeY, TextureRenderer.RENDER_TEXTURE_2D);
camNode = new CameraNode("Camera Node", tRenderer.getCamera());
camNode.updateGeometricState(0, true);
}
public Node createMonitor() {
Node monitorNode = new Node("Monitor Node");
Quad quad = new Quad("Monitor");
quad.initialize(3, 3);
monitorNode.attachChild(quad);
ZBufferState buf = display.getRenderer().createZBufferState();
buf.setEnabled(true);
buf.setFunction(ZBufferState.CF_LEQUAL);
monitorNode.setRenderState(buf);
fakeTex.setRTTSource(Texture.RTT_SOURCE_RGBA);
tRenderer.setupTexture(fakeTex);
TextureState screen = display.getRenderer().createTextureState();
screen.setTexture(fakeTex);
screen.setEnabled(true);
quad.setRenderState(screen);
monitorNode.updateGeometricState(0.0f, true);
monitorNode.updateRenderState();
monitorNode.setLightCombineMode(LightState.OFF);
return monitorNode;
}
public CameraNode getCamNode() {
return camNode;
}
protected void render(float tpf) {
lastRend += tpf;
if (lastRend > throttle ) {
tRenderer.render(camNode,fakeTex);
lastRend = 0;
}
}
}
i didnt understand everything of what im doing espacially not the line tRenderer.render(camNode,fakeTex); in the test class ther was instead of the camNode the model which is viewed but i dont get what this method does i thougth it updates this fake Texture so it can display moving things but then i dont understand what the spatial is for. nevertheless my actual problem is that i get a nullpointer Exception in this Line:
tRenderer.render(camNode,fakeTex);
with:
at com.jme.renderer.lwjgl.LWJGLTextureRenderer.<init>(Unknown Source)
at com.jme.system.lwjgl.LWJGLDisplaySystem.createTextureRenderer(Unknown Source)
thanks for help