当前位置: 首页>>代码示例>>Java>>正文


Java Camera.setFrustumPerspective方法代码示例

本文整理汇总了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);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:Application.java

示例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);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:ShadowCamera.java

示例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());
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:17,代码来源:SceneComposerTopComponent.java

示例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;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:39,代码来源:TestRenderToTexture.java

示例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);
}
 
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:29,代码来源:SubScreenBridge.java

示例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);
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:14,代码来源:SceneComposerTopComponent.java

示例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);
}
 
开发者ID:dwhuang,项目名称:SMILE,代码行数:29,代码来源:Robot.java

示例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);
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:42,代码来源:TestRenderToMemory.java

示例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);
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:52,代码来源:ShadowUtil.java

示例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);
}
 
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:45,代码来源:OSRBridge.java


注:本文中的com.jme3.renderer.Camera.setFrustumPerspective方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。