Package com.jme.math

Examples of com.jme.math.Vector3f


                    // Figure out the world coordinates of the center of the
                    // affordance.
                    Entity entity = event.getEntity();
                    RenderComponent rc = (RenderComponent)entity.getComponent(RenderComponent.class);
                    Vector3f centerWorld = rc.getSceneRoot().getWorldTranslation();

                    // Compute the vector from the starting point of the drag
                    // to the center of the affordance in world coordinates.
                    dragStartVectorWorld = dragStartWorld.subtract(centerWorld);
                    dragStartRadius = dragStartVectorWorld.length();

                    // Show the resize label, make sure we do this in an
                    // AWT Event Thread
                    showResizeLabel(awtMouseEvent);

                    // Tell the listeners that a resizing has started
                    fireResizingStarted();
                } else if (be.isReleased() == true) {
                    // Hide the resize label, make sure we do this in an
                    // AWT Event Thread
                    hideResizeLabel();
                }
                return;
            }

            // If not a drag motion, just return, we don't care about the event
            if (!(event instanceof MouseDraggedEvent3D)) {
                return;
            }

            // Get the vector of the drag motion from the initial starting
            // point in world coordinates.
            MouseDraggedEvent3D dragEvent = (MouseDraggedEvent3D) event;
            Vector3f dragWorld = dragEvent.getDragVectorWorld(dragStartWorld,
                    dragStartScreen, new Vector3f());

            // Figure out what the vector is of the current drag location in
            // world coodinates. This gives a vector from the center of the
            // affordance. We just take the vector (from the center) of the
            // start of the drag and add the bit we dragged the mouse. Also
            // compute the length of this radius
            Vector3f dragEndVectorWorld = dragStartVectorWorld.add(dragWorld);
            float dragEndRadius = dragEndVectorWorld.length();

            // Take the ratio of the radius between the start and the end. That
            // will give us the amount to scale the cell
            float scale = dragEndRadius / dragStartRadius;
View Full Code Here


                    // primary View Cell exists at this point, since the menu
                    // item is not added until a primary View Cell exists.
                    ViewManager viewManager = ViewManager.getViewManager();
                    ViewCell viewCell = viewManager.getPrimaryViewCell();
                    CellTransform transform = viewCell.getWorldTransform();
                    Vector3f translation = transform.getTranslation(null);

                    // This is the offset from the avatar view Cell to place the
                    // camera
                    Vector3f offset = new Vector3f(0.0f, 4.0f, -10.0f);

                    // force an update
                    camState.setCameraPosition(translation.add(offset));
                }

                // OWL issue #125: Reinitialize the gesture HUD panel with the
                // current avatar character.
                if (gestureHUDRef != null && gestureHUDRef.get() != null) {
                    if (newAvatar instanceof WlAvatarCharacter) {
                        gestureHUDRef.get().setAvatarCharacter((WlAvatarCharacter) newAvatar,
                                                               gestureMI.getState());
                    } else {
                        gestureHUDRef.get().setVisible(false);
                    }
                }
            }
        };

        // A menu item for the chase camera
        chaseCameraMI = new JRadioButtonMenuItem(bundle.getString("Chase_Camera"));
        chaseCameraMI.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                // Fetch the initial position of the camera. This is based upon
                // the current avatar position. We can assume that the primary
                // View Cell exists at this point, since the menu item is not
                // added until a primary View Cell exists.
                ViewManager viewManager = ViewManager.getViewManager();
                ViewCell viewCell = viewManager.getPrimaryViewCell();
                CellTransform transform = viewCell.getWorldTransform();
                Vector3f translation = transform.getTranslation(null);

                // This is the offset from the avatar view Cell to place the
                // camera
                Vector3f offset = new Vector3f(0.0f, 4.0f, -10.0f);

                // Create the camera state if it does not yet exist. Initialize
                // the initial position to that of the view Cell.
                if (camState == null) {
                    camModel = (ChaseCamModel) CameraModels.getCameraModel(ChaseCamModel.class);
                    camState = new ChaseCamState(offset, new Vector3f(0.0f, 1.8f, 0.0f));
                    camState.setDamping(1.7f);
                    camState.setLookAtDamping(1.7f);
                }
                camState.setCameraPosition(translation.add(offset));
                camState.setTargetCharacter(avatarCellRenderer.getAvatarCharacter());
View Full Code Here

                drawBounds(cell.getWorldBounds(), g, true, Color.RED);
            } else {
                drawBounds(cell.getWorldBounds(), g, false, Color.BLACK);
            }

            Vector3f cellPos = cell.getWorldTransform().getTranslation(null);
            g.drawString(cell.getName(), cellPos.x*scale, cellPos.z*scale);
        }
View Full Code Here

        // load initial coordinates
        float x = Float.parseFloat(props.getProperty(X_PROP, X_DEFAULT));
        float y = Float.parseFloat(props.getProperty(Y_PROP, Y_DEFAULT));
        float z = Float.parseFloat(props.getProperty(Z_PROP, Z_DEFAULT));
      
        mover = new GroupMover(new Vector3f(x + (group*groupSeparation), y, z),
                               avatar);
       
        mover.start();
    }
View Full Code Here

    public void updateCommon() throws InstantiationException {
       
        ClientContextJME.getWorldManager().addRenderUpdater(new RenderUpdater() {
            public void update(Object arg0) {
                if (horizBar != null) {
                    horizBar.setLocalTranslationNoUpdater(new Vector3f(horizX, horizY, Z_OFFSET));
                }
                if (vertBar != null) {
                    vertBar.setLocalTranslationNoUpdater(new Vector3f(vertX, vertY, Z_OFFSET));
                }
                if (localToCellNode != null) {
                    localToCellNode.setLocalTranslation(origin);
                    ClientContextJME.getWorldManager().addToUpdateList(localToCellNode);
                }
View Full Code Here

        rightSide.updateLayout();
        bottomSide.updateLayout();

        // Origin of the resize corner coordinate system is the lower right
        // corner of the view.
        origin = new Vector3f(0f, 0f, Z_OFFSET);

        horizX = (viewWidth - Frame2DCell.RESIZE_CORNER_WIDTH) / 2f;
        horizY = (-viewHeight - Frame2DCell.SIDE_THICKNESS) / 2f;
        horizWidth = RESIZE_CORNER_WIDTH;
        horizHeight = Frame2DCell.SIDE_THICKNESS;
View Full Code Here

    // Uses: type, ortho, parent, stack
    @Override
    protected Vector3f calcStackTranslation () {
        if (isOrtho()) {
            return new Vector3f(0f, 0f, 0f);
        } else {
            int stackPos = window.getStackPosition();
            if (stackPos < 0) {
                logger.info("ERROR: stack position cannot be calculated for window " + window);
                stackPos = 0;
            }
            logger.fine("View " + this);
            logger.fine("zOrder = " + window.getZOrder());
            logger.fine("stackPos = " + stackPos);
            float localZ;
            if ((type == Type.POPUP || type == Type.SECONDARY) && parent != null) {
                Window2D parentWindow = ((View2DCell)parent).window;
                if (parentWindow == null) {
                    localZ = 0f;
                } else {
                    int stackPosParent = parentWindow.getStackPosition();
                    logger.fine("stackPosParent = " + stackPosParent);
                    logger.fine("zOrder Parent = " + parentWindow.getZOrder());
                    localZ = (stackPos - stackPosParent) * STACK_GAP;
                }
            } else {
                localZ = stackPos * STACK_GAP;
            }

            logger.fine("localZ = " + localZ);
            return new Vector3f(0f, 0f, localZ);
        }
    }
View Full Code Here

    public CoverScreenListener(final Placemark placemark, final ServerSessionManager sessionManager,
            Vector3f goalPosP, String from, CoverScreenData csd) {
        if (goalPosP == null) {
            if (System.getProperty("x") == null || System.getProperty("y") == null
                    || System.getProperty("z") == null) {
                goalPosP = new Vector3f(0, 0, 0);
            } else {
                goalPosP = new Vector3f(Float.parseFloat(System.getProperty("x")), Float.parseFloat(System.getProperty("y")), Float.parseFloat(System.getProperty("z")));
            }
        }
        this.goalPos = goalPosP;

        Vector3f fromLoc = null;
        try {
            fromLoc = ClientContextJME.getViewManager()
                    .getPrimaryViewCell().getWorldTransform().getTranslation(null);
        } catch (Exception e) {
        }
        Vector3f toLoc = goalPos;
        if (fromLoc != null && goalPos != null && Math.abs((fromLoc.x) - (toLoc.x)) <= 150
                && Math.abs((fromLoc.y) - (toLoc.y)) <= 150
                && Math.abs((fromLoc.z) - (toLoc.z)) <= 150) {
            //Cover Screen not needed
        } else {
View Full Code Here

        // origin)
        cellState.addComponentServerState(new PortalComponentServerState());
       
        // set the scaling to make the model smaller
        PositionComponentServerState pcss = new PositionComponentServerState();
        pcss.setScaling(new Vector3f(0.4f, 0.4f, 0.4f));
        cellState.addComponentServerState(pcss);
       
        return (T) cellState;
    }
View Full Code Here

    private void actionCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_actionCBActionPerformed

    }//GEN-LAST:event_actionCBActionPerformed

    private void homeBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_homeBActionPerformed
        avatarCharacter.goTo(new Vector3f(0,0,0), new Vector3f(0,0,-1));
}//GEN-LAST:event_homeBActionPerformed
View Full Code Here

TOP

Related Classes of com.jme.math.Vector3f

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.