/** * Alter the gravity acting on this character. Note that this also realigns * the local coordinate system of the character so that continuous changes * in gravity direction are possible while maintaining a sensible control * over the character. * * @param gravity an acceleration vector (not null, unaffected) */ public void setGravity(Vector3f gravity) { rigidBody.setGravity(gravity); localUp.set(gravity).normalizeLocal().negateLocal(); updateLocalCoordinateSystem(); }
/** * Alter the gravity acting on this character. Note that this also realigns * the local coordinate system of the character so that continuous changes * in gravity direction are possible while maintaining a sensible control * over the character. * * @param gravity an acceleration vector (not null, unaffected) */ public void setGravity(Vector3f gravity) { rigidBody.setGravity(gravity); localUp.set(gravity).normalizeLocal().negateLocal(); updateLocalCoordinateSystem(); }
/** * Add all managed physics objects to the specified space. * * @param space which physics space to add to (not null) */ @Override protected void addPhysics(PhysicsSpace space) { space.getGravity(localUp).normalizeLocal().negateLocal(); updateLocalCoordinateSystem(); space.addCollisionObject(rigidBody); space.addTickListener(this); }
public Vector3f reflect(Vector3f point, Vector3f store){ if (store == null) store = new Vector3f(); float d = pseudoDistance(point); store.set(normal).negateLocal().multLocal(d * 2f); store.addLocal(point); return store; }
/** * Add all managed physics objects to the specified space. * * @param space which physics space to add to (not null) */ @Override protected void addPhysics(PhysicsSpace space) { space.getGravity(localUp).normalizeLocal().negateLocal(); updateLocalCoordinateSystem(); space.addCollisionObject(rigidBody); space.addTickListener(this); }
/** * Rotate the GUI to the given direction. * @param dir the direction to rotate to. * @param tpf the time per frame. */ private void rotateScreenTo(Quaternion dir, float tpf) { dir.getRotationColumn(2, look).negateLocal(); dir.getRotationColumn(0, left).negateLocal(); orient.fromAxes(left, dir.getRotationColumn(1, up), look); Quaternion rot = tempq.fromRotationMatrix(orient); if( posMode == VRGUIPositioningMode.AUTO_CAM_ALL_SKIP_PITCH ){ VRUtil.stripToYaw(rot); } if( guiPositioningElastic > 0f && posMode != VRGUIPositioningMode.MANUAL ) { // mix pos & dir with current pos & dir EoldDir.nlerp(rot, tpf * guiPositioningElastic); guiQuadNode.setLocalRotation(EoldDir); } else { guiQuadNode.setLocalRotation(rot); } }
private float collideWithVertex(Vector3f sCenter, Vector3f sVelocity, float velocitySquared, Vector3f vertex, float t) { // A = velocity * velocity // B = 2 * (velocity . (center - vertex)); // C = ||vertex - center||^2 - 1f; temp1.set(sCenter).subtractLocal(vertex); float a = velocitySquared; float b = 2f * sVelocity.dot(temp1); float c = temp1.negateLocal().lengthSquared() - 1f; float newT = getLowestRoot(a, b, c, t); // float A = velocitySquared; // float B = sCenter.subtract(vertex).dot(sVelocity) * 2f; // float C = vertex.subtract(sCenter).lengthSquared() - 1f; // // float newT = getLowestRoot(A, B, C, Float.MAX_VALUE); // if (newT > 1.0f) // newT = Float.NaN; return newT; }
/** * Rotate the billboard so it points directly opposite the direction the * camera's facing * * @param camera * Camera */ private void rotateScreenAligned(Camera camera) { // coopt diff for our in direction: look.set(camera.getDirection()).negateLocal(); // coopt loc for our left direction: left.set(camera.getLeft()).negateLocal(); orient.fromAxes(left, camera.getUp(), look); Node parent = spatial.getParent(); Quaternion rot=new Quaternion().fromRotationMatrix(orient); if ( parent != null ) { rot = parent.getWorldRotation().inverse().multLocal(rot); rot.normalizeLocal(); } spatial.setLocalRotation(rot); fixRefreshFlags(); }
newLeftNegate.set(newLeft).negateLocal(); direction.set(worldUpVector).crossLocal(newLeftNegate).normalizeLocal(); if (direction.equals(Vector3f.ZERO)) {
newLeftNegate.set(newLeft).negateLocal(); direction.set(worldUpVector).crossLocal(newLeftNegate).normalizeLocal(); if (direction.equals(Vector3f.ZERO)) {
/** * Saves the current bone state as its binding pose, including its children. */ void setBindingPose() { bindPos.set(localPos); bindRot.set(localRot); bindScale.set(localScale); if (modelBindInversePos == null) { modelBindInversePos = new Vector3f(); modelBindInverseRot = new Quaternion(); modelBindInverseScale = new Vector3f(); } // Save inverse derived position/scale/orientation, used for calculate offset transform later modelBindInversePos.set(modelPos); modelBindInversePos.negateLocal(); modelBindInverseRot.set(modelRot); modelBindInverseRot.inverseLocal(); modelBindInverseScale.set(Vector3f.UNIT_XYZ); modelBindInverseScale.divideLocal(modelScale); for (Bone b : children) { b.setBindingPose(); } }
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); }
Vector3f counter = dir.project(linearVelocity).normalizeLocal().negateLocal().multLocal(1 - d); applyForce(counter.multLocal(mass * 10), Vector3f.ZERO); linearVelocity.normalizeLocal().negateLocal(); applyForce(linearVelocity.mult(mass * 10), Vector3f.ZERO);
/** * Set the gravity for this character. Note that this also realigns the * local coordinate system of the character so that continuous changes in * gravity direction are possible while maintaining a sensible control over * the character. * * @param gravity */ public void setGravity(Vector3f gravity) { rigidBody.setGravity(gravity); localUp.set(gravity).normalizeLocal().negateLocal(); updateLocalCoordinateSystem(); }
/** * Alter the gravity acting on this character. Note that this also realigns * the local coordinate system of the character so that continuous changes * in gravity direction are possible while maintaining a sensible control * over the character. * * @param gravity an acceleration vector (not null, unaffected) */ public void setGravity(Vector3f gravity) { rigidBody.setGravity(gravity); localUp.set(gravity).normalizeLocal().negateLocal(); updateLocalCoordinateSystem(); }
public Vector3f reflect(Vector3f point, Vector3f store){ if (store == null) store = new Vector3f(); float d = pseudoDistance(point); store.set(normal).negateLocal().multLocal(d * 2f); store.addLocal(point); return store; }
/** * Add all managed physics objects to the specified space. * * @param space which physics space to add to (not null) */ @Override protected void addPhysics(PhysicsSpace space) { space.getGravity(localUp).normalizeLocal().negateLocal(); updateLocalCoordinateSystem(); space.addCollisionObject(rigidBody); space.addTickListener(this); }
void moveBackward() { Vector3f dir = screenLoc.subtract(smartphone.getLocalTranslation()); dir.normalizeLocal(); dir.multLocal(step); dir.negateLocal(); smartphone.move(dir); bitmapText.setText(String.valueOf(distanceToScreen())+"m"); }
public Vector3f reflect(Vector3f point, Vector3f store){ if (store == null) store = new Vector3f(); float d = pseudoDistance(point); store.set(normal).negateLocal().multLocal(d * 2f); store.addLocal(point); return store; }
void moveBackward() { Vector3f inc = cam.getDirection().normalize().mult(0.01f); inc.negateLocal(); //cam.getDirection().set(cam.getLocation().subtract(screenLoc)); cam.setLocation(cam.getLocation().add(inc)); System.out.println("d = "+distanceToScreen()); }