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


Java Camera类代码示例

本文整理汇总了Java中com.jme3.renderer.Camera的典型用法代码示例。如果您正苦于以下问题:Java Camera类的具体用法?Java Camera怎么用?Java Camera使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Camera类属于com.jme3.renderer包,在下文中一共展示了Camera类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareProcessor

import com.jme3.renderer.Camera; //导入依赖的package包/类
/**
 * Prepare the processor to render the a preview object.
 */
@JMEThread
private void prepareProcessor() {

    if (processor != null) {
        processor.setEnabled(true);
    }

    frame = 0;

    final Editor editor = Editor.getInstance();
    final Camera camera = editor.getPreviewCamera();
    camera.setLocation(CAMERA_LOCATION);
    camera.setRotation(CAMERA_ROTATION);

    modelNode.detachAllChildren();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:20,代码来源:JMEFilePreviewManager.java

示例2: getScenePosByScreenPos

import com.jme3.renderer.Camera; //导入依赖的package包/类
/**
 * Get a position on a scene for a cursor position on a screen.
 *
 * @param screenX the x position on screen.
 * @param screenY the y position on screen.
 * @return the position on a scene.
 */
@JMEThread
public @NotNull Vector3f getScenePosByScreenPos(final float screenX, final float screenY) {

    final Camera camera = getCamera();
    final M currentModel = notNull(getCurrentModel());

    Vector3f result = GeomUtils.getContactPointFromScreenPos(currentModel, camera, screenX, screenY);

    if (result != null) {
        return result;
    }

    result = GeomUtils.getContactPointFromScreenPos(getGrid(), camera, screenX, screenY);

    return result == null ? Vector3f.ZERO : result;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:24,代码来源:AbstractSceneEditor3DState.java

示例3: startCameraMoving

import com.jme3.renderer.Camera; //导入依赖的package包/类
/**
 * Start to move the camera.
 */
@JMEThread
private void startCameraMoving(final int key) {

    if (Config.DEV_CAMERA_DEBUG && LOGGER.isEnabled(LoggerLevel.DEBUG)) {
        LOGGER.debug(this, "start camera moving[" + cameraMoving + "] for key " + key);
    }

    if (cameraMoving.get() == 0) {

        final Camera camera = EDITOR.getCamera();
        final Node nodeForCamera = getNodeForCamera();
        nodeForCamera.setLocalTranslation(camera.getLocation());

        final EditorCamera editorCamera = notNull(getEditorCamera());
        editorCamera.setTargetDistance(0);
    }

    final boolean[] cameraKeysState = getCameraKeysState();

    if (!cameraKeysState[key]) {
        cameraKeysState[key] = true;
        cameraMoving.incrementAndGet();
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:28,代码来源:AdvancedAbstractEditor3DState.java

示例4: moveDirectionCamera

import com.jme3.renderer.Camera; //导入依赖的package包/类
/**
 * Move a camera to direction.
 *
 * @param value the value to move.
 */
@JMEThread
private void moveDirectionCamera(final float value, final boolean isAction, final boolean isPressed, final int key) {
    if (!canCameraMove()) return;
    if (isAction && isPressed) startCameraMoving(key);
    else if (isAction) finishCameraMoving(key, false);
    if (!isCameraMoving() || isAction) return;

    final EditorCamera editorCamera = getEditorCamera();
    if (editorCamera == null) return;

    final Camera camera = EDITOR.getCamera();
    final Node nodeForCamera = getNodeForCamera();

    final LocalObjects local = LocalObjects.get();
    final Vector3f direction = camera.getDirection(local.nextVector());
    direction.multLocal(value * cameraSpeed);
    direction.addLocal(nodeForCamera.getLocalTranslation());

    nodeForCamera.setLocalTranslation(direction);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:26,代码来源:AdvancedAbstractEditor3DState.java

示例5: moveSideCamera

import com.jme3.renderer.Camera; //导入依赖的package包/类
/**
 * Move a camera to side.
 *
 * @param value the value to move.
 */
@JMEThread
private void moveSideCamera(final float value, final boolean isAction, final boolean isPressed, final int key) {
    if (!canCameraMove()) return;
    if (isAction && isPressed) startCameraMoving(key);
    else if (isAction) finishCameraMoving(key, false);
    if (!isCameraMoving() || isAction) return;

    final EditorCamera editorCamera = getEditorCamera();
    if (editorCamera == null) return;

    final Camera camera = EDITOR.getCamera();
    final Node nodeForCamera = getNodeForCamera();

    final LocalObjects local = LocalObjects.get();
    final Vector3f left = camera.getLeft(local.nextVector());
    left.multLocal(value * cameraSpeed);
    left.addLocal(nodeForCamera.getLocalTranslation());

    nodeForCamera.setLocalTranslation(left);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:26,代码来源:AdvancedAbstractEditor3DState.java

示例6: CombinedViewport

import com.jme3.renderer.Camera; //导入依赖的package包/类
public CombinedViewport(String name,
        RenderManager renderManager,
        Camera mainCam,
        float fov,
        float near,
        float far,
        Node node,
        FilterPostProcessor fpp
) {
    this.name = name;
    this.cam = new Camera(mainCam.getWidth(),mainCam.getHeight());
    this.viewPort = renderManager.createMainView(name, cam);
    this.fov = fov;
    this.near = near;
    this.far = far;
    this.aspect = (float) mainCam.getWidth() / (float) mainCam.getHeight();
    this.node = node;
    this.fpp = fpp;
    setupView();
}
 
开发者ID:ZoltanTheHun,项目名称:SkyHussars,代码行数:21,代码来源:CombinedViewport.java

示例7: createSimpleChaseCamera

import com.jme3.renderer.Camera; //导入依赖的package包/类
public static ChaseCamera createSimpleChaseCamera(Camera camera
            , InputManager inputManager) {
        ChaseCamera chaseCam = new ChaseCamera(camera, inputManager);
        
        // 开启镜头跟随可能让部分人容易犯头晕
//        chaseCam.setSmoothMotion(true);
//        chaseCam.setTrailingEnabled(false);
        
        chaseCam.setInvertVerticalAxis(true);
        chaseCam.setLookAtOffset(Vector3f.UNIT_Y.mult(2f));
        chaseCam.setZoomSensitivity(0.5f);
        chaseCam.setRotationSpeed(5f);
        chaseCam.setRotationSensitivity(5);
        chaseCam.setMaxDistance(15);
        chaseCam.setMinDistance(2f);
        chaseCam.setDefaultDistance(15);
        chaseCam.setChasingSensitivity(5);
        chaseCam.setDownRotateOnCloseViewOnly(true); 
        chaseCam.setUpVector(Vector3f.UNIT_Y);
        // 不要隐藏光标,否则在MAC系统下鼠标点击后会上下错位
        chaseCam.setHideCursorOnRotate(false);
        return chaseCam;
    }
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:24,代码来源:SceneTools.java

示例8: renderQueue

import com.jme3.renderer.Camera; //导入依赖的package包/类
public void renderQueue(Bucket bucket, RenderManager rm, Camera cam, boolean clear) {
    switch (bucket) {
        case Gui:
            renderGeometryList(guiList, rm, cam, clear);
            break;
        case Opaque:
            renderGeometryList(opaqueList, rm, cam, clear);
            break;
        case Sky:
            renderGeometryList(skyList, rm, cam, clear);
            break;
        case Transparent:
            renderGeometryList(transparentList, rm, cam, clear);
            break;
        case Translucent:
            renderGeometryList(translucentList, rm, cam, clear);
            break;

        default:
            throw new UnsupportedOperationException("Unsupported bucket type: " + bucket);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:RenderQueue.java

示例9: initialize

import com.jme3.renderer.Camera; //导入依赖的package包/类
public void initialize(RenderManager rm, ViewPort vp) {
    renderManager = rm;
    renderer = rm.getRenderer();
    viewPort = vp;
    fsQuad = new Picture("filter full screen quad");

    Camera cam = vp.getCamera();


    //save view port diensions
    left = cam.getViewPortLeft();
    right = cam.getViewPortRight();
    top = cam.getViewPortTop();
    bottom = cam.getViewPortBottom();
    originalWidth = cam.getWidth();
    originalHeight = cam.getHeight();
    //first call to reshape
    reshape(vp, cam.getWidth(), cam.getHeight());

}
 
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:FilterPostProcessor.java

示例10: postQueue

import com.jme3.renderer.Camera; //导入依赖的package包/类
@Override
    public void postQueue(RenderQueue rq) {
        Camera sceneCam = rm.getCurrentCamera();

        // 如果水体在镜头外就不要渲染,浪费性能。
        FrustumIntersect fi = sceneCam.contains(waterPlane.getWorldBound());
        if (fi != FrustumIntersect.Outside) {
//            LOG.log(Level.INFO, "Need render simple water. FrustumIntersect={0}", fi);
            WaterUtils.updateReflectionCam(reflectionCam, plane, sceneCam);
            rm.renderViewPort(reflectionView, savedTpf);
            rm.getRenderer().setFrameBuffer(vp.getOutputFrameBuffer());
            rm.setCamera(sceneCam, false);
        } 
//        else {
//            LOG.log(Level.INFO, "Don't need render simple water.");
//        }

    }
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:19,代码来源:VerySimpleWaterProcessor.java

示例11: rotateScreenAligned

import com.jme3.renderer.Camera; //导入依赖的package包/类
/**
 * Rotate the billboard so it points directly opposite the direction the
 * camera's facing
 *
 * @param camera
 *            Camera
 */
private void rotateScreenAligned(Camera camera) {
    // coopt diff for our in direction:
    look.set(camera.getDirection()).negateLocal();
    // coopt loc for our left direction:
    left.set(camera.getLeft()).negateLocal();
    orient.fromAxes(left, camera.getUp(), look);
    Node parent = spatial.getParent();
    Quaternion rot=new Quaternion().fromRotationMatrix(orient);
    if ( parent != null ) {
        rot =  parent.getWorldRotation().inverse().multLocal(rot);
        rot.normalize();
    }
    spatial.setLocalRotation(rot);
    spatial.updateGeometricState();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:BillboardControl.java

示例12: 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

示例13: 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

示例14: renderFromControl

import com.jme3.renderer.Camera; //导入依赖的package包/类
/**
 * Callback from Control.render(), do not use.
 * 
 * @param rm
 * @param vp 
 */
private void renderFromControl(RenderManager rm, ViewPort vp) {
    Camera cam = vp.getCamera();

    if (meshType == ParticleMesh.Type.Point) {
        float C = cam.getProjectionMatrix().m00;
        C *= cam.getWidth() * 0.5f;

        // send attenuation params
        this.getMaterial().setFloat("Quadratic", C);
    }

    Matrix3f inverseRotation = Matrix3f.IDENTITY;
    TempVars vars = null;
    if (!worldSpace) {
        vars = TempVars.get();

        inverseRotation = this.getWorldRotation().toRotationMatrix(vars.tempMat3).invertLocal();
    }
    particleMesh.updateParticleData(particles, cam, inverseRotation);
    if (!worldSpace) {
        vars.release();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:30,代码来源:ParticleEmitter.java

示例15: updateFrustumPoints2

import com.jme3.renderer.Camera; //导入依赖的package包/类
/**
 * Updates a points arrays with the frustum corners of the provided camera.
 * @param viewCam
 * @param points 
 */
public static void updateFrustumPoints2(Camera viewCam, Vector3f[] points) {
    int w = viewCam.getWidth();
    int h = viewCam.getHeight();
    float n = viewCam.getFrustumNear();
    float f = viewCam.getFrustumFar();

    points[0].set(viewCam.getWorldCoordinates(new Vector2f(0, 0), n));
    points[1].set(viewCam.getWorldCoordinates(new Vector2f(0, h), n));
    points[2].set(viewCam.getWorldCoordinates(new Vector2f(w, h), n));
    points[3].set(viewCam.getWorldCoordinates(new Vector2f(w, 0), n));

    points[4].set(viewCam.getWorldCoordinates(new Vector2f(0, 0), f));
    points[5].set(viewCam.getWorldCoordinates(new Vector2f(0, h), f));
    points[6].set(viewCam.getWorldCoordinates(new Vector2f(w, h), f));
    points[7].set(viewCam.getWorldCoordinates(new Vector2f(w, 0), f));
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:ShadowUtil.java


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