Package com.jme.renderer

Examples of com.jme.renderer.Camera


     * Calculates the ray to use for picking, based on the given screen coordinates.
     */
    Ray calcPickRayWorld (int x, int y) {
        Ray result = null;
  // Get the world space coordinates of the eye position
  Camera camera = cameraComp.getCamera();
  Vector3f eyePosWorld = camera.getLocation();

  // Convert the event from AWT coords to JME float screen space.
  // Need to invert y because (0f, 0f) is at the button left corner.
  eventPointScreen.setX((float)x);
  eventPointScreen.setY((float)(canvas.getHeight()-1-y));

  // Get the world space coordinates of the screen space point from the event
  // (The glass plate of the screen is considered to be at at z = 0 in world space
        try { // May fail if jME thinks the camera matrix is singular
            camera.getWorldCoordinates(eventPointScreen, 0f, eventPointWorld);
            // Compute the diff and create the ray
            eventPointWorld.subtract(eyePosWorld, directionWorld);
            result = new Ray(eyePosWorld, directionWorld.normalize());
        } catch (ArithmeticException ex) {
            logger.log(Level.SEVERE,"Problem getting world space coords for pick ray.", ex);
View Full Code Here


     * {@inheritDoc}
     */
    public void viewPropertiesChange(ViewProperty property) {
        // Update the camera properties, if it has been created already.
        if (cameraComponent != null) {
            Camera camera = cameraComponent.getCamera();
            float fov = viewProperties.getFieldOfView();
            float frontClip = viewProperties.getFrontClip();
            float backClip = viewProperties.getBackClip();
            camera.setFrustumPerspective(fov, aspect, frontClip, backClip);
        }
    }
View Full Code Here

    private class MyCameraListener implements ViewManager.CameraListener {
        public void cameraMoved(CellTransform cameraWorldTransform) {
      synchronized (cameraLock) {
    cameraWorldTransform.getTranslation(cameraPositionWorld);
    if (cameraComp != null) {
        Camera camera = cameraComp.getCamera();
        cameraModelViewMatrix = ((AbstractCamera)camera).getModelViewMatrix();
        cameraModelViewMatrixInverse = null;
    }
      }
  }
View Full Code Here

  /**
   * Create the chase camera and assign a tank to it.
   *
   */
  protected void buildCamera() {
    Camera cam = renderer.getCamera();

    // initialize the perspective
    cam.setFrustumPerspective(60.0f, (float) display.getWidth()
        / (float) display.getHeight(), nearFrustrum, farFrustrum);
    cam.update();

    // initialize the control scheme
    chaseCam = new MouseLookCamera(cam, player.getControlledObject(), root,
        15, 0, 0);
  }
View Full Code Here

        addFrameListener( new FrameListener()
        {

            public void onFrame( final double secondsSinceLastFrame )
            {
                final Camera camera = myCanvas3D.getCamera();
                if ( camera != null )
                {
                    final Vector3f currentCameraPosition = camera.getLocation();
                    if ( !currentCameraPosition.equals( myPreviousCameraPosition ) )
                    {
                        // Grow quad tree if necessary
                        myQuadTree.getRootNode().growToInclude( currentCameraPosition.x,
                                                                currentCameraPosition.y,
View Full Code Here

    //----------------------------------------------------------------------
    // MouseWheelListener Implementation

    public void mouseWheelMoved( final MouseWheelEvent e )
    {
        final Camera camera = getCamera();

        final float movementAmount = -e.getWheelRotation() * getSensitivity() * getAltitudeFactor();

        // TODO: Implement inertia, acceleration, locked movement, and keyboard input

        camera.getLocation().scaleAdd( movementAmount, camera.getDirection(), camera.getLocation() );
        camera.onFrameChange();
    }
View Full Code Here

    public void mouseDragged( final MouseEvent e )
    {
        if ( isMouseButtonPressed( e, myButtonDownMask ) )
        {
            final Camera camera = getCamera();
            if ( camera != null )
            {
                // Calculate mouse movement
                final int currentX = e.getX();
                final int currentY = e.getY();
View Full Code Here

    /**
     * @return a multiplication factor calculated from the altitude, used to adjust the move and pan operations.
     */
    protected final float getAltitudeFactor()
    {
        final Camera camera = getCamera();
        if ( camera != null )
        {
            final float altitude = getAltitudeAt( camera.getLocation() );

            // Less movement lower, more higher.  Use a non linear function (square root) of the altitude.
            return (float) ( 0.4 * Math.sqrt( Math.abs( altitude ) ) + 0.01f );
        }
        else
View Full Code Here

                {
                    aspectRatio = width / height;
                }

                // Set aspect ratio and field of view to camera
                final Camera camera = getCamera();
                camera.setFrustumPerspective( DEFAULT_FIELD_OF_VIEW_DEGREES,
                                              aspectRatio,
                                              camera.getFrustumNear(),
                                              camera.getFrustumFar() );
            }
        }
View Full Code Here

TOP

Related Classes of com.jme.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.