本文整理汇总了Java中com.jme3.renderer.Camera.setFrustumPerspective方法的典型用法代码示例。如果您正苦于以下问题:Java Camera.setFrustumPerspective方法的具体用法?Java Camera.setFrustumPerspective怎么用?Java Camera.setFrustumPerspective使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.renderer.Camera
的用法示例。
在下文中一共展示了Camera.setFrustumPerspective方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initCamera
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
/**
* Creates the camera to use for rendering. Default values are perspective
* projection with 45° field of view, with near and far values 1 and 1000
* units respectively.
*/
private void initCamera(){
cam = new Camera(settings.getWidth(), settings.getHeight());
cam.setFrustumPerspective(45f, (float)cam.getWidth() / cam.getHeight(), 1f, 1000f);
cam.setLocation(new Vector3f(0f, 0f, 10f));
cam.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y);
renderManager = new RenderManager(renderer);
//Remy - 09/14/2010 setted the timer in the renderManager
renderManager.setTimer(timer);
viewPort = renderManager.createMainView("Default", cam);
viewPort.setClearFlags(true, true, true);
// Create a new cam for the gui
Camera guiCam = new Camera(settings.getWidth(), settings.getHeight());
guiViewPort = renderManager.createPostView("Gui Default", guiCam);
guiViewPort.setClearFlags(false, false, false);
}
示例2: updateLightCamera
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
/**
* Updates the camera view direction and position based on the light
*/
public void updateLightCamera(Camera lightCam) {
if (target.getType() == Light.Type.Directional) {
DirectionalLight dl = (DirectionalLight) target;
lightCam.setParallelProjection(true);
lightCam.setLocation(Vector3f.ZERO);
lightCam.lookAtDirection(dl.getDirection(), Vector3f.UNIT_Y);
lightCam.setFrustum(-1, 1, -1, 1, 1, -1);
} else {
PointLight pl = (PointLight) target;
lightCam.setParallelProjection(false);
lightCam.setLocation(pl.getPosition());
// direction will have to be calculated automatically
lightCam.setFrustumPerspective(45, 1, 1, 300);
}
}
示例3: jSpinner1StateChanged
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
private void jSpinner1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner1StateChanged
// This is called, when the spinner of the near plane has been changed.
float near = ((float)jSlider1.getValue() / 1000f);
float spin = (Float)jSpinner1.getValue();
// Prevent an endless loop of state changes and don't change the slider when the spinner
// has gone out of range, since this would lead to the slider's StateChanged overwriting the spinner again.
// but we want the spinner to be a free-form field
if (spin <= 2000f && spin >= 100f && !FastMath.approximateEquals((Float)(jSpinner1.getValue()), near)) {
jSlider1.setValue((int)((Float)(jSpinner1.getValue()) * 1000f));
}
final Camera cam = SceneApplication.getApplication().getCamera();
cam.setFrustumPerspective(45f, (float)cam.getWidth() / cam.getHeight(), spin, cam.getFrustumFar());
}
示例4: setupOffscreenView
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
public Texture setupOffscreenView(){
Camera offCamera = new Camera(512, 512);
offView = renderManager.createPreView("Offscreen View", offCamera);
offView.setClearFlags(true, true, true);
offView.setBackgroundColor(ColorRGBA.DarkGray);
// create offscreen framebuffer
FrameBuffer offBuffer = new FrameBuffer(512, 512, 1);
//setup framebuffer's cam
offCamera.setFrustumPerspective(45f, 1f, 1f, 1000f);
offCamera.setLocation(new Vector3f(0f, 0f, -5f));
offCamera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y);
//setup framebuffer's texture
Texture2D offTex = new Texture2D(512, 512, Format.RGBA8);
offTex.setMinFilter(Texture.MinFilter.Trilinear);
offTex.setMagFilter(Texture.MagFilter.Bilinear);
//setup framebuffer to use texture
offBuffer.setDepthBuffer(Format.Depth);
offBuffer.setColorTexture(offTex);
//set viewport to render to offscreen framebuffer
offView.setOutputFrameBuffer(offBuffer);
// setup framebuffer's scene
Box boxMesh = new Box(Vector3f.ZERO, 1,1,1);
Material material = assetManager.loadMaterial("Interface/Logo/Logo.j3m");
offBox = new Geometry("box", boxMesh);
offBox.setMaterial(material);
// attach the scene to the viewport to be rendered
offView.attachScene(offBox);
return offTex;
}
示例5: SubScreenBridge
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
public SubScreenBridge(RenderManager rm, int width, int height, Node root) {
this.rm = rm;
this.root = root;
cam = new Camera(width, height);
cam.setParallelProjection(true);
cam.setFrustumPerspective(45, 90, 0, 1);
vp = rm.createPreView("Offscreen View", cam);
if (!ToolKit.isAndroid()) vp.setClearFlags(true, true, true);
else vp.setClearFlags(true, false, false);
FrameBuffer offBuffer = new FrameBuffer(width, height, 1);
tex = new Texture2D(width, height, Image.Format.RGBA8);
tex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
tex.setMagFilter(Texture.MagFilter.Bilinear);
if (!ToolKit.isAndroid())
offBuffer.setDepthBuffer(Image.Format.Depth);
offBuffer.setColorTexture(tex);
vp.setOutputFrameBuffer(offBuffer);
setSpatial(root);
vp.attachScene(root);
}
示例6: jSpinner2StateChanged
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
private void jSpinner2StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner2StateChanged
// Prevent an endless loop of state changes and don't change the slider when the spinner
// has gone out of range, since this would lead to the slider's StateChanged overwriting the spinner again.
// but we want the spinner to be a free-form field
float spin = (Float)jSpinner2.getValue();
if (spin <= 3000f && spin >= 5f && !FastMath.approximateEquals(spin, (float)jSlider2.getValue())) {
jSlider2.setValue((int)spin);
}
final Camera cam = SceneApplication.getApplication().getCamera();
cam.setFrustumPerspective(45f, (float)cam.getWidth() / cam.getHeight(), cam.getFrustumNear(), spin);
}
示例7: Robot
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
public Robot(String name, MainApp app, Node robotLocationNode) {
this.name = name;
assetManager = app.getAssetManager();
renderManager = app.getRenderManager();
physicsSpace = app.getBulletAppState().getPhysicsSpace();
factory = app.getFactory();
rootNode = app.getRootNode();
this.robotLocationNode = robotLocationNode;
loadHeadCamParams();
buildRobot(name, robotLocationNode);
// the camera attached near the top of the head screen is used
// to take pictures, which are sent to the control agent
headCamcorder = new Camera(headCamResWidth, headCamResHeight);
headCamcorder.setFrustumPerspective(headCamFov,
headCamResWidth / headCamResHeight, 0.01f, 100);
headImageCapturer = new ImageCapturer(headCamcorder, renderManager,
headCamNode, this.rootNode);
headImageCapturer.syncCamera();
// facial expressoin
showNextFacialExpression();
// control agent
matlabAgent = new MatlabAgent(leftJointStates, rightJointStates,
leftGripper, rightGripper, locTrackers, rootNode, factory, headCamResWidth, headCamResHeight);
}
示例8: setupOffscreenView
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
public void setupOffscreenView(){
offCamera = new Camera(width, height);
// create a pre-view. a view that is rendered before the main view
offView = renderManager.createPreView("Offscreen View", offCamera);
offView.setBackgroundColor(ColorRGBA.DarkGray);
offView.setClearFlags(true, true, true);
// this will let us know when the scene has been rendered to the
// frame buffer
offView.addProcessor(this);
// create offscreen framebuffer
offBuffer = new FrameBuffer(width, height, 1);
//setup framebuffer's cam
offCamera.setFrustumPerspective(45f, 1f, 1f, 1000f);
offCamera.setLocation(new Vector3f(0f, 0f, -5f));
offCamera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y);
//setup framebuffer's texture
// offTex = new Texture2D(width, height, Format.RGBA8);
//setup framebuffer to use renderbuffer
// this is faster for gpu -> cpu copies
offBuffer.setDepthBuffer(Format.Depth);
offBuffer.setColorBuffer(Format.RGBA8);
// offBuffer.setColorTexture(offTex);
//set viewport to render to offscreen framebuffer
offView.setOutputFrameBuffer(offBuffer);
// setup framebuffer's scene
Box boxMesh = new Box(Vector3f.ZERO, 1,1,1);
Material material = assetManager.loadMaterial("Interface/Logo/Logo.j3m");
offBox = new Geometry("box", boxMesh);
offBox.setMaterial(material);
// attach the scene to the viewport to be rendered
offView.attachScene(offBox);
}
示例9: updateShadowCamera
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
/**
* Updates the shadow camera to properly contain the given
* points (which contain the eye camera frustum corners)
*
* @param occluders
* @param lightCam
* @param points
*/
public static void updateShadowCamera(Camera shadowCam, Vector3f[] points) {
boolean ortho = shadowCam.isParallelProjection();
shadowCam.setProjectionMatrix(null);
if (ortho) {
shadowCam.setFrustum(-1, 1, -1, 1, 1, -1);
} else {
shadowCam.setFrustumPerspective(45, 1, 1, 150);
}
Matrix4f viewProjMatrix = shadowCam.getViewProjectionMatrix();
Matrix4f projMatrix = shadowCam.getProjectionMatrix();
BoundingBox splitBB = computeBoundForPoints(points, viewProjMatrix);
Vector3f splitMin = splitBB.getMin(null);
Vector3f splitMax = splitBB.getMax(null);
// splitMin.z = 0;
// Create the crop matrix.
float scaleX, scaleY, scaleZ;
float offsetX, offsetY, offsetZ;
scaleX = 2.0f / (splitMax.x - splitMin.x);
scaleY = 2.0f / (splitMax.y - splitMin.y);
offsetX = -0.5f * (splitMax.x + splitMin.x) * scaleX;
offsetY = -0.5f * (splitMax.y + splitMin.y) * scaleY;
scaleZ = 1.0f / (splitMax.z - splitMin.z);
offsetZ = -splitMin.z * scaleZ;
Matrix4f cropMatrix = new Matrix4f(scaleX, 0f, 0f, offsetX,
0f, scaleY, 0f, offsetY,
0f, 0f, scaleZ, offsetZ,
0f, 0f, 0f, 1f);
Matrix4f result = new Matrix4f();
result.set(cropMatrix);
result.multLocal(projMatrix);
shadowCam.setProjectionMatrix(result);
}
示例10: OSRBridge
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
public OSRBridge(RenderManager rm, int width, int height, Node root) {
this.rm = rm;
this.root = root;
cam = new Camera(width, height);
vp = rm.createPreView("Offscreen View", cam);
if (!ToolKit.isAndroid())
vp.setClearFlags(true, true, true);
else
vp.setClearFlags(true, false, false);
FrameBuffer offBuffer = new FrameBuffer(width, height, 1);
tex = new Texture2D(width, height, Image.Format.RGBA8);
tex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
tex.setMagFilter(Texture.MagFilter.Bilinear);
if (!ToolKit.isAndroid())
offBuffer.setDepthBuffer(Image.Format.Depth);
offBuffer.setColorTexture(tex);
vp.setOutputFrameBuffer(offBuffer);
setSpatial(root);
vp.attachScene(root);
chaseCam = new ChaseCamera(cam, root) {
@Override
public void setDragToRotate(boolean dragToRotate) {
this.dragToRotate = dragToRotate;
this.canRotate = !dragToRotate;
}
};
chaseCam.setDefaultDistance(5f);
chaseCam.setMaxDistance(340f);
chaseCam.setDefaultHorizontalRotation(90 * FastMath.DEG_TO_RAD);
chaseCam.setDefaultVerticalRotation(0f);
cam.setFrustumFar(36000f);
float aspect = (float) cam.getWidth() / (float) cam.getHeight();
cam.setFrustumPerspective(45f, aspect, 0.1f, cam.getFrustumFar());
chaseCam.setUpVector(Vector3f.UNIT_Y);
}