Package com.jme3.renderer

Examples of com.jme3.renderer.Camera


            GeometryList outputGeometryList) {
        for (int i = 0; i < inputGeometryList.size(); i++) {
            Geometry g = inputGeometryList.get(i);
            boolean inFrustum = false;
            for (int j = 0; j < cameras.length && inFrustum == false; j++) {
                Camera camera = cameras[j];
                int planeState = camera.getPlaneState();
                camera.setPlaneState(0);
                inFrustum = camera.contains(g.getWorldBound()) != Camera.FrustumIntersect.Outside;
                camera.setPlaneState(planeState);
            }
            if (inFrustum) {
                outputGeometryList.add(g);
            }
        }
View Full Code Here


    cam.setViewPort(.5f, 1f, 0f, 0.5f);
    cam.setLocation(new Vector3f(3.3212643f, 4.484704f, 4.2812433f));
    cam.setRotation(new Quaternion(-0.07680723f, 0.92299235f, -0.2564353f, -0.27645364f));

    // Setup second view
    Camera cam2 = cam.clone();
    cam2.setViewPort(0f, 0.5f, 0f, 0.5f);
    cam2.setLocation(new Vector3f(-0.10947256f, 1.5760219f, 4.81758f));
    cam2.setRotation(new Quaternion(0.0010108891f, 0.99857414f, -0.04928594f, 0.020481428f));

    ViewPort view2 = renderManager.createMainView("Bottom Left", cam2);
    view2.setClearFlags(true, true, true);
    view2.attachScene(rootNode);

    // Setup third view
    Camera cam3 = cam.clone();
    cam3.setViewPort(0f, .5f, .5f, 1f);
    cam3.setLocation(new Vector3f(0.2846221f, 6.4271426f, 0.23380789f));
    cam3.setRotation(new Quaternion(0.004381671f, 0.72363687f, -0.69015175f, 0.0045953835f));

    ViewPort view3 = renderManager.createMainView("Top Left", cam3);
    view3.setClearFlags(true, true, true);
    view3.attachScene(rootNode);

    // Setup fourth view
    Camera cam4 = cam.clone();
    cam4.setViewPort(.5f, 1f, .5f, 1f);
    cam4.setLocation(new Vector3f(4.775564f, 1.4548365f, 0.11491505f));
    cam4.setRotation(new Quaternion(0.02356979f, -0.74957186f, 0.026729556f, 0.66096294f));

    ViewPort view4 = renderManager.createMainView("Top Right", cam4);
    view4.setClearFlags(true, true, true);
    view4.attachScene(rootNode);

    // test multiview for gui
    guiViewPort.getCamera().setViewPort(.5f, 1f, .5f, 1f);

    // Setup second gui view
    Camera guiCam2 = guiViewPort.getCamera().clone();
    guiCam2.setViewPort(0f, 0.5f, 0f, 0.5f);
    ViewPort guiViewPort2 = renderManager.createPostView("Gui 2", guiCam2);
    guiViewPort2.setClearFlags(false, false, false);
    guiViewPort2.attachScene(guiViewPort.getScenes().get(0));

  }
View Full Code Here

     *
     * @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);
        }

View Full Code Here

        if (sceneStructure != null) {
            Structure renderData = (Structure) sceneStructure.getFieldValue("r");
            width = ((Number) renderData.getFieldValue("xsch")).shortValue();
            height = ((Number) renderData.getFieldValue("ysch")).shortValue();
        }
        Camera camera = new Camera(width, height);
        int type = ((Number) structure.getFieldValue("type")).intValue();
        if (type != 0 && type != 1) {
            LOGGER.log(Level.WARNING, "Unknown camera type: {0}. Perspective camera is being used!", type);
            type = 0;
        }
        // type==0 - perspective; type==1 - orthographic; perspective is used as default
        camera.setParallelProjection(type == 1);
        float aspect = width / (float) height;
        float fovY; // Vertical field of view in degrees
        float clipsta = ((Number) structure.getFieldValue("clipsta")).floatValue();
        float clipend = ((Number) structure.getFieldValue("clipend")).floatValue();
        if (type == 0) {
            // Convert lens MM to vertical degrees in fovY, see Blender rna_Camera_angle_get()
            // Default sensor size prior to 2.60 was 32.
            float sensor = 32.0f;
            boolean sensorVertical = false;
            Number sensorFit = (Number) structure.getFieldValue("sensor_fit");
            if (sensorFit != null) {
                // If sensor_fit is vert (2), then sensor_y is used
                sensorVertical = sensorFit.byteValue() == 2;
                String sensorName = "sensor_x";
                if (sensorVertical) {
                    sensorName = "sensor_y";
                }
                sensor = ((Number) structure.getFieldValue(sensorName)).floatValue();
            }
            float focalLength = ((Number) structure.getFieldValue("lens")).floatValue();
            float fov = 2.0f * FastMath.atan((sensor / 2.0f) / focalLength);
            if (sensorVertical) {
                fovY = fov * FastMath.RAD_TO_DEG;
            } else {
                // Convert fov from horizontal to vertical
                fovY = 2.0f * FastMath.atan(FastMath.tan(fov / 2.0f) / aspect) * FastMath.RAD_TO_DEG;
            }
        } else {
            // This probably is not correct.
            fovY = ((Number) structure.getFieldValue("ortho_scale")).floatValue();
        }
        camera.setFrustumPerspective(fovY, aspect, clipsta, clipend);
        return new CameraNode(null, camera);
    }
View Full Code Here

     * @throws BlenderFileException
     *             an exception is thrown when there are problems with the
     *             blender file
     */
    private CameraNode toCamera249(Structure structure) throws BlenderFileException {
        Camera camera = new Camera(DEFAULT_CAM_WIDTH, DEFAULT_CAM_HEIGHT);
        int type = ((Number) structure.getFieldValue("type")).intValue();
        if (type != 0 && type != 1) {
            LOGGER.log(Level.WARNING, "Unknown camera type: {0}. Perspective camera is being used!", type);
            type = 0;
        }
        // type==0 - perspective; type==1 - orthographic; perspective is used as default
        camera.setParallelProjection(type == 1);
        float aspect = 0;
        float clipsta = ((Number) structure.getFieldValue("clipsta")).floatValue();
        float clipend = ((Number) structure.getFieldValue("clipend")).floatValue();
        if (type == 0) {
            aspect = ((Number) structure.getFieldValue("lens")).floatValue();
        } else {
            aspect = ((Number) structure.getFieldValue("ortho_scale")).floatValue();
        }
        camera.setFrustumPerspective(aspect, camera.getWidth() / camera.getHeight(), clipsta, clipend);
        return new CameraNode(null, camera);
    }
View Full Code Here

            camera.setFrustumFar(SAXUtil.parseFloat(attribs.getValue("farPlaneDist")));
        }
    }
   
    private void parseCamera(Attributes attribs) throws SAXException {
        camera = new Camera(DEFAULT_CAM_WIDTH, DEFAULT_CAM_HEIGHT);
        if (SAXUtil.parseString(attribs.getValue("projectionType"), "perspective").equals("parallel")){
            camera.setParallelProjection(true);
        }
        float fov = SAXUtil.parseFloat(attribs.getValue("fov"), 45f);
        if (fov < FastMath.PI) {
View Full Code Here

        cameraBody.setMaterial(blackAluminumTexture);
        cameraBody.rotate((float) Math.PI / 2, 0f, 0f);
        cameraBody.move(-6, -50 / 2 + 15 / 2, 8 + 3);
        head.attachChild(cameraBody);
       
        Camera cam = defaultCamera.clone();
        cam.setViewPort(0f, 0.5f, 0.5f, 1.0f);
        cam.setFrustumFar(500);
        cam.update();
       
        CameraNode camNode = new CameraNode("camera", cam);
        camNode.setControlDir(CameraControl.ControlDirection.SpatialToCamera);
        camNode.rotate((float) Math.PI / 2, (float) Math.PI, 0);
        camNode.move(-6, -50 / 2 + 15 / 2, 8 + 3);
View Full Code Here

    return groundColor;
  }

  public void worldInitialized() {
    CameraNode camNode = world.getPlayer().getCameraNode();
    Camera c = camNode.getCamera();
    float width = Math.abs(c.getFrustumRight() - c.getFrustumLeft());
    float height = Math.abs(c.getFrustumTop() - c.getFrustumBottom());
    float distance = c.getFrustumFar();
    float scale = distance / c.getFrustumNear();
    distance = distance * (255f / 256f);
    width *= scale;
    height *= scale;
    geom = new Geometry("SkyPlane", new Quad(width, height));
    geom.setLocalRotation(Quaternion.DIRECTION_Z.opposite());
    geom.setLocalTranslation(c.getDirection().mult(-distance).add(new Vector3f(-width / 2, height / 2, 0)));
    geom.setMaterial(mat);
    camNode.attachChild(geom);
  }
View Full Code Here

        return matrix.determinant();
    }

    public static final CollisionResult getClosestMouseHitResult(SimpleApplication app) {
        Camera cam = app.getCamera();
        CollisionResult result;

        ray.setOrigin(cam.getLocation());
        ray.setDirection(get3DMousePosition(app, v3f_0).subtractLocal(cam.getLocation()));

        results.clear();
        app.getRootNode().collideWith(ray, results);

        result = results.getClosestCollision();
View Full Code Here

    }

    @Override
    public void simpleInitApp() {
        Box b = new Box(Vector3f.ZERO, 1, 1, 1);
        Geometry geom = new Geometry("Box", b);
        geom.updateModelBound();

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
        mat.setColor("m_Color", ColorRGBA.Blue);
        geom.setMaterial(mat);

        rootNode.attachChild(geom);
    }
View Full Code Here

TOP

Related Classes of com.jme3.renderer.Camera

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.