Java Code Examples for com.jme3.scene.Spatial#scale()
The following examples show how to use
com.jme3.scene.Spatial#scale() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestAppStates.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@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); }
Example 2
Source File: TestAppStates.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@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); }
Example 3
Source File: TestMousePick.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
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; }
Example 4
Source File: HelloAssets.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void simpleInitApp() { /** Load a teapot model (OBJ file from test-data) */ Spatial teapot = assetManager.loadModel("Models/Teapot/Teapot.obj"); Material mat_default = new Material( assetManager, "Common/MatDefs/Misc/ShowNormals.j3md"); teapot.setMaterial(mat_default); rootNode.attachChild(teapot); /** Create a wall (Box with material and texture from test-data) */ Box box = new Box(2.5f, 2.5f, 1.0f); Spatial wall = new Geometry("Box", box ); Material mat_brick = new Material( assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat_brick.setTexture("ColorMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg")); wall.setMaterial(mat_brick); wall.setLocalTranslation(2.0f,-2.5f,0.0f); rootNode.attachChild(wall); /** Display a line of text (default font from test-data) */ setDisplayStatView(false); guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText helloText = new BitmapText(guiFont, false); helloText.setSize(guiFont.getCharSet().getRenderedSize()); helloText.setText("Hello World"); helloText.setLocalTranslation(300, helloText.getLineHeight(), 0); guiNode.attachChild(helloText); /** Load a Ninja model (OgreXML + material + texture from test_data) */ Spatial ninja = assetManager.loadModel("Models/Ninja/Ninja.mesh.xml"); ninja.scale(0.05f, 0.05f, 0.05f); ninja.rotate(0.0f, -3.0f, 0.0f); ninja.setLocalTranslation(0.0f, -5.0f, -2.0f); rootNode.attachChild(ninja); /** You must add a light to make the model visible */ DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal()); rootNode.addLight(sun); }
Example 5
Source File: HelloPicking.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
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; }
Example 6
Source File: TestOgreLoading.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void simpleInitApp() { // PointLight pl = new PointLight(); // pl.setPosition(new Vector3f(10, 10, -10)); // rootNode.addLight(pl); flyCam.setMoveSpeed(10f); // sunset light 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); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); rootNode.attachChild(lightMdl); lightMd2 = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMd2.setMaterial(assetManager.loadMaterial("Common/Materials/WhiteColor.j3m")); rootNode.attachChild(lightMd2); pl = new PointLight(); pl.setColor(new ColorRGBA(1, 0.9f, 0.9f, 0)); pl.setPosition(new Vector3f(0f, 0f, 4f)); rootNode.addLight(pl); p2 = new PointLight(); p2.setColor(new ColorRGBA(0.9f, 1, 0.9f, 0)); p2.setPosition(new Vector3f(0f, 0f, 3f)); rootNode.addLight(p2); // create the geometry and attach it Spatial elephant = assetManager.loadModel("Models/Elephant/Elephant.mesh.xml"); float scale = 0.05f; elephant.scale(scale, scale, scale); rootNode.attachChild(elephant); }
Example 7
Source File: TestPhysicsCharacter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@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); }
Example 8
Source File: TestHoveringTank.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
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); }
Example 9
Source File: MapDrawer.java From OpenRTS with MIT License | 5 votes |
private void attachManmadeCliff(Cliff c) { Node n = new Node(); tilesSpatial.get(c.getTile()).add(n); castAndReceiveNode.attachChild(n); ManmadeFace face = (ManmadeFace) (c.face); Spatial s = getModel(face.modelPath); if (s == null) { logger.warning("Can't find model " + face.modelPath); return; } switch (c.type) { case Orthogonal: s.rotate(0, 0, (float) (c.angle + AngleUtil.RIGHT)); break; case Salient: s.rotate(0, 0, (float) (c.angle + AngleUtil.RIGHT)); break; case Corner: s.rotate(0, 0, (float) (c.angle)); break; default: break; } s.scale(0.005f); s.setLocalTranslation((float)c.getTile().getCoord().x + 0.5f, (float)c.getTile().getCoord().y + 0.5f, (float) (c.level * Tile.STAGE_HEIGHT) + 0.1f); n.attachChild(s); }
Example 10
Source File: TestMousePick.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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; }
Example 11
Source File: HelloAssets.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void simpleInitApp() { /** Load a teapot model (OBJ file from test-data) */ Spatial teapot = assetManager.loadModel("Models/Teapot/Teapot.obj"); Material mat_default = new Material( assetManager, "Common/MatDefs/Misc/ShowNormals.j3md"); teapot.setMaterial(mat_default); rootNode.attachChild(teapot); /** Create a wall (Box with material and texture from test-data) */ Box box = new Box(Vector3f.ZERO, 2.5f,2.5f,1.0f); Spatial wall = new Geometry("Box", box ); Material mat_brick = new Material( assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat_brick.setTexture("ColorMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg")); wall.setMaterial(mat_brick); wall.setLocalTranslation(2.0f,-2.5f,0.0f); rootNode.attachChild(wall); /** Display a line of text (default font from test-data) */ guiNode.detachAllChildren(); guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText helloText = new BitmapText(guiFont, false); helloText.setSize(guiFont.getCharSet().getRenderedSize()); helloText.setText("Hello World"); helloText.setLocalTranslation(300, helloText.getLineHeight(), 0); guiNode.attachChild(helloText); /** Load a Ninja model (OgreXML + material + texture from test_data) */ Spatial ninja = assetManager.loadModel("Models/Ninja/Ninja.mesh.xml"); ninja.scale(0.05f, 0.05f, 0.05f); ninja.rotate(0.0f, -3.0f, 0.0f); ninja.setLocalTranslation(0.0f, -5.0f, -2.0f); rootNode.attachChild(ninja); /** You must add a light to make the model visible */ DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal()); rootNode.addLight(sun); }
Example 12
Source File: HelloPicking.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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; }
Example 13
Source File: TestOgreLoading.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void simpleInitApp() { // PointLight pl = new PointLight(); // pl.setPosition(new Vector3f(10, 10, -10)); // rootNode.addLight(pl); flyCam.setMoveSpeed(10f); // sunset light 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); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); rootNode.attachChild(lightMdl); lightMd2 = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMd2.setMaterial(assetManager.loadMaterial("Common/Materials/WhiteColor.j3m")); rootNode.attachChild(lightMd2); pl = new PointLight(); pl.setColor(new ColorRGBA(1, 0.9f, 0.9f, 0)); pl.setPosition(new Vector3f(0f, 0f, 4f)); rootNode.addLight(pl); p2 = new PointLight(); p2.setColor(new ColorRGBA(0.9f, 1, 0.9f, 0)); p2.setPosition(new Vector3f(0f, 0f, 3f)); rootNode.addLight(p2); // create the geometry and attach it Spatial elephant = (Spatial) assetManager.loadModel("Models/Elephant/Elephant.mesh.xml"); float scale = 0.05f; elephant.scale(scale, scale, scale); rootNode.attachChild(elephant); }
Example 14
Source File: TestPhysicsCharacter.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@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); }
Example 15
Source File: TestHoveringTank.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example 16
Source File: TestShadowBug.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { flyCam.setMoveSpeed(100f); rootNode.attachChild(makeFloor()); Node characters = new Node("Characters"); characters.setShadowMode(ShadowMode.Cast); rootNode.attachChild(characters); Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); golem.scale(0.5f); golem.setLocalTranslation(200.0f, -6f, 200f); golem.setShadowMode(ShadowMode.CastAndReceive); characters.attachChild(golem); DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-1f, -1f, 1f)); sun.setColor(ColorRGBA.White.mult(1.3f)); rootNode.addLight(sun); characters.addLight(sun); SpotLight spot = new SpotLight(); spot.setSpotRange(13f); // distance spot.setSpotInnerAngle(15f * FastMath.DEG_TO_RAD); // inner light cone (central beam) spot.setSpotOuterAngle(20f * FastMath.DEG_TO_RAD); // outer light cone (edge of the light) spot.setColor(ColorRGBA.White.mult(1.3f)); // light color spot.setPosition(new Vector3f(192.0f, -1f, 192f)); spot.setDirection(new Vector3f(1, -0.5f, 1)); rootNode.addLight(spot); PointLight lamp_light = new PointLight(); lamp_light.setColor(ColorRGBA.Yellow); lamp_light.setRadius(20f); lamp_light.setPosition(new Vector3f(210.0f, 0f, 210f)); rootNode.addLight(lamp_light); SpotLightShadowRenderer slsr = new SpotLightShadowRenderer(assetManager, 512); slsr.setLight(spot); slsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest); slsr.setShadowIntensity(0.6f); viewPort.addProcessor(slsr); PointLightShadowRenderer plsr = new PointLightShadowRenderer(assetManager, 512); plsr.setLight(lamp_light); plsr.setShadowIntensity(0.6f); plsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest); viewPort.addProcessor(plsr); viewPort.getCamera().setLocation(new Vector3f(192.0f, 10f, 192f)); float[] angles = new float[]{3.14f/2, 3.14f/2, 0}; viewPort.getCamera().setRotation(new Quaternion(angles)); }