/** * Convert the cell coordinate (integer coordinates) into world coordinates. */ public Vector3f toWorldSpace(Vector3f cellLocation) { return cellLocation.mult(getLocalScale()).multLocal(quadSize - 1); }
/** * <code>multLocal</code> multiplies a provided vector to this vector * internally, and returns a handle to this vector for easy chaining of * calls. If the provided vector is null, null is returned. * * @param vec * the vector to mult to this vector. * @return this */ public Vector3f mult(Vector3f vec) { if (null == vec) { logger.warning("Provided vector is null, null returned."); return null; } return mult(vec, null); }
public Vector3f getPositiveEnd(Vector3f store) { if (store == null) { store = new Vector3f(); } return origin.add((direction.mult(extent, store)), store); }
@Override public void adjustHeight(List<Vector2f> xz, List<Float> height) { Vector3f currentGridLocation = getCurrentCell().mult(getLocalScale()).multLocal(quadSize - 1); for (Vector2f vect : xz) { vect.x -= currentGridLocation.x; vect.y -= currentGridLocation.z; } super.adjustHeight(xz, height); }
public Vector3f getNegativeEnd(Vector3f store) { if (store == null) { store = new Vector3f(); } return origin.subtract((direction.mult(extent, store)), store); }
public BezierLine scale(Vector3f scale) { BezierLine result = new BezierLine(vertices, materialNumber, smooth, cyclic); result.vertices = new Vector3f[vertices.length]; for (int i = 0; i < vertices.length; ++i) { result.vertices[i] = vertices[i].mult(scale); } result.recomputeLength(); return result; }
/** * Centered at 0,0. * Get the tile index location in integer form: * @param location world coordinate */ public Vector3f getTileCell(Vector3f location) { Vector3f tileLoc = location.divide(this.getWorldScale().mult(this.quadSize)); return tileLoc; }
public Object call() throws Exception { for (Spatial s : getChildren()) { if (s instanceof TerrainQuad) { TerrainQuad tq = (TerrainQuad)s; tq.resetCachedNeighbours(); } } System.out.println("fixed normals "+location.clone().mult(size)); setNeedToRecalculateNormals(); return null; } });
/** * Instantiate an enabled control. */ public KinematicRagdollControl() { baseRigidBody = new PhysicsRigidBody(new BoxCollisionShape(Vector3f.UNIT_XYZ.mult(0.1f)), 1); baseRigidBody.setKinematic(mode == Mode.Kinematic); }
/** * Instantiate an enabled control. */ public KinematicRagdollControl() { baseRigidBody = new PhysicsRigidBody(new BoxCollisionShape(Vector3f.UNIT_XYZ.mult(0.1f)), 1); baseRigidBody.setKinematic(mode == Mode.Kinematic); }
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); }
/** * Translate the camera upward by the specified amount. * * @param value translation amount */ protected void riseCamera(float value){ Vector3f vel = initialUpVec.mult(value * moveSpeed); Vector3f pos = cam.getLocation().clone(); if (motionAllowed != null) motionAllowed.checkMotionAllowed(pos, vel); else pos.addLocal(vel); cam.setLocation(pos); }
/** A red ball that marks the last spot that was "hit" by the "shot". */ protected void initMark() { Arrow arrow = new Arrow(Vector3f.UNIT_Z.mult(2f)); //Sphere sphere = new Sphere(30, 30, 0.2f); mark = new Geometry("BOOM!", arrow); //mark = new Geometry("BOOM!", sphere); Material mark_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mark_mat.getAdditionalRenderState().setLineWidth(3); mark_mat.setColor("Color", ColorRGBA.Red); mark.setMaterial(mark_mat); }
public float distanceSquared(Vector3f point) { TempVars vars = TempVars.get(); Vector3f compVec1 = vars.vect1; Vector3f compVec2 = vars.vect2; point.subtract(origin, compVec1); float lineParameter = direction.dot(compVec1); origin.add(direction.mult(lineParameter, compVec2), compVec2); compVec2.subtract(point, compVec1); float len = compVec1.lengthSquared(); vars.release(); return len; }
public void onAction(String name, boolean keyPressed, float tpf) { if (name.equals("shoot") && !keyPressed) { Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(mat2); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setLocalTranslation(cam.getLocation()); RigidBodyControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1); // RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, 1); bulletNode.setLinearVelocity(cam.getDirection().mult(25)); bulletg.addControl(bulletNode); rootNode.attachChild(bulletg); getPhysicsSpace().add(bulletNode); } } };
public void onAction(String name, boolean keyPressed, float tpf) { if (name.equals("shoot") && !keyPressed) { Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(mat2); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setLocalTranslation(cam.getLocation()); RigidBodyControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1); // RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, 1); bulletNode.setLinearVelocity(cam.getDirection().mult(25)); bulletg.addControl(bulletNode); rootNode.attachChild(bulletg); getPhysicsSpace().add(bulletNode); } } };
private void bulletControl() { shootingChannel.setAnim("Dodge", 0.1f); shootingChannel.setLoopMode(LoopMode.DontLoop); Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(matBullet); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setLocalTranslation(character.getPhysicsLocation().add(cam.getDirection().mult(5))); RigidBodyControl bulletControl = new BombControl(bulletCollisionShape, 1); bulletControl.setCcdMotionThreshold(0.1f); bulletControl.setLinearVelocity(cam.getDirection().mult(80)); bulletg.addControl(bulletControl); rootNode.attachChild(bulletg); getPhysicsSpace().add(bulletControl); }
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); }