Package com.jme.math

Examples of com.jme.math.Vector2f


        }
    }

    /** Returns the pixel scale vector for the current mode. */
    public Vector2f getPixelScaleCurrent () {
        Vector2f pixelScale;
        if (ortho) {
            pixelScale = getPixelScaleOrtho();
        } else {
            pixelScale = getPixelScale();
        }
View Full Code Here


    /**
     * Called by the UI to indicate the start of an interactive planar move.
     */
    public synchronized void userMovePlanarStart () {
        userMovePlanarDragVectorPrev = new Vector2f();
    }
View Full Code Here

     * Called by the UI to indicate a drag vector update during interactive planar move.
     */
    public synchronized void userMovePlanarUpdate (Vector2f dragVector) {
       
        // Calculate the delta of the movement since the last update
        Vector2f deltaDragVector = dragVector.clone();
        deltaDragVector.subtractLocal(userMovePlanarDragVectorPrev);
        userMovePlanarDragVectorPrev = dragVector;

        applyDeltaTranslationUser(new Vector3f(deltaDragVector.x, deltaDragVector.y, 0f), true);
    }
View Full Code Here

    private Dimension userResizeCalcWindowNewSize (Vector2f dragVector) {
        if (dragVector.x == 0 && dragVector.y == 0) return null;

        // Convert local coords drag vector to a pixel vector
        Vector2f pixelScale = getPixelScaleCurrent();
        //System.err.println("pixelScale = " + pixelScale);
        int deltaWidth = (int)(dragVector.x / pixelScale.x);
        int deltaHeight = (int)(dragVector.y / pixelScale.y);

        //System.err.println("deltaWH = " + deltaWidth + ", " + deltaHeight);
View Full Code Here

        if (type != Type.PRIMARY && type != Type.UNKNOWN && parent != null) {

            // Convert pixel offset to local coords and add it in
            // TODO: does the width/height need to include the scroll bars?
            Vector2f pixelScale = getPixelScaleCurrent();
            Dimension parentSize = parent.getSizeApp()// TODO: is this now unused?
            trans.y += parentViewNewSize.height * pixelScale.y / 2f;
            trans.y -= y * pixelScale.y / 2f;
        }

View Full Code Here

                translation.y = locationOrtho.y + offset.y;
                logger.fine("translation 1 = " + translation);
               
                // Convert pixel offset to local coords and add it in
                Dimension parentSize = parent.getSizeApp();
                Vector2f pixelScaleOrtho = parent.getPixelScaleOrtho();
                logger.fine("parentSize = " + parentSize);
                translation.x += -parentSize.width * pixelScaleOrtho.x / 2f;
                translation.y += parentSize.height * pixelScaleOrtho.y / 2f;
                logger.fine("translation 2 = " + translation);
                logger.fine("sizeApp = " + sizeApp);
                pixelScaleOrtho = getPixelScaleOrtho();
                translation.x += sizeApp.width * pixelScaleOrtho.x / 2f;
                translation.y -= sizeApp.height * pixelScaleOrtho.y / 2f;
                logger.fine("translation 3 = " + translation);
                logger.fine("pixelOffset = " + pixelOffset);
                translation.x += pixelOffset.x * pixelScaleOrtho.x;
                translation.y -= pixelOffset.y * pixelScaleOrtho.y;
                logger.fine("translation 4 = " + translation);
            }
        } else {   

            // Initialize to the first part of the offset (the local coordinate translation)
            logger.fine("view = " + this);
            logger.fine("parent = " + parent);
            logger.fine("offset = " + offset);
            translation.x = offset.x;
            translation.y = offset.y;
            logger.fine("translation 1 = " + translation);

            if (type != Type.PRIMARY && type != Type.UNKNOWN && parent != null) {

                // Convert pixel offset to local coords and add it in
                // TODO: does the width/height need to include the scroll bars?
                Vector2f pixelScale = parent.getPixelScaleCurrent();
                Dimension parentSize = parent.getSizeApp();
                logger.fine("parentSize = " + parentSize);
                translation.x += -parentSize.width * pixelScale.x / 2f;
                translation.y += parentSize.height * pixelScale.y / 2f;
                logger.fine("translation 2 = " + translation);
View Full Code Here

     */
    @Override
    public void setServerState(CellServerState state) {
        super.setServerState(state);
        App2DCellServerState serverState = (App2DCellServerState) state;
        pixelScale = new Vector2f(serverState.getPixelScaleX(), serverState.getPixelScaleY());

        ViewComponentServerState vcss =
                (ViewComponentServerState) serverState.getComponentServerState(ViewComponentServerState.class);
        logger.info("vcss = " + vcss);
        if (vcss != null) {
View Full Code Here

        //System.err.println("***** height = " + height);

        if (vec.x == 0 && vec.y == 0) return;

        // Convert local coords drag vector to a pixel vector
        Vector2f pixelScale = view.getPixelScaleCurrent();
        int deltaWidth = (int)(vec.x / pixelScale.x);
        int deltaHeight = (int)(vec.y / pixelScale.y);

        //System.err.println("deltaWH = " + deltaWidth + ", " + deltaHeight);

View Full Code Here

            viewWidth3D -= frame.getLeftSideWidth() + frame.getRightSideWidth();
            viewHeight3D -= frame.getHeaderHeight() + frame.getBottomSideHeight();
        }

        // Convert to window coordinates
        Vector2f pixelScale = view.getPixelScaleCurrent();
        int widthPix = (int) (viewWidth3D / pixelScale.x);
        int heightPix = (int) (viewHeight3D / pixelScale.y);

        //System.err.println("***** widthPix = " + widthPix);
        //System.err.println("***** heightPix = " + heightPix);
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public Vector2f getLocation(HUDComponent component) {
        Vector2f location = new Vector2f();

        if ((component != null) && (hudViewMap.get(component) != null)) {
            // get HUD component's view width
            HUDView2D view2d = (HUDView2D) hudViewMap.get(component);
            float compWidth = view2d.getDisplayerLocalWidth();
            float compHeight = view2d.getDisplayerLocalHeight();

            // get the bounds of the HUD containing the component
            int hudWidth = hud.getWidth();
            int hudHeight = hud.getHeight();

            location = positionMap.get(component);
            if (location == null) {
                // component is new, place it in the next position in the linear flow
                location = new Vector2f(nextX, nextY);
                // next free position in flow layout
                nextX += compWidth + X_GAP;
            }

            int x = (int) location.x;
            int y = (int) location.y;

            if (x < hud.getX() + MIN_LEFT_MARGIN) {
                x = hud.getX() + MIN_LEFT_MARGIN;
            } else if (x + compWidth > hud.getX() + hudWidth - MIN_RIGHT_MARGIN) {
                // start a new row, above this one
                x = MIN_LEFT_MARGIN;
                y += compHeight + Y_GAP;
            }
            if (y < hud.getY() + MIN_BOTTOM_MARGIN) {
                y = hud.getY() + MIN_BOTTOM_MARGIN;
            } else if (y + compHeight > hud.getY() + hudHeight - MIN_TOP_MARGIN) {
                y = (int) (hud.getY() + hudHeight - MIN_TOP_MARGIN - compHeight);
            }

            // adjusted location to fit bounds of HUD
            location.set(x, y);

            // remember the position of the component
            positionMap.put(component, location);
        }

View Full Code Here

TOP

Related Classes of com.jme.math.Vector2f

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.