/** * Transform this <code>ColorRGBA</code> to a <code>Vector3f</code> using * x = r, y = g, z = b. The Alpha value is not used. * This method is useful for shader assignments. * @return A <code>Vector3f</code> containing the RGB value of this <code>ColorRGBA</code>. */ public Vector3f toVector3f() { return new Vector3f(r, g, b); }
/** * * <code>mult</code> multiplies this vector by a scalar. The resultant * vector is returned. * * @param scalar * the value to multiply this vector by. * @return the new vector. */ public Vector3f mult(float scalar) { return new Vector3f(x * scalar, y * scalar, z * scalar); }
static Vector3f[] toVector3(double[] data) { Vector3f[] vectors = new Vector3f[data.length / 3]; for (int i = 0; i < vectors.length; i++) { float x = (float) data[i * 3]; float y = (float) data[i * 3 + 1]; float z = (float) data[i * 3 + 2]; vectors[i] = new Vector3f(x, y, z); } return vectors; }
/** * Copy the collision's lateral friction direction #1. * * @return a new vector (not null) */ public Vector3f getLateralFrictionDir1() { return getLateralFrictionDir1(new Vector3f()); }
/** * Copy the collision's location in the local coordinates of object A. * * @return a new location vector (in local coordinates, not null) */ public Vector3f getLocalPointA() { return getLocalPointA(new Vector3f()); }
/** * Retreives the scale vector from the matrix. * * @return the scale vector */ public Vector3f toScaleVector() { Vector3f result = new Vector3f(); this.toScaleVector(result); return result; }
/** * Alter this body's angular factor. * * @param factor the desired angular factor for all axes (not null, * unaffected, default=1) */ public void setAngularFactor(float factor) { setAngularFactor(objectId, new Vector3f(factor, factor, factor)); }
public EmitterBoxShape(Vector3f min, Vector3f max) { if (min == null || max == null) { throw new IllegalArgumentException("min or max cannot be null"); } this.min = min; this.len = new Vector3f(); this.len.set(max).subtractLocal(min); }
public static void methodThatUsesAllocation(){ Vector3f vector = new Vector3f(); vector.set(0.1f, 0.2f, 0.3f); sumCompute.addLocal(vector); }
public void setupJoint() { Node holderNode=PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0); holderNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f,0,0f)); rootNode.attachChild(holderNode); getPhysicsSpace().add(holderNode); Node hammerNode=PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .3f, .3f, .3f)),1); hammerNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f,-1,0f)); rootNode.attachChild(hammerNode); getPhysicsSpace().add(hammerNode); joint=new HingeJoint(holderNode.getControl(RigidBodyControl.class), hammerNode.getControl(RigidBodyControl.class), Vector3f.ZERO, new Vector3f(0f,-1,0f), Vector3f.UNIT_Z, Vector3f.UNIT_Z); getPhysicsSpace().add(joint); }
public void multLocal(Quaternion rotation) { Vector3f axis = new Vector3f(); float angle = rotation.toAngleAxis(axis); Matrix4f matrix4f = new Matrix4f(); matrix4f.fromAngleAxis(angle, axis); multLocal(matrix4f); }
@Override public void simpleUpdate(float tpf) { super.simpleUpdate(tpf);//To change body of generated methods, choose Tools | Templates. for (int i = 0; i < 3; i++){ PointLight pl = pls[i]; float angle = (float)Math.PI * (i + (timer.getTimeInSeconds() % 6)/3); // 3s for full loop pl.setPosition( new Vector3f(FastMath.cos(angle)*3f, 0, FastMath.sin(angle)*3f)); } } public void initialize(RenderManager rm, ViewPort vp) {
@Override public void simpleUpdate(float tpf){ // cam.setLocation(new Vector3f(2.0632997f, 1.9493936f, 2.6885238f)); // cam.setRotation(new Quaternion(-0.053555284f, 0.9407851f, -0.17754152f, -0.28378546f)); angle += tpf; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 2f, 0.5f, FastMath.sin(angle) * 2f)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf){ angle += tpf; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 2f, 2f, FastMath.sin(angle) * 2f)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf){ angle += tpf * 0.25f; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 4f, 0.5f, FastMath.sin(angle) * 4f)); lightMdl.setLocalTranslation(pl.getPosition()); }
private void setupLight() { // AmbientLight al = new AmbientLight(); // al.setColor(ColorRGBA.White.mult(1)); // rootNode.addLight(al); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal()); dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); rootNode.addLight(dl); }
public void makeCamFrustum() { Vector3f[] points = new Vector3f[8]; for (int i = 0; i < 8; i++) { points[i] = new Vector3f(); } ShadowUtil.updateFrustumPoints2(frustumCam, points); WireFrustum frustumShape = new WireFrustum(points); frustumGeom = new Geometry("frustum", frustumShape); frustumGeom.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md")); rootNode.attachChild(frustumGeom); }
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule ic = im.getCapsule(this); enabled = ic.readBoolean("enabled", true); useViewDirection = ic.readBoolean("viewDirectionEnabled", true); viewDirection = (Vector3f) ic.readSavable("viewDirection", new Vector3f(Vector3f.UNIT_Z)); applyLocal = ic.readBoolean("applyLocalPhysics", false); spatial = (Spatial) ic.readSavable("spatial", null); setUserObject(spatial); } }
private void createCharacter() { CapsuleCollisionShape capsule = new CapsuleCollisionShape(3f, 4f); character = new CharacterControl(capsule, 0.01f); model = (Node) assetManager.loadModel("Models/Oto/OtoOldAnim.j3o"); //model.setLocalScale(0.5f); model.addControl(character); character.setPhysicsLocation(new Vector3f(-140, 40, -10)); rootNode.attachChild(model); getPhysicsSpace().add(character); }