Java Code Examples for com.jme3.math.Vector3f#setY()
The following examples show how to use
com.jme3.math.Vector3f#setY() .
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: TestReverb.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleUpdate(float tpf) { time += tpf; if (time > nextTime) { Vector3f v = new Vector3f(); v.setX(FastMath.nextRandomFloat()); v.setY(FastMath.nextRandomFloat()); v.setZ(FastMath.nextRandomFloat()); v.multLocal(40, 2, 40); v.subtractLocal(20, 1, 20); audioSource.setLocalTranslation(v); audioSource.playInstance(); time = 0; nextTime = FastMath.nextRandomFloat() * 2 + 0.5f; } }
Example 2
Source File: TestHoveringTank.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public void updateCamera() { rootNode.updateGeometricState(); Vector3f pos = spaceCraft.getWorldTranslation().clone(); Quaternion rot = spaceCraft.getWorldRotation(); Vector3f dir = rot.getRotationColumn(2); // make it XZ only Vector3f camPos = new Vector3f(dir); camPos.setY(0); camPos.normalizeLocal(); // negate and multiply by distance from object camPos.negateLocal(); camPos.multLocal(15); // add Y distance camPos.setY(2); camPos.addLocal(pos); cam.setLocation(camPos); Vector3f lookAt = new Vector3f(dir); lookAt.multLocal(7); // look at dist lookAt.addLocal(pos); cam.lookAt(lookAt, Vector3f.UNIT_Y); }
Example 3
Source File: TestReverb.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void simpleUpdate(float tpf) { time += tpf; if (time > nextTime) { Vector3f v = new Vector3f(); v.setX(FastMath.nextRandomFloat()); v.setY(FastMath.nextRandomFloat()); v.setZ(FastMath.nextRandomFloat()); v.multLocal(40, 2, 40); v.subtractLocal(20, 1, 20); audioSource.setLocalTranslation(v); audioSource.playInstance(); time = 0; nextTime = FastMath.nextRandomFloat() * 2 + 0.5f; } }
Example 4
Source File: CreateSkyDialog.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * The process of creating a new sky. */ @FxThread private void createSkyInBackground() { final AssetManager assetManager = EditorUtil.getAssetManager(); final NodeTree<?> nodeTree = getNodeTree(); final ChangeConsumer changeConsumer = notNull(nodeTree.getChangeConsumer()); final FloatTextField normalScaleXSpinner = getNormalScaleXField(); final FloatTextField normalScaleYSpinner = getNormalScaleYField(); final FloatTextField normalScaleZSpinner = getNormalScaleZField(); final Vector3f scale = new Vector3f(); scale.setX(normalScaleXSpinner.getValue()); scale.setY(normalScaleYSpinner.getValue()); scale.setZ(normalScaleZSpinner.getValue()); final ComboBox<SkyType> skyTypeComboBox = getSkyTypeComboBox(); final SingleSelectionModel<SkyType> selectionModel = skyTypeComboBox.getSelectionModel(); final SkyType selectedItem = selectionModel.getSelectedItem(); if (selectedItem == SkyType.SINGLE_TEXTURE) { createSingleTexture(assetManager, changeConsumer, scale); } else if (selectedItem == SkyType.MULTIPLE_TEXTURE) { createMultipleTexture(assetManager, changeConsumer, scale); } }
Example 5
Source File: RelativeWanderBehavior.java From MonkeyBrains with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see SimpleWanderBehavior#changeSteer(float) */ @Override protected void changeSteer(float tpf) { time -= tpf; if (time <= 0) { lastSteer = currentSteer; Vector3f randomSteer = this.newRandomSteer(); randomSteer.setX(lastSteer.x*(1-relativeFactor) + randomSteer.getX()*relativeFactor); randomSteer.setY(lastSteer.y*(1-relativeFactor) + randomSteer.getY()*relativeFactor); randomSteer.setZ(lastSteer.z*(1-relativeFactor) + randomSteer.getZ()*relativeFactor); currentSteer = randomSteer; time = timeInterval; } }
Example 6
Source File: AbstractStrengthSteeringBehavior.java From MonkeyBrains with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Calculates the steering force with the specified strength. <br><br> * * If the strength was not setted up it the return calculateSteering(), the * unmodified force. * * @return The steering force with the specified strength. */ @Override protected Vector3f calculateSteering() { Vector3f strengthSteeringForce = calculateRawSteering(); switch (this.type) { case SCALAR: strengthSteeringForce = strengthSteeringForce.mult(this.scalar); break; case AXIS: strengthSteeringForce.setX(strengthSteeringForce.getX() * this.x); strengthSteeringForce.setY(strengthSteeringForce.getY() * this.y); strengthSteeringForce.setZ(strengthSteeringForce.getZ() * this.z); break; case PLANE: strengthSteeringForce = this.plane.getClosestPoint(strengthSteeringForce).mult(this.scalar); break; } //if there is no steering force, than the steering vector is zero if (strengthSteeringForce.equals(Vector3f.NAN)) { strengthSteeringForce = Vector3f.ZERO.clone(); } return strengthSteeringForce; }
Example 7
Source File: UnalignedCollisionAvoidanceBehavior.java From MonkeyBrains with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * removes negative zeros */ private void removeNegativeZeros(Vector3f vector) { if (vector.x == -0) { vector.setX(0); } if (vector.y == -0) { vector.setY(0); } if (vector.z == -0) { vector.setZ(0); } }
Example 8
Source File: RollingTheMonkey.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void simpleUpdate(float tpf) { // Update and position the score scoreText.setText("Score: " + score); scoreText.setLocalTranslation((cam.getWidth() - scoreText.getLineWidth()) / 2.0f, scoreText.getLineHeight(), 0.0f); // Rotate all the pickups float pickUpSpeed = PICKUP_SPEED * tpf; for(Spatial pickUp : pickUps.getChildren()) { pickUp.rotate(pickUpSpeed, pickUpSpeed, pickUpSpeed); } Vector3f centralForce = new Vector3f(); if(keyForward) centralForce.addLocal(cam.getDirection()); if(keyBackward) centralForce.addLocal(cam.getDirection().negate()); if(keyLeft) centralForce.addLocal(cam.getLeft()); if(keyRight) centralForce.addLocal(cam.getLeft().negate()); if(!Vector3f.ZERO.equals(centralForce)) { centralForce.setY(0); // stop ball from pusing down or flying up centralForce.normalizeLocal(); // normalize force centralForce.multLocal(PLAYER_FORCE); // scale vector to force player.applyCentralForce(centralForce); // apply force to player } cam.lookAt(player.getPhysicsLocation(), Vector3f.UNIT_Y); }
Example 9
Source File: Intersection.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static final void findMinMax(float x0, float x1, float x2, Vector3f minMax) { minMax.set(x0, x0, 0); if (x1 < minMax.x) { minMax.setX(x1); } if (x1 > minMax.y) { minMax.setY(x1); } if (x2 < minMax.x) { minMax.setX(x2); } if (x2 > minMax.y) { minMax.setY(x2); } }
Example 10
Source File: Intersection.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private static final void findMinMax(float x0, float x1, float x2, Vector3f minMax) { minMax.set(x0, x0, 0); if (x1 < minMax.x) { minMax.setX(x1); } if (x1 > minMax.y) { minMax.setY(x1); } if (x2 < minMax.x) { minMax.setX(x2); } if (x2 > minMax.y) { minMax.setY(x2); } }
Example 11
Source File: ScaleToolControl.java From jmonkeybuilder with Apache License 2.0 | 4 votes |
@JmeThread @Override public void processTransform() { final EditorTransformSupport editorControl = getEditorControl(); final LocalObjects local = LocalObjects.get(); final Camera camera = editorControl.getCamera(); final InputManager inputManager = EditorUtil.getInputManager(); final Transform transform = notNull(editorControl.getTransformCenter()); // cursor position and selected position vectors final Vector2f cursorPos = inputManager.getCursorPosition(); final Vector3f transformOnScreen = camera.getScreenCoordinates(transform.getTranslation(), local.nextVector()); final Vector2f selectedCoords = local.nextVector(transformOnScreen.getX(), transformOnScreen.getY()); // set new deltaVector if it's not set (scale tool stores position of a cursor) if (Float.isNaN(editorControl.getTransformDeltaX())) { editorControl.setTransformDeltaX(cursorPos.getX()); editorControl.setTransformDeltaY(cursorPos.getY()); } final Node parentNode = getParentNode(); final Node childNode = getChildNode(); // Picked vector final Spatial toTransform = notNull(editorControl.getToTransform()); final TransformationMode transformationMode = editorControl.getTransformationMode(); transformationMode.prepareToScale(parentNode, childNode, transform, camera); // scale according to distance final Vector3f deltaVector = local.nextVector(editorControl.getTransformDeltaX(), editorControl.getTransformDeltaY(), 0F); final Vector2f delta2d = local.nextVector(deltaVector.getX(), deltaVector.getY()); final Vector3f baseScale = local.nextVector(transform.getScale()); // default scale final Vector3f pickedVector = local.nextVector(transformationMode.getScaleAxis(transform, editorControl.getPickedAxis(), camera)); pickedVector.setX(abs(pickedVector.getX())); pickedVector.setY(abs(pickedVector.getY())); pickedVector.setZ(abs(pickedVector.getZ())); if (Config.DEV_TRANSFORMS_DEBUG) { System.out.println("Base scale " + baseScale + ", pickedVector " + pickedVector); } // scale object float disCursor = cursorPos.distance(selectedCoords); float disDelta = delta2d.distance(selectedCoords); float scaleValue = (float) (cursorPos.distance(delta2d) * 0.01f * Math.sqrt(baseScale.length())); if (disCursor > disDelta) { baseScale.addLocal(pickedVector.mult(scaleValue, local.nextVector())); } else { scaleValue = Math.min(scaleValue, 0.999f); // remove negateve values baseScale.subtractLocal(pickedVector.mult(scaleValue, local.nextVector())); } parentNode.setLocalScale(baseScale); if (Config.DEV_TRANSFORMS_DEBUG) { System.out.println("New scale " + baseScale + ", result world " + childNode.getWorldScale()); } parentNode.setLocalScale(baseScale); toTransform.setLocalScale(childNode.getWorldScale()); editorControl.notifyTransformed(toTransform); }