/** * Scales the spatial by the given value * * @return The spatial on which this method is called, e.g <code>this</code>. */ public Spatial scale(float s) { return scale(s, s, s); }
s.scale(scale); s.move(offset); assets.add(s);
protected Spatial makeCharacter() { // load a character from jme3test-test-data Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); golem.scale(0.5f); golem.setLocalTranslation(-1.0f, -1.5f, -0.6f); // We must add a light to make the model visible DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f)); golem.addLight(sun); return golem; } }
protected Spatial makeCharacter() { // load a character from jme3test-test-data Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); golem.scale(0.5f); golem.setLocalTranslation(-1.0f, -1.5f, -0.6f); // We must add a light to make the model visible DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal()); golem.addLight(sun); return golem; } }
@Override public void initialize(){ super.initialize(); System.out.println("Initialize"); RootNodeState state = new RootNodeState(); viewPort.attachScene(state.getRootNode()); stateManager.attach(state); Spatial model = assetManager.loadModel("Models/Teapot/Teapot.obj"); model.scale(3); model.setMaterial(assetManager.loadMaterial("Interface/Logo/Logo.j3m")); state.getRootNode().attachChild(model); NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort); niftyDisplay.getNifty().fromXml("Interface/Nifty/HelloJme.xml", "start"); guiViewPort.addProcessor(niftyDisplay); }
public void makeMissile() { Vector3f pos = spaceCraft.getWorldTranslation().clone(); Quaternion rot = spaceCraft.getWorldRotation(); Vector3f dir = rot.getRotationColumn(2); Spatial missile = assetManager.loadModel("Models/SpaceCraft/Rocket.mesh.xml"); missile.scale(0.5f); missile.rotate(0, FastMath.PI, 0); missile.updateGeometricState(); BoundingBox box = (BoundingBox) missile.getWorldBound(); final Vector3f extent = box.getExtent(null); BoxCollisionShape boxShape = new BoxCollisionShape(extent); missile.setName("Missile"); missile.rotate(rot); missile.setLocalTranslation(pos.addLocal(0, extent.y * 4.5f, 0)); missile.setLocalRotation(hoverControl.getPhysicsRotation()); missile.setShadowMode(ShadowMode.Cast); RigidBodyControl control = new BombControl(assetManager, boxShape, 20); control.setLinearVelocity(dir.mult(100)); control.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_03); missile.addControl(control); rootNode.attachChild(missile); getPhysicsSpace().add(missile); }
@Override public void simpleInitApp() { // activate physics bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); // init a physical test scene PhysicsTestHelper.createPhysicsTestWorldSoccer(rootNode, assetManager, bulletAppState.getPhysicsSpace()); setupKeys(); // Add a physics character to the world physicsCharacter = new CharacterControl(new CapsuleCollisionShape(0.5f, 1.8f), .1f); physicsCharacter.setPhysicsLocation(new Vector3f(0, 1, 0)); characterNode = new Node("character node"); Spatial model = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml"); model.scale(0.25f); characterNode.addControl(physicsCharacter); getPhysicsSpace().add(physicsCharacter); rootNode.attachChild(characterNode); characterNode.attachChild(model); // set forward camera node that follows the character camNode = new CameraNode("CamNode", cam); camNode.setControlDir(ControlDirection.SpatialToCamera); camNode.setLocalTranslation(new Vector3f(0, 1, -5)); camNode.lookAt(model.getLocalTranslation(), Vector3f.UNIT_Y); characterNode.attachChild(camNode); //disable the default 1st-person flyCam (don't forget this!!) flyCam.setEnabled(false); }
@Override public void simpleInitApp() { // Create two boxes Mesh mesh1 = new Box(0.5f, 0.5f, 0.5f); geom1 = new Geometry("Box", mesh1); geom1.move(2, 2, -.5f); Material m1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); m1.setColor("Color", ColorRGBA.Blue); geom1.setMaterial(m1); rootNode.attachChild(geom1); // load a character from jme3test-test-data golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); golem.scale(0.5f); golem.setLocalTranslation(-1.0f, -1.5f, -0.6f); // We must add a light to make the model visible DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal()); golem.addLight(sun); rootNode.attachChild(golem); // Create input inputManager.addMapping("MoveRight", new KeyTrigger(KeyInput.KEY_L)); inputManager.addMapping("MoveLeft", new KeyTrigger(KeyInput.KEY_J)); inputManager.addMapping("MoveUp", new KeyTrigger(KeyInput.KEY_I)); inputManager.addMapping("MoveDown", new KeyTrigger(KeyInput.KEY_K)); inputManager.addListener(analogListener, new String[]{ "MoveRight", "MoveLeft", "MoveUp", "MoveDown" }); } private AnalogListener analogListener = new AnalogListener() {
ninja.scale(0.05f, 0.05f, 0.05f); ninja.rotate(0.0f, -3.0f, 0.0f); ninja.setLocalTranslation(0.0f, -5.0f, -2.0f);
elephant.scale(scale, scale, scale); rootNode.attachChild(elephant);
golem.scale(0.5f); golem.setLocalTranslation(200.0f, -6f, 200f); golem.setShadowMode(ShadowMode.CastAndReceive);
/** * Scales the spatial by the given value * * @return The spatial on which this method is called, e.g <code>this</code>. */ public Spatial scale(float s) { return scale(s, s, s); }
/** * Scales the spatial by the given value * * @return The spatial on which this method is called, e.g <code>this</code>. */ public Spatial scale(float s) { return scale(s, s, s); }
public static void scale(final Spatial spatial) { spatial.scale(MapLoader.TILE_WIDTH, MapLoader.TILE_HEIGHT, MapLoader.TILE_WIDTH); }
model.scale(0.01f); rootNode.attachChild(model);
model.scale(0.01f); rootNode.attachChild(model);