Java Code Examples for com.jme3.math.Vector3f#UNIT_Y

The following examples show how to use com.jme3.math.Vector3f#UNIT_Y . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimplePlayerAttackBehavior.java    From MonkeyBrains with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void onAction(String name, boolean isPressed, float tpf) {
    operation = name;
    if (isPressed) {
        supportedOperations.get(operation).setEnabled(true);
        Vector2f click2d = MonkeyBrainsAppState.getInstance().getApp().getInputManager().getCursorPosition();
        Vector3f click3d = agent.getCamera().getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 0f).clone();
        Vector3f dir = agent.getCamera().getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 1f).subtractLocal(click3d).normalizeLocal();
        Ray ray = new Ray(click3d, dir);
        Plane ground = new Plane(Vector3f.UNIT_Y, 0);
        Vector3f groundpoint = new Vector3f();
        ray.intersectsWherePlane(ground, groundpoint);
        ((SimpleAttackBehavior) supportedOperations.get(operation)).setTarget(groundpoint);
    } else {
        operation = null;
    }
}
 
Example 2
Source File: EditorTransformSupport.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Get a vector to calculate transformations by the Axis.
 *
 * @param transform  the base transform.
 * @param pickedAxis the picked Axis.
 * @param camera     the camera.
 * @return the axis vector.
 */
@JmeThread
protected @NotNull Vector3f getPickedVector(@NotNull final Transform transform,
                                            @NotNull final PickedAxis pickedAxis,
                                            @NotNull final Camera camera) {

    if (pickedAxis == PickedAxis.Y) {
        return Vector3f.UNIT_Y;
    } else if (pickedAxis == PickedAxis.Z) {
        return Vector3f.UNIT_Z;
    } else {
        return Vector3f.UNIT_X;
    }
}
 
Example 3
Source File: EditorTransformSupport.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Get a vector to calculate scaling by the axis.
 *
 * @param transform  the base transform.
 * @param pickedAxis the picked Axis.
 * @param camera     the camera.
 * @return the axis vector.
 */
@JmeThread
protected @NotNull Vector3f getScaleAxis(@NotNull final Transform transform,
                                         @NotNull final PickedAxis pickedAxis, @NotNull final Camera camera) {

    if (pickedAxis == PickedAxis.Y) {
        return Vector3f.UNIT_Y;
    } else if (pickedAxis == PickedAxis.Z) {
        return Vector3f.UNIT_Z;
    } else return Vector3f.UNIT_X;
}
 
Example 4
Source File: EditorCamera.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs the chase camera if you use this constructor you have to attach the camera later to a spatial doing
 * spatial.addControl(chaseCamera);
 *
 * @param camera the application camera
 */
public EditorCamera(@NotNull final Camera camera) {
    this.camera = camera;
    this.initialUpVec = Vector3f.UNIT_Y;
    this.targetDir = new Vector3f();
    this.position = new Vector3f();
    this.targetLocation = new Vector3f(0, 0, 0);
    this.lookAtOffset = new Vector3f(0, 0, 0);
    this.temp = new Vector3f(0, 0, 0);
}
 
Example 5
Source File: DebugTools.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Render all the debug geometries to the specified view port.
 *
 * @param rm the render manager (not null)
 * @param vp the view port (not null)
 */
public void show(RenderManager rm, ViewPort vp) {
    if (!Vector3f.UNIT_X.equals(UNIT_X_CHECK) || !Vector3f.UNIT_Y.equals(UNIT_Y_CHECK) || !Vector3f.UNIT_Z.equals(UNIT_Z_CHECK)
            || !Vector3f.UNIT_XYZ.equals(UNIT_XYZ_CHECK) || !Vector3f.ZERO.equals(ZERO_CHECK)) {
        throw new IllegalStateException("Unit vectors compromised!"
                + "\nX: " + Vector3f.UNIT_X
                + "\nY: " + Vector3f.UNIT_Y
                + "\nZ: " + Vector3f.UNIT_Z
                + "\nXYZ: " + Vector3f.UNIT_XYZ
                + "\nZERO: " + Vector3f.ZERO);
    }
    debugNode.updateLogicalState(0);
    debugNode.updateGeometricState();
    rm.renderScene(debugNode, vp);
}