作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何在 JMonkeyEngine 3 中将相机作为纹理投影到立方体上?你介意帮我吗?
我尝试通过这段代码来做到这一点,但它不起作用:
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);
}
最佳答案
如果您使用jme3-examples
项目中的TestRenderToTexture
示例,您将实现您想要的效果。您可以将整个内容放在 util 类中,然后从您的项目中调用它(我自己已经这样做了)。
关于java - 我如何将相机作为 jMonkeyEngine 3 中的纹理投影到立方体上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36665499/
我是一名优秀的程序员,十分优秀!