/** * <code>fromAngleAxis</code> sets this matrix4f to the values specified * by an angle and an axis of rotation. This method creates an object, so * use fromAngleNormalAxis if your axis is already normalized. * * @param angle * the angle to rotate (in radians). * @param axis * the axis of rotation. */ public void fromAngleAxis(float angle, Vector3f axis) { Vector3f normAxis = axis.normalize(); fromAngleNormalAxis(angle, normAxis); }
float d = dir.dot(linearVelocity.normalize()); Vector3f counter = dir.project(linearVelocity).normalizeLocal().negateLocal().multLocal(1 - d); applyForce(counter.multLocal(mass * 10), Vector3f.ZERO);
@Override public void simpleInitApp() { loadHintText(); initCrossHairs(); setupKeys(); createMarker(); // WIREFRAME material matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); matWire.getAdditionalRenderState().setWireframe(true); matWire.setColor("Color", ColorRGBA.Green); createTerrain(); //createTerrainGrid(); DirectionalLight light = new DirectionalLight(); light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize()); rootNode.addLight(light); AmbientLight ambLight = new AmbientLight(); ambLight.setColor(new ColorRGBA(1f, 1f, 0.8f, 0.2f)); rootNode.addLight(ambLight); cam.setLocation(new Vector3f(0, 256, 0)); cam.lookAtDirection(new Vector3f(0, -1f, 0).normalizeLocal(), Vector3f.UNIT_X); }
/** * <code>fromAngleAxis</code> sets this matrix4f to the values specified * by an angle and an axis of rotation. This method creates an object, so * use fromAngleNormalAxis if your axis is already normalized. * * @param angle * the angle to rotate (in radians). * @param axis * the axis of rotation. */ public void fromAngleAxis(float angle, Vector3f axis) { Vector3f normAxis = axis.normalize(); fromAngleNormalAxis(angle, normAxis); }
light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize()); rootNode.addLight(light);
/** * <code>fromAngleAxis</code> sets this quaternion to the values specified * by an angle and an axis of rotation. This method creates an object, so * use fromAngleNormalAxis if your axis is already normalized. * * @param angle * the angle to rotate (in radians). * @param axis * the axis of rotation. * @return this quaternion */ public Quaternion fromAngleAxis(float angle, Vector3f axis) { Vector3f normAxis = axis.normalize(); fromAngleNormalAxis(angle, normAxis); return this; }
light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize()); rootNode.addLight(light);
@Override public void onAction(String name, boolean isPressed, float tpf) { if (name.equals("rup") && isPressed) { roughness = FastMath.clamp(roughness + 0.1f, 0.0f, 1.0f); m.setFloat("Roughness", roughness); } if (name.equals("rdown") && isPressed) { roughness = FastMath.clamp(roughness - 0.1f, 0.0f, 1.0f); m.setFloat("Roughness", roughness); } if (name.equals("light") && isPressed) { dl.setDirection(cam.getDirection().normalize()); } } }, "light", "rup", "rdown");
light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize()); rootNode.addLight(light);
private Geometry getRandomBall(Vector3f location) { Vector3f localLocation = new Vector3f(); localLocation.set(location); localLocation.addLocal(new Vector3f(random.nextFloat() - 0.5f, random.nextFloat() - 0.5f, random.nextFloat() - 0.5f).normalize().mult(3)); Geometry poiGeom = new Geometry("ball", ballMesh); poiGeom.setLocalTranslation(localLocation); poiGeom.setMaterial(ballMaterial); RigidBodyControl control = new RigidBodyControl(ballCollisionShape, 1); //!!! Important control.setApplyPhysicsLocal(true); poiGeom.addControl(control); float x = (random.nextFloat() - 0.5f) * 100; float y = (random.nextFloat() - 0.5f) * 100; float z = (random.nextFloat() - 0.5f) * 100; control.setLinearVelocity(new Vector3f(x, y, z)); return poiGeom; }
private void scaleAsChild(float percent, Vector3f dist) { float childScale = mapValue(percent, 1.0f / poiRadius, 1); Vector3f distToHorizon = dist.normalize(); Vector3f scaledDistToHorizon = distToHorizon.mult(childScale * poiRadius); Vector3f rootOff = dist.add(scaledDistToHorizon); debugTools.setBlueArrow(Vector3f.ZERO, rootOff); getRootNode().setLocalScale(childScale); getRootNode().setLocalTranslation(rootOff); //prepare player position already Vector3f playerPosition = dist.normalize().mult(-poiRadius); setPlayerPosition(playerPosition); }
dl.setDirection(cam.getDirection().normalize());
private void scaleAsParent(float percent, Vector3f playerPos, Vector3f dist) { float scale = mapValue(percent, 1.0f, poiRadius); Vector3f distToHorizon = dist.subtract(dist.normalize()); Vector3f offLocation = playerPos.add(distToHorizon); Vector3f rootOff = offLocation.mult(scale).negate(); rootOff.addLocal(dist); debugTools.setGreenArrow(Vector3f.ZERO, offLocation); getRootNode().setLocalScale(scale); getRootNode().setLocalTranslation(rootOff); }
Vector3f xPoint = v1.add(h.normalize().multLocal(x));
protected Vector3f getNormal(float x, float z, Vector2f xz) { x-=0.5f; z-=0.5f; float col = FastMath.floor(x); float row = FastMath.floor(z); boolean onX = false; if(1 - (x - col)-(z - row) < 0) // what triangle to interpolate on onX = true; // v1--v2 ^ // | / | | // | / | | // v3--v4 | Z // | // <-------Y // X Vector3f n1 = getMeshNormal((int) FastMath.ceil(x), (int) FastMath.ceil(z)); Vector3f n2 = getMeshNormal((int) FastMath.floor(x), (int) FastMath.ceil(z)); Vector3f n3 = getMeshNormal((int) FastMath.ceil(x), (int) FastMath.floor(z)); Vector3f n4 = getMeshNormal((int) FastMath.floor(x), (int) FastMath.floor(z)); return n1.add(n2).add(n3).add(n4).normalize(); }
Vector3f dir = extent.normalize();
parent.takeOverChild(inParentPosition.add(playerPos.normalize())); application.getStateManager().attach(parent); currentReturnLevel = parent;
light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize()); rootNode.addLight(light);
dl.setDirection(new Vector3f(-1, -1, -1).normalize()); rootNode.addLight(dl);