/** * Sets the vertical scale of the visualization where * each unit is a millisecond. Defaults to 2, ie: a * single millisecond stretches two pixels high. * @param scale the scale */ public void setGraphScale( float scale ) { if( this.scale == scale ) { return; } this.scale = scale; if( graph != null ) { graph.setLocalScale(1, scale, 1); } }
private void attachRandomGeometry(Node node, Material mat) { Box box = new Box(0.25f, 0.25f, 0.25f); Torus torus = new Torus(16, 16, 0.2f, 0.8f); Geometry[] boxes = new Geometry[]{ new Geometry("box1", box), new Geometry("box2", box), new Geometry("box3", box), new Geometry("torus1", torus), new Geometry("torus2", torus), new Geometry("torus3", torus) }; for (int i = 0; i < boxes.length; i++) { Geometry geometry = boxes[i]; geometry.setLocalTranslation((float) Math.random() * 10 -10, (float) Math.random() * 10 -10, (float) Math.random() * 10 -10); geometry.setLocalRotation(new Quaternion().fromAngles((float) Math.random() * FastMath.PI, (float) Math.random() * FastMath.PI, (float) Math.random() * FastMath.PI)); geometry.setLocalScale((float) Math.random() * 10 -10, (float) Math.random() * 10 -10, (float) Math.random() * 10 -10); geometry.setMaterial(mat); node.attachChild(geometry); } }
@Override public void simpleUpdate(float tpf) { if (!done) { done = true; batch.attachChild(cube2); batch.batch(); } updateBoindPoints(points); frustum.update(points); time += tpf; dl.setDirection(cam.getDirection()); cube2.setLocalTranslation(FastMath.sin(-time) * 3, FastMath.cos(time) * 3, 0); cube2.setLocalRotation(new Quaternion().fromAngleAxis(time, Vector3f.UNIT_Z)); cube2.setLocalScale(Math.max(FastMath.sin(time), 0.5f)); // batch.setLocalRotation(new Quaternion().fromAngleAxis(time, Vector3f.UNIT_Z)); } //
probeGeom.setLocalScale(probeScale); if (probe.isReady()) { m.setTexture("CubeMap", probe.getPrefilteredEnvMap());
@Override protected void initialize( Application app ) { graph = new Geometry("profiler", profiler.getMesh()); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setBoolean("VertexColor", true); graph.setMaterial(mat); graph.setLocalTranslation(0, 300, 0); graph.setLocalScale(1, scale, 1); Mesh mesh = new Mesh(); background = new Geometry("profiler.background", mesh); mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setBoolean("VertexColor", true); mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); background.setMaterial(mat); background.setLocalTranslation(0, 300, -1); background.setLocalScale(1, scale, 1); refreshBackground(); InputManager inputManager = app.getInputManager(); if( inputManager != null ) { inputManager.addMapping(INPUT_MAPPING_PROFILER_TOGGLE, new KeyTrigger(KeyInput.KEY_F6)); inputManager.addListener(keyListener, INPUT_MAPPING_PROFILER_TOGGLE); } }
@Override public void simpleInitApp() { Quad q = new Quad(1, 1); Geometry g = new Geometry("quad", q); g.setLocalTranslation(-500, -500, 0); g.setLocalScale(1000); rootNode.attachChild(g); cam.setLocation(new Vector3f(0.0f, 0.0f, 0.40647888f)); cam.setRotation(new Quaternion(0.0f, 1.0f, 0.0f, 0.0f)); Texture tex = assetManager.loadTexture("Interface/Logo/Monkey.jpg"); Material mat = new Material(assetManager, "Common/MatDefs/Misc/UnshadedNodes.j3md"); //Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Yellow); mat.setTexture("ColorMap", tex); g.setMaterial(mat); //place the geoms in the transparent bucket so that they are rendered back to front for maximum overdraw g.setQueueBucket(RenderQueue.Bucket.Transparent); for (int i = 0; i < 1000; i++) { Geometry cl = g.clone(false); cl.move(0, 0, -(i + 1)); rootNode.attachChild(cl); } flyCam.setMoveSpeed(20); Logger.getLogger("com.jme3").setLevel(Level.WARNING); this.setAppProfiler(new Profiler()); }
bulletg.setMaterial(matBullet); bulletg.setLocalTranslation(cam.getLocation()); bulletg.setLocalScale(bulletSize); bulletCollisionShape = new SphereCollisionShape(bulletSize); RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, bulletSize * 10); bulletg.setMaterial(matBullet); bulletg.setLocalTranslation(cam.getLocation()); bulletg.setLocalScale(bulletSize); bulletCollisionShape = new SphereCollisionShape(bulletSize); BombControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1);
@Override public void simpleInitApp() { // create a simple plane/quad Quad quadMesh = new Quad(1, 1); quadMesh.updateGeometry(1, 1, true); Geometry quad = new Geometry("Textured Quad", quadMesh); assetManager.registerLocator("https://raw.githubusercontent.com/jMonkeyEngine/BookSamples/master/assets/Textures/", UrlLocator.class); TextureKey key = new TextureKey("mucha-window.png", false); key.setGenerateMips(true); Texture tex = assetManager.loadTexture(key); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", tex); quad.setMaterial(mat); float aspect = tex.getImage().getWidth() / (float) tex.getImage().getHeight(); quad.setLocalScale(new Vector3f(aspect * 1.5f, 1.5f, 1)); quad.center(); rootNode.attachChild(quad); }
public void makeBoxWire(BoundingBox box) { Vector3f[] points = new Vector3f[8]; for (int i = 0; i < 8; i++) { points[i] = new Vector3f(); } points[0].set(-1, -1, 1); points[1].set(-1, 1, 1); points[2].set(1, 1, 1); points[3].set(1, -1, 1); points[4].set(-1, -1, -1); points[5].set(-1, 1, -1); points[6].set(1, 1, -1); points[7].set(1, -1, -1); WireFrustum frustumShape = new WireFrustum(points); aabbGeom = new Geometry("box", frustumShape); aabbGeom.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md")); aabbGeom.getMaterial().getAdditionalRenderState().setWireframe(true); aabbGeom.setLocalTranslation(box.getCenter()); aabbGeom.setLocalScale(box.getXExtent(), box.getYExtent(), box.getZExtent()); rootNode.attachChild(aabbGeom); }
clonePot.setLocalScale(.15f);
lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); lightMdl.setLocalTranslation(new Vector3f(77.70334f, 34.013165f, 27.1017f)); lightMdl.setLocalScale(5); rootNode.attachChild(lightMdl);
clonePot.setLocalScale(.15f); clonePot.setMaterial(mat); rootNode.attachChild(clonePot);
clonePot.setLocalScale(.15f);
teapot.setLocalScale(2f); Material mat2 = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); mat2.setFloat("Shininess", 25);
TangentBinormalGenerator.generate(teapot.getMesh(), true); teapot.setLocalScale(2f); Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
geom2.setMaterial(mat2); rootNode.attachChild(geom2); geom2.setLocalScale(0.1f, 0.2f, 1);
lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); lightMdl.setLocalTranslation(new Vector3f(77.70334f, 34.013165f, 27.1017f)); lightMdl.setLocalScale(5); rootNode.attachChild(lightMdl);
/** * Sets the vertical scale of the visualization where * each unit is a millisecond. Defaults to 2, ie: a * single millisecond stretches two pixels high. * @param scale the scale */ public void setGraphScale( float scale ) { if( this.scale == scale ) { return; } this.scale = scale; if( graph != null ) { graph.setLocalScale(1, scale, 1); } }
@Override public Void call() throws Exception { for (BasicGoodyGeomBinding aGeomBinding : myGeomBindings) { Vector3f rotatedScale = aGeomBinding.myRotationOffset.mult(scaleVector); aGeomBinding.myGeometry.setLocalScale(rotatedScale); } return null; } }, style);
public static Geometry makeGeometry(Vector3f loc, Vector3f scl, Mesh mesh, Material mat, String name) { Geometry geom = new Geometry(name, mesh); geom.setMaterial(mat); geom.setLocalTranslation(loc); geom.setLocalScale(scl); return geom; }