本文整理了Java中com.jme3.renderer.Renderer.setViewPort
方法的一些代码示例,展示了Renderer.setViewPort
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Renderer.setViewPort
方法的具体详情如下:
包路径:com.jme3.renderer.Renderer
类名称:Renderer
方法名:setViewPort
[英]Set the viewport location and resolution on the screen.
[中]在屏幕上设置视口位置和分辨率。
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
int viewHeight = (int) ((curCamera.getViewPortTop() - curCamera.getViewPortBottom()) * curCamera.getHeight());
renderer.setViewPort(0, 0, width, height);
renderer.readFrameBuffer(out, outBuf);
renderer.setViewPort(viewX, viewY, viewWidth, viewHeight);
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private void setViewPort(Camera cam) {
// this will make sure to update viewport only if needed
if (cam != prevCam || cam.isViewportChanged()) {
viewX = (int) (cam.getViewPortLeft() * cam.getWidth());
viewY = (int) (cam.getViewPortBottom() * cam.getHeight());
int viewX2 = (int) (cam.getViewPortRight() * cam.getWidth());
int viewY2 = (int) (cam.getViewPortTop() * cam.getHeight());
viewWidth = viewX2 - viewX;
viewHeight = viewY2 - viewY;
uniformBindingManager.setViewPort(viewX, viewY, viewWidth, viewHeight);
renderer.setViewPort(viewX, viewY, viewWidth, viewHeight);
renderer.setClipRect(viewX, viewY, viewWidth, viewHeight);
cam.clearViewportChanged();
prevCam = cam;
// float translateX = viewWidth == viewX ? 0 : -(viewWidth + viewX) / (viewWidth - viewX);
// float translateY = viewHeight == viewY ? 0 : -(viewHeight + viewY) / (viewHeight - viewY);
// float scaleX = viewWidth == viewX ? 1f : 2f / (viewWidth - viewX);
// float scaleY = viewHeight == viewY ? 1f : 2f / (viewHeight - viewY);
//
// orthoMatrix.loadIdentity();
// orthoMatrix.setTranslation(translateX, translateY, 0);
// orthoMatrix.setScale(scaleX, scaleY, 0);
orthoMatrix.loadIdentity();
orthoMatrix.setTranslation(-1f, -1f, 0f);
orthoMatrix.setScale(2f / cam.getWidth(), 2f / cam.getHeight(), 0f);
}
}
代码示例来源:origin: net.sf.phat/phat-core
@Override
public void postFrame(FrameBuffer out) {
if (capture) {
capture = false;
Camera curCamera = rm.getCurrentCamera();
int viewX = (int) (curCamera.getViewPortLeft() * curCamera.getWidth());
int viewY = (int) (curCamera.getViewPortBottom() * curCamera.getHeight());
int viewWidth = (int) ((curCamera.getViewPortRight() - curCamera.getViewPortLeft()) * curCamera.getWidth());
int viewHeight = (int) ((curCamera.getViewPortTop() - curCamera.getViewPortBottom()) * curCamera.getHeight());
renderer.setViewPort(0, 0, width, height);
renderer.readFrameBuffer(out, outBuf);
renderer.setViewPort(viewX, viewY, viewWidth, viewHeight);
for (int i = 0; i < width*height*4; i+=4) {
byte r = outBuf.get(i);
byte g = outBuf.get(i + 1);
byte b = outBuf.get(i + 2);
byte a = outBuf.get(i + 3);
imgBuf.put(i, b); // r
imgBuf.put(i + 1, g); // g
imgBuf.put(i + 2, r); // b
imgBuf.put(i + 3, a); // a
}
image = new Image(Image.Format.RGBA8, width, height, imgBuf);
}
}
代码示例来源:origin: org.jmonkeyengine/jme3-core
int viewHeight = (int) ((curCamera.getViewPortTop() - curCamera.getViewPortBottom()) * curCamera.getHeight());
renderer.setViewPort(0, 0, width, height);
renderer.readFrameBuffer(out, outBuf);
renderer.setViewPort(viewX, viewY, viewWidth, viewHeight);
代码示例来源:origin: net.sf.phat/phat-devices
private void process3(FrameBuffer fb) {
Camera curCamera = viewPort.getCamera();
int viewX = (int) (curCamera.getViewPortLeft() * curCamera.getWidth());
int viewY = (int) (curCamera.getViewPortBottom() * curCamera.getHeight());
int viewWidth = (int) ((curCamera.getViewPortRight() - curCamera.getViewPortLeft()) * curCamera.getWidth());
int viewHeight = (int) ((curCamera.getViewPortTop() - curCamera.getViewPortBottom()) * curCamera.getHeight());
renderManager.getRenderer().setViewPort(320, 640, 0, 240);
renderManager.getRenderer().readFrameBuffer(fb, outBuf);
renderManager.getRenderer().setViewPort(0, 0, width, height);
}
代码示例来源:origin: net.sf.phat/phat-devices
private void process1(FrameBuffer fb) {
Camera curCamera = viewPort.getCamera();
int viewX = (int) (curCamera.getViewPortLeft() * curCamera.getWidth());
int viewY = (int) (curCamera.getViewPortBottom() * curCamera.getHeight());
int viewWidth = (int) ((curCamera.getViewPortRight() - curCamera.getViewPortLeft()) * curCamera.getWidth());
int viewHeight = (int) ((curCamera.getViewPortTop() - curCamera.getViewPortBottom()) * curCamera.getHeight());
renderManager.getRenderer().setViewPort(0, 0, width, height);
renderManager.getRenderer().readFrameBuffer(fb, outBuf);
renderManager.getRenderer().setViewPort(viewX, viewY, viewWidth, viewHeight);
}
代码示例来源:origin: us.ihmc/IHMCJMonkeyEngineToolkit
int viewWidth = (int) ((curCamera.getViewPortRight() - curCamera.getViewPortLeft()) * curCamera.getWidth());
int viewHeight = (int) ((curCamera.getViewPortTop() - curCamera.getViewPortBottom()) * curCamera.getHeight());
renderer.setViewPort(0, 0, width, height);
renderer.setViewPort(viewX, viewY, viewWidth, viewHeight);
代码示例来源:origin: us.ihmc/ihmc-jmonkey-engine-toolkit
int viewWidth = (int) ((curCamera.getViewPortRight() - curCamera.getViewPortLeft()) * curCamera.getWidth());
int viewHeight = (int) ((curCamera.getViewPortTop() - curCamera.getViewPortBottom()) * curCamera.getHeight());
renderer.setViewPort(0, 0, width, height);
renderer.setViewPort(viewX, viewY, viewWidth, viewHeight);
代码示例来源:origin: org.jmonkeyengine/jme3-core
private void setViewPort(Camera cam) {
// this will make sure to update viewport only if needed
if (cam != prevCam || cam.isViewportChanged()) {
viewX = (int) (cam.getViewPortLeft() * cam.getWidth());
viewY = (int) (cam.getViewPortBottom() * cam.getHeight());
int viewX2 = (int) (cam.getViewPortRight() * cam.getWidth());
int viewY2 = (int) (cam.getViewPortTop() * cam.getHeight());
viewWidth = viewX2 - viewX;
viewHeight = viewY2 - viewY;
uniformBindingManager.setViewPort(viewX, viewY, viewWidth, viewHeight);
renderer.setViewPort(viewX, viewY, viewWidth, viewHeight);
renderer.setClipRect(viewX, viewY, viewWidth, viewHeight);
cam.clearViewportChanged();
prevCam = cam;
// float translateX = viewWidth == viewX ? 0 : -(viewWidth + viewX) / (viewWidth - viewX);
// float translateY = viewHeight == viewY ? 0 : -(viewHeight + viewY) / (viewHeight - viewY);
// float scaleX = viewWidth == viewX ? 1f : 2f / (viewWidth - viewX);
// float scaleY = viewHeight == viewY ? 1f : 2f / (viewHeight - viewY);
//
// orthoMatrix.loadIdentity();
// orthoMatrix.setTranslation(translateX, translateY, 0);
// orthoMatrix.setScale(scaleX, scaleY, 0);
orthoMatrix.loadIdentity();
orthoMatrix.setTranslation(-1f, -1f, 0f);
orthoMatrix.setScale(2f / cam.getWidth(), 2f / cam.getHeight(), 0f);
}
}
代码示例来源:origin: info.projectkyoto/mms-engine
private void setViewPort(Camera cam) {
// this will make sure to update viewport only if needed
if (cam != prevCam || cam.isViewportChanged()) {
viewX = (int) (cam.getViewPortLeft() * cam.getWidth());
viewY = (int) (cam.getViewPortBottom() * cam.getHeight());
viewWidth = (int) ((cam.getViewPortRight() - cam.getViewPortLeft()) * cam.getWidth());
viewHeight = (int) ((cam.getViewPortTop() - cam.getViewPortBottom()) * cam.getHeight());
renderer.setViewPort(viewX, viewY, viewWidth, viewHeight);
renderer.setClipRect(viewX, viewY, viewWidth, viewHeight);
cam.clearViewportChanged();
prevCam = cam;
// float translateX = viewWidth == viewX ? 0 : -(viewWidth + viewX) / (viewWidth - viewX);
// float translateY = viewHeight == viewY ? 0 : -(viewHeight + viewY) / (viewHeight - viewY);
// float scaleX = viewWidth == viewX ? 1f : 2f / (viewWidth - viewX);
// float scaleY = viewHeight == viewY ? 1f : 2f / (viewHeight - viewY);
//
// orthoMatrix.loadIdentity();
// orthoMatrix.setTranslation(translateX, translateY, 0);
// orthoMatrix.setScale(scaleX, scaleY, 0);
orthoMatrix.loadIdentity();
orthoMatrix.setTranslation(-1f, -1f, 0f);
orthoMatrix.setScale(2f / cam.getWidth(), 2f / cam.getHeight(), 0f);
// orthoMatrix.fillFloatBuffer(orthoMatrixBuf, true);
}
}
内容来源于网络,如有侵权,请联系作者删除!