Wie projiziere ich eine Kamera auf einen Würfel als Textur in JMonkeyEngine3? Würde es Ihnen etwas ausmachen, mir zu helfen?Wie projiziere ich eine Kamera auf einen Würfel als Textur in jMonkeyEngine 3?
ich versuche, es von diesem Stück Code zu tun, aber es dosent Arbeit:
private void addCamera() {
Camera c = new Camera(100, 100);
c.setViewPort(0, 1, 0, 1);
c.setLocation(Vector3f.ZERO);
ViewPort v = new ViewPort("c", c);
v.attachScene(rootNode);
FrameBuffer fb = v.getOutputFrameBuffer();
fb.setDepthBuffer(Format.Depth);
Texture2D niftytex = new Texture2D(1024, 768, Format.RGB8);
fb.setColorTexture(niftytex);
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
Geometry geom = new Geometry("Box", b);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("m_ColorMap", niftytex);
/**
* Here comes the texture!
*/
geom.setMaterial(mat);
localRootNode.attachChild(geom);
}
Was genau funktioniert nicht? Ich könnte hier eine Reihe von Problemen erkennen: 1) 'fb' ist NULL. 2) Sie müssen 'v.setOutputFrameBuffer()' 3) einstellen. Der Materialparameter ist 'ColorMap' ohne das' m_'. – 1000ml