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

The following examples show how to use com.jme3.math.Vector3f#UNIT_X . 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: TestRayCollision.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void main(String[] args){
    Ray r = new Ray(Vector3f.ZERO, Vector3f.UNIT_X);
    BoundingBox bbox = new BoundingBox(new Vector3f(5, 0, 0), 1, 1, 1);

    CollisionResults res = new CollisionResults();
    bbox.collideWith(r, res);

    System.out.println("Bounding:" +bbox);
    System.out.println("Ray: "+r);

    System.out.println("Num collisions: "+res.size());
    for (int i = 0; i < res.size(); i++){
        System.out.println("--- Collision #"+i+" ---");
        float dist = res.getCollision(i).getDistance();
        Vector3f pt = res.getCollision(i).getContactPoint();
        System.out.println("distance: "+dist);
        System.out.println("point: "+pt);
    }
}
 
Example 2
Source File: TestRayCollision.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public static void main(String[] args){
    Ray r = new Ray(Vector3f.ZERO, Vector3f.UNIT_X);
    BoundingBox bbox = new BoundingBox(new Vector3f(5, 0, 0), 1, 1, 1);

    CollisionResults res = new CollisionResults();
    bbox.collideWith(r, res);

    System.out.println("Bounding:" +bbox);
    System.out.println("Ray: "+r);

    System.out.println("Num collisions: "+res.size());
    for (int i = 0; i < res.size(); i++){
        System.out.println("--- Collision #"+i+" ---");
        float dist = res.getCollision(i).getDistance();
        Vector3f pt = res.getCollision(i).getContactPoint();
        System.out.println("distance: "+dist);
        System.out.println("point: "+pt);
    }
}
 
Example 3
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 4
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 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);
}
 
Example 6
Source File: JMonkeyEngineTest.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
@Test
public void testVector() {
    Vector3f v = Vector3f.UNIT_X;
    v = v.add(0f, 2f, 0f);
    v.normalizeLocal();
}