Java Code Examples for com.jme3.light.AmbientLight#setColor()
The following examples show how to use
com.jme3.light.AmbientLight#setColor() .
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: TestUnshadedModel.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void simpleInitApp() { Sphere sphMesh = new Sphere(32, 32, 1); sphMesh.setTextureMode(Sphere.TextureMode.Projected); sphMesh.updateGeometry(32, 32, 1, false, false); TangentBinormalGenerator.generate(sphMesh); Geometry sphere = new Geometry("Rock Ball", sphMesh); Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); mat.setColor("Ambient", ColorRGBA.DarkGray); mat.setColor("Diffuse", ColorRGBA.White); mat.setBoolean("UseMaterialColors", true); sphere.setMaterial(mat); rootNode.attachChild(sphere); PointLight pl = new PointLight(); pl.setColor(ColorRGBA.White); pl.setPosition(new Vector3f(4f, 0f, 0f)); rootNode.addLight(pl); AmbientLight al = new AmbientLight(); al.setColor(ColorRGBA.White); rootNode.addLight(al); }
Example 2
Source File: TestUnshadedModel.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void simpleInitApp() { Sphere sphMesh = new Sphere(32, 32, 1); sphMesh.setTextureMode(Sphere.TextureMode.Projected); sphMesh.updateGeometry(32, 32, 1, false, false); TangentBinormalGenerator.generate(sphMesh); Geometry sphere = new Geometry("Rock Ball", sphMesh); Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); mat.setColor("Ambient", ColorRGBA.DarkGray); mat.setColor("Diffuse", ColorRGBA.White); mat.setBoolean("UseMaterialColors", true); sphere.setMaterial(mat); rootNode.attachChild(sphere); PointLight pl = new PointLight(); pl.setColor(ColorRGBA.White); pl.setPosition(new Vector3f(4f, 0f, 0f)); rootNode.addLight(pl); AmbientLight al = new AmbientLight(); al.setColor(ColorRGBA.White); rootNode.addLight(al); }
Example 3
Source File: TestSpotLightTerrain.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void simpleInitApp() { makeTerrain(); flyCam.setMoveSpeed(50); sl = new SpotLight(); sl.setSpotRange(100); sl.setSpotOuterAngle(20 * FastMath.DEG_TO_RAD); sl.setSpotInnerAngle(15 * FastMath.DEG_TO_RAD); sl.setDirection(new Vector3f(-0.39820394f, -0.73094344f, 0.55421597f)); sl.setPosition(new Vector3f(-64.61567f, -87.615425f, -202.41328f)); rootNode.addLight(sl); AmbientLight ambLight = new AmbientLight(); ambLight.setColor(new ColorRGBA(0.8f, 0.8f, 0.8f, 0.2f)); rootNode.addLight(ambLight); cam.setLocation(new Vector3f(-41.219646f, -84.8363f, -171.67267f)); cam.setRotation(new Quaternion(-0.04562731f, 0.89917684f, -0.09668826f, -0.4243236f)); sl.setDirection(cam.getDirection()); sl.setPosition(cam.getLocation()); }
Example 4
Source File: TestSpotLight.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setupLighting(){ AmbientLight al=new AmbientLight(); al.setColor(ColorRGBA.White.mult(0.02f)); rootNode.addLight(al); spot=new SpotLight(); spot.setSpotRange(1000); spot.setSpotInnerAngle(5*FastMath.DEG_TO_RAD); spot.setSpotOuterAngle(10*FastMath.DEG_TO_RAD); spot.setPosition(new Vector3f(77.70334f, 34.013165f, 27.1017f)); spot.setDirection(lightTarget.subtract(spot.getPosition())); spot.setColor(ColorRGBA.White.mult(2)); rootNode.addLight(spot); // PointLight pl=new PointLight(); // pl.setPosition(new Vector3f(77.70334f, 34.013165f, 27.1017f)); // pl.setRadius(1000); // pl.setColor(ColorRGBA.White.mult(2)); // rootNode.addLight(pl); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); lightMdl.setLocalTranslation(new Vector3f(77.70334f, 34.013165f, 27.1017f)); lightMdl.setLocalScale(5); rootNode.attachChild(lightMdl); // DirectionalLight dl = new DirectionalLight(); // dl.setDirection(lightTarget.subtract(new Vector3f(77.70334f, 34.013165f, 27.1017f))); // dl.setColor(ColorRGBA.White.mult(2)); // rootNode.addLight(dl); }
Example 5
Source File: TestSpotLight.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void setupLighting(){ AmbientLight al=new AmbientLight(); al.setColor(ColorRGBA.White.mult(0.8f)); rootNode.addLight(al); spot=new SpotLight(); spot.setSpotRange(1000); spot.setSpotInnerAngle(5*FastMath.DEG_TO_RAD); spot.setSpotOuterAngle(10*FastMath.DEG_TO_RAD); spot.setPosition(new Vector3f(77.70334f, 34.013165f, 27.1017f)); spot.setDirection(lightTarget.subtract(spot.getPosition())); spot.setColor(ColorRGBA.White.mult(2)); rootNode.addLight(spot); // PointLight pl=new PointLight(); // pl.setPosition(new Vector3f(77.70334f, 34.013165f, 27.1017f)); // pl.setRadius(1000); // pl.setColor(ColorRGBA.White.mult(2)); // rootNode.addLight(pl); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); lightMdl.setLocalTranslation(new Vector3f(77.70334f, 34.013165f, 27.1017f)); lightMdl.setLocalScale(5); rootNode.attachChild(lightMdl); // DirectionalLight dl = new DirectionalLight(); // dl.setDirection(lightTarget.subtract(new Vector3f(77.70334f, 34.013165f, 27.1017f))); // dl.setColor(ColorRGBA.White.mult(2)); // rootNode.addLight(dl); }
Example 6
Source File: TestSSAO.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void simpleInitApp() { cam.setLocation(new Vector3f(68.45442f, 8.235511f, 7.9676695f)); cam.setRotation(new Quaternion(0.046916496f, -0.69500375f, 0.045538206f, 0.7160271f)); flyCam.setMoveSpeed(50); Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); Texture diff = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"); diff.setWrap(Texture.WrapMode.Repeat); Texture norm = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall_normal.jpg"); norm.setWrap(Texture.WrapMode.Repeat); mat.setTexture("DiffuseMap", diff); mat.setTexture("NormalMap", norm); mat.setFloat("Shininess", 2.0f); AmbientLight al = new AmbientLight(); al.setColor(new ColorRGBA(1.8f, 1.8f, 1.8f, 1.0f)); rootNode.addLight(al); model = (Geometry) assetManager.loadModel("Models/Sponza/Sponza.j3o"); model.getMesh().scaleTextureCoordinates(new Vector2f(2, 2)); model.setMaterial(mat); rootNode.attachChild(model); FilterPostProcessor fpp = new FilterPostProcessor(assetManager); SSAOFilter ssaoFilter = new SSAOFilter(12.940201f, 43.928635f, 0.32999992f, 0.6059958f); fpp.addFilter(ssaoFilter); SSAOUI ui = new SSAOUI(inputManager, ssaoFilter); viewPort.addProcessor(fpp); }
Example 7
Source File: AbstractBlenderLoader.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * This method returns the data read from the WORLD file block. The block contains data that can be stored as * separate jme features and therefore cannot be returned as a single jME scene feature. * @param structure * the structure with WORLD block data * @return data read from the WORLD block that can be added to the scene */ public WorldData toWorldData(Structure structure) { WorldData result = new WorldData(); // reading ambient light AmbientLight ambientLight = new AmbientLight(); float ambr = ((Number) structure.getFieldValue("ambr")).floatValue(); float ambg = ((Number) structure.getFieldValue("ambg")).floatValue(); float ambb = ((Number) structure.getFieldValue("ambb")).floatValue(); ambientLight.setColor(new ColorRGBA(ambr, ambg, ambb, 0.0f)); result.setAmbientLight(ambientLight); return result; }
Example 8
Source File: HelloCollision.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private void setUpLight() { // We add light so we see the scene AmbientLight al = new AmbientLight(); al.setColor(ColorRGBA.White.mult(1.3f)); rootNode.addLight(al); DirectionalLight dl = new DirectionalLight(); dl.setColor(ColorRGBA.White); dl.setDirection(new Vector3f(2.8f, -2.8f, -2.8f).normalizeLocal()); rootNode.addLight(dl); }
Example 9
Source File: TerrainTestModifyHeight.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void simpleInitApp() { loadHintText(); initCrossHairs(); setupKeys(); createMarker(); // WIREFRAME material matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); matWire.getAdditionalRenderState().setWireframe(true); matWire.setColor("Color", ColorRGBA.Green); createTerrain(); //createTerrainGrid(); DirectionalLight light = new DirectionalLight(); light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize()); rootNode.addLight(light); AmbientLight ambLight = new AmbientLight(); ambLight.setColor(new ColorRGBA(1f, 1f, 0.8f, 0.2f)); rootNode.addLight(ambLight); cam.setLocation(new Vector3f(0, 256, 0)); cam.lookAtDirection(new Vector3f(0, -1f, 0).normalizeLocal(), Vector3f.UNIT_X); }
Example 10
Source File: TestJaime.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setupLights() { AmbientLight al = new AmbientLight(); al.setColor(new ColorRGBA(0.1f, 0.1f, 0.1f, 1)); rootNode.addLight(al); SpotLight sl = new SpotLight(); sl.setColor(ColorRGBA.White.mult(1.0f)); sl.setPosition(new Vector3f(1.2074411f, 10.6868908f, 4.1489987f)); sl.setDirection(sl.getPosition().mult(-1)); sl.setSpotOuterAngle(0.1f); sl.setSpotInnerAngle(0.004f); rootNode.addLight(sl); //pointlight to fake indirect light coming from the ground PointLight pl = new PointLight(); pl.setColor(ColorRGBA.White.mult(1.5f)); pl.setPosition(new Vector3f(0, 0, 1)); pl.setRadius(2); rootNode.addLight(pl); SpotLightShadowRenderer shadows = new SpotLightShadowRenderer(assetManager, 1024); shadows.setLight(sl); shadows.setShadowIntensity(0.3f); shadows.setEdgeFilteringMode(EdgeFilteringMode.PCF8); viewPort.addProcessor(shadows); FilterPostProcessor fpp = new FilterPostProcessor(assetManager); SSAOFilter filter = new SSAOFilter(0.10997847f,0.440001f,0.39999998f,-0.008000026f);; fpp.addFilter(filter); fpp.addFilter(new FXAAFilter()); fpp.addFilter(new FXAAFilter()); viewPort.addProcessor(fpp); }
Example 11
Source File: TestQ3.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); flyCam.setMoveSpeed(100); setupKeys(); this.cam.setFrustumFar(2000); DirectionalLight dl = new DirectionalLight(); dl.setColor(ColorRGBA.White.clone().multLocal(2)); dl.setDirection(new Vector3f(-1, -1, -1).normalize()); rootNode.addLight(dl); AmbientLight am = new AmbientLight(); am.setColor(ColorRGBA.White.mult(2)); rootNode.addLight(am); // load the level from zip or http zip if (useHttp) { assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/quake3level.zip", HttpZipLocator.class.getName()); } else { assetManager.registerLocator("quake3level.zip", ZipLocator.class.getName()); } // create the geometry and attach it MaterialList matList = (MaterialList) assetManager.loadAsset("Scene.material"); OgreMeshKey key = new OgreMeshKey("main.meshxml", matList); gameLevel = (Node) assetManager.loadAsset(key); gameLevel.setLocalScale(0.1f); // add a physics control, it will generate a MeshCollisionShape based on the gameLevel gameLevel.addControl(new RigidBodyControl(0)); player = new PhysicsCharacter(new SphereCollisionShape(5), .01f); player.setJumpSpeed(20); player.setFallSpeed(30); player.setGravity(30); player.setPhysicsLocation(new Vector3f(60, 10, -60)); rootNode.attachChild(gameLevel); getPhysicsSpace().addAll(gameLevel); getPhysicsSpace().add(player); }
Example 12
Source File: TestDirectionalLightShadow.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void loadScene() { obj = new Spatial[2]; // Setup first view mat = new Material[2]; mat[0] = assetManager.loadMaterial("Common/Materials/RedColor.j3m"); mat[1] = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); mat[1].setBoolean("UseMaterialColors", true); mat[1].setColor("Ambient", ColorRGBA.White); mat[1].setColor("Diffuse", ColorRGBA.White.clone()); obj[0] = new Geometry("sphere", new Sphere(30, 30, 2)); obj[0].setShadowMode(ShadowMode.CastAndReceive); obj[1] = new Geometry("cube", new Box(1.0f, 1.0f, 1.0f)); obj[1].setShadowMode(ShadowMode.CastAndReceive); TangentBinormalGenerator.generate(obj[1]); TangentBinormalGenerator.generate(obj[0]); Spatial t = obj[0].clone(false); t.setLocalScale(10f); t.setMaterial(mat[1]); rootNode.attachChild(t); t.setLocalTranslation(0, 25, 0); for (int i = 0; i < 60; i++) { t = obj[FastMath.nextRandomInt(0, obj.length - 1)].clone(false); t.setLocalScale(FastMath.nextRandomFloat() * 10f); t.setMaterial(mat[FastMath.nextRandomInt(0, mat.length - 1)]); rootNode.attachChild(t); t.setLocalTranslation(FastMath.nextRandomFloat() * 200f, FastMath.nextRandomFloat() * 30f + 20, 30f * (i + 2f)); } Box b = new Box(1000, 2, 1000); b.scaleTextureCoordinates(new Vector2f(10, 10)); ground = new Geometry("soil", b); ground.setLocalTranslation(0, 10, 550); matGroundU = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); matGroundU.setColor("Color", ColorRGBA.Green); matGroundL = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg"); grass.setWrap(WrapMode.Repeat); matGroundL.setTexture("DiffuseMap", grass); ground.setMaterial(matGroundL); ground.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(ground); l = new DirectionalLight(); //l.setDirection(new Vector3f(0.5973172f, -0.16583486f, 0.7846725f).normalizeLocal()); l.setDirection(new Vector3f(-1, -1, -1)); rootNode.addLight(l); al = new AmbientLight(); al.setColor(ColorRGBA.White.mult(0.02f)); rootNode.addLight(al); Spatial sky = SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", EnvMapType.CubeMap); sky.setLocalScale(350); rootNode.attachChild(sky); }
Example 13
Source File: TestTransparentSSAO.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { renderManager.setAlphaToCoverage(true); cam.setLocation(new Vector3f(0.14914267f, 0.58147097f, 4.7686534f)); cam.setRotation(new Quaternion(-0.0044764364f, 0.9767943f, 0.21314798f, 0.020512417f)); // cam.setLocation(new Vector3f(2.0606942f, 3.20342f, 6.7860126f)); // cam.setRotation(new Quaternion(-0.017481906f, 0.98241085f, -0.12393151f, -0.13857932f)); viewPort.setBackgroundColor(ColorRGBA.DarkGray); Quad q = new Quad(20, 20); q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(5)); Geometry geom = new Geometry("floor", q); Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); geom.setMaterial(mat); geom.rotate(-FastMath.HALF_PI, 0, 0); geom.center(); geom.setShadowMode(ShadowMode.Receive); TangentBinormalGenerator.generate(geom); rootNode.attachChild(geom); // create the geometry and attach it Spatial teaGeom = assetManager.loadModel("Models/Tree/Tree.mesh.j3o"); teaGeom.setQueueBucket(Bucket.Transparent); teaGeom.setShadowMode(ShadowMode.Cast); AmbientLight al = new AmbientLight(); al.setColor(ColorRGBA.White.mult(2)); rootNode.addLight(al); DirectionalLight dl1 = new DirectionalLight(); dl1.setDirection(new Vector3f(1, -1, 1).normalizeLocal()); dl1.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f)); rootNode.addLight(dl1); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal()); dl.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f)); rootNode.addLight(dl); rootNode.attachChild(teaGeom); FilterPostProcessor fpp = new FilterPostProcessor(assetManager); SSAOFilter ssao = new SSAOFilter();//0.49997783f, 42.598858f, 35.999966f, 0.39299846f fpp.addFilter(ssao); SSAOUI ui = new SSAOUI(inputManager, ssao); viewPort.addProcessor(fpp); }
Example 14
Source File: PhysicsTestHelper.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
/** * creates a simple physics test world with a floor, an obstacle and some test boxes * @param rootNode * @param assetManager * @param space */ public static void createPhysicsTestWorld(Node rootNode, AssetManager assetManager, PhysicsSpace space) { AmbientLight light = new AmbientLight(); light.setColor(ColorRGBA.LightGray); rootNode.addLight(light); Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); Box floorBox = new Box(140, 0.25f, 140); Geometry floorGeometry = new Geometry("Floor", floorBox); floorGeometry.setMaterial(material); floorGeometry.setLocalTranslation(0, -5, 0); // Plane plane = new Plane(); // plane.setOriginNormal(new Vector3f(0, 0.25f, 0), Vector3f.UNIT_Y); // floorGeometry.addControl(new RigidBodyControl(new PlaneCollisionShape(plane), 0)); floorGeometry.addControl(new RigidBodyControl(0)); rootNode.attachChild(floorGeometry); space.add(floorGeometry); //movable boxes for (int i = 0; i < 12; i++) { Box box = new Box(0.25f, 0.25f, 0.25f); Geometry boxGeometry = new Geometry("Box", box); boxGeometry.setMaterial(material); boxGeometry.setLocalTranslation(i, 5, -3); //RigidBodyControl automatically uses box collision shapes when attached to single geometry with box mesh boxGeometry.addControl(new RigidBodyControl(2)); rootNode.attachChild(boxGeometry); space.add(boxGeometry); } //immovable sphere with mesh collision shape Sphere sphere = new Sphere(8, 8, 1); Geometry sphereGeometry = new Geometry("Sphere", sphere); sphereGeometry.setMaterial(material); sphereGeometry.setLocalTranslation(4, -4, 2); sphereGeometry.addControl(new RigidBodyControl(new MeshCollisionShape(sphere), 0)); rootNode.attachChild(sphereGeometry); space.add(sphereGeometry); }
Example 15
Source File: TestShadowsPerf.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { flyCam.setMoveSpeed(50); flyCam.setEnabled(false); viewPort.setBackgroundColor(ColorRGBA.DarkGray); cam.setLocation(new Vector3f(-53.952988f, 27.15874f, -32.875023f)); cam.setRotation(new Quaternion(0.1564309f, 0.6910534f, -0.15713608f, 0.6879555f)); // cam.setLocation(new Vector3f(53.64627f, 130.56f, -11.247704f)); // cam.setRotation(new Quaternion(-6.5737107E-4f, 0.76819664f, -0.64021313f, -7.886125E-4f)); //// cam.setFrustumFar(500); mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); Box b = new Box(800, 1, 700); b.scaleTextureCoordinates(new Vector2f(50, 50)); Geometry ground = new Geometry("ground", b); ground.setMaterial(mat); rootNode.attachChild(ground); ground.setShadowMode(ShadowMode.Receive); Sphere sphMesh = new Sphere(32, 32, 1); sphMesh.setTextureMode(Sphere.TextureMode.Projected); sphMesh.updateGeometry(32, 32, 1, false, false); TangentBinormalGenerator.generate(sphMesh); sphere = new Geometry("Rock Ball", sphMesh); sphere.setLocalTranslation(0, 5, 0); sphere.setMaterial(mat); sphere.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(sphere); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(0, -1, 0).normalizeLocal()); dl.setColor(ColorRGBA.White); rootNode.addLight(dl); AmbientLight al = new AmbientLight(); al.setColor(ColorRGBA.White.mult(0.7f)); rootNode.addLight(al); //rootNode.setShadowMode(ShadowMode.CastAndReceive); createballs(); final DirectionalLightShadowRenderer pssmRenderer = new DirectionalLightShadowRenderer(assetManager, 1024, 4); viewPort.addProcessor(pssmRenderer); // // final PssmShadowFilter pssmRenderer = new PssmShadowFilter(assetManager, 1024, 4); // FilterPostProcessor fpp = new FilterPostProcessor(assetManager); // fpp.addFilter(pssmRenderer); // viewPort.addProcessor(fpp); pssmRenderer.setLight(dl); pssmRenderer.setLambda(0.55f); pssmRenderer.setShadowIntensity(0.55f); pssmRenderer.setShadowCompareMode(com.jme3.shadow.CompareMode.Software); pssmRenderer.setEdgeFilteringMode(EdgeFilteringMode.PCF4); //pssmRenderer.displayDebug(); inputManager.addListener(new ActionListener() { @Override public void onAction(String name, boolean isPressed, float tpf) { if (name.equals("display") && isPressed) { //pssmRenderer.debugFrustrums(); System.out.println("tetetetet"); } if (name.equals("add") && isPressed) { createballs(); } } }, "display", "add"); inputManager.addMapping("display", new KeyTrigger(KeyInput.KEY_SPACE)); inputManager.addMapping("add", new KeyTrigger(KeyInput.KEY_RETURN)); }
Example 16
Source File: TestTransparentCartoonEdge.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { renderManager.setAlphaToCoverage(true); cam.setLocation(new Vector3f(0.14914267f, 0.58147097f, 4.7686534f)); cam.setRotation(new Quaternion(-0.0044764364f, 0.9767943f, 0.21314798f, 0.020512417f)); // cam.setLocation(new Vector3f(2.0606942f, 3.20342f, 6.7860126f)); // cam.setRotation(new Quaternion(-0.017481906f, 0.98241085f, -0.12393151f, -0.13857932f)); viewPort.setBackgroundColor(ColorRGBA.DarkGray); Quad q = new Quad(20, 20); q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(5)); Geometry geom = new Geometry("floor", q); Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); geom.setMaterial(mat); geom.rotate(-FastMath.HALF_PI, 0, 0); geom.center(); geom.setShadowMode(ShadowMode.Receive); rootNode.attachChild(geom); // create the geometry and attach it Spatial teaGeom = assetManager.loadModel("Models/Tree/Tree.mesh.j3o"); teaGeom.setQueueBucket(Bucket.Transparent); teaGeom.setShadowMode(ShadowMode.Cast); makeToonish(teaGeom); AmbientLight al = new AmbientLight(); al.setColor(ColorRGBA.White.mult(2)); rootNode.addLight(al); DirectionalLight dl1 = new DirectionalLight(); dl1.setDirection(new Vector3f(1, -1, 1).normalizeLocal()); dl1.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f)); rootNode.addLight(dl1); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal()); dl.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f)); rootNode.addLight(dl); rootNode.attachChild(teaGeom); FilterPostProcessor fpp=new FilterPostProcessor(assetManager); CartoonEdgeFilter toon=new CartoonEdgeFilter(); toon.setEdgeWidth(0.5f); toon.setEdgeIntensity(1.0f); toon.setNormalThreshold(0.8f); fpp.addFilter(toon); viewPort.addProcessor(fpp); }
Example 17
Source File: TerrainTestTile.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { loadHintText(); setupKeys(); // WIREFRAME material matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); matWire.getAdditionalRenderState().setWireframe(true); matWire.setColor("Color", ColorRGBA.Green); terrain = new TiledTerrain(); rootNode.attachChild(terrain); DirectionalLight light = new DirectionalLight(); light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize()); rootNode.addLight(light); AmbientLight ambLight = new AmbientLight(); ambLight.setColor(new ColorRGBA(1f, 1f, 0.8f, 0.2f)); rootNode.addLight(ambLight); cam.setLocation(new Vector3f(0, 256, 0)); cam.lookAtDirection(new Vector3f(0, -1, -1).normalizeLocal(), Vector3f.UNIT_Y); Sphere s = new Sphere(12, 12, 3); Geometry g = new Geometry("marker"); g.setMesh(s); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Red); g.setMaterial(mat); g.setLocalTranslation(0, -100, 0); rootNode.attachChild(g); Geometry g2 = new Geometry("marker"); g2.setMesh(s); mat.setColor("Color", ColorRGBA.Red); g2.setMaterial(mat); g2.setLocalTranslation(10, -100, 0); rootNode.attachChild(g2); Geometry g3 = new Geometry("marker"); g3.setMesh(s); mat.setColor("Color", ColorRGBA.Red); g3.setMaterial(mat); g3.setLocalTranslation(0, -100, 10); rootNode.attachChild(g3); }
Example 18
Source File: TestQ3.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { File file = new File("quake3level.zip"); if (!file.exists()) { useHttp = true; } bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); flyCam.setMoveSpeed(100); setupKeys(); this.cam.setFrustumFar(2000); DirectionalLight dl = new DirectionalLight(); dl.setColor(ColorRGBA.White.clone().multLocal(2)); dl.setDirection(new Vector3f(-1, -1, -1).normalize()); rootNode.addLight(dl); AmbientLight am = new AmbientLight(); am.setColor(ColorRGBA.White.mult(2)); rootNode.addLight(am); // load the level from zip or http zip if (useHttp) { assetManager.registerLocator( "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jmonkeyengine/quake3level.zip", HttpZipLocator.class); } else { assetManager.registerLocator("quake3level.zip", ZipLocator.class); } // create the geometry and attach it MaterialList matList = (MaterialList) assetManager.loadAsset("Scene.material"); OgreMeshKey key = new OgreMeshKey("main.meshxml", matList); gameLevel = (Node) assetManager.loadAsset(key); gameLevel.setLocalScale(0.1f); // add a physics control, it will generate a MeshCollisionShape based on the gameLevel gameLevel.addControl(new RigidBodyControl(0)); player = new PhysicsCharacter(new SphereCollisionShape(5), .01f); player.setJumpSpeed(20); player.setFallSpeed(30); player.setGravity(30); player.setPhysicsLocation(new Vector3f(60, 10, -60)); rootNode.attachChild(gameLevel); getPhysicsSpace().addAll(gameLevel); getPhysicsSpace().add(player); }
Example 19
Source File: TestTransparentCartoonEdge.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void simpleInitApp() { renderManager.setAlphaToCoverage(true); cam.setLocation(new Vector3f(0.14914267f, 0.58147097f, 4.7686534f)); cam.setRotation(new Quaternion(-0.0044764364f, 0.9767943f, 0.21314798f, 0.020512417f)); // cam.setLocation(new Vector3f(2.0606942f, 3.20342f, 6.7860126f)); // cam.setRotation(new Quaternion(-0.017481906f, 0.98241085f, -0.12393151f, -0.13857932f)); viewPort.setBackgroundColor(ColorRGBA.DarkGray); Quad q = new Quad(20, 20); q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(5)); Geometry geom = new Geometry("floor", q); Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); geom.setMaterial(mat); geom.rotate(-FastMath.HALF_PI, 0, 0); geom.center(); geom.setShadowMode(ShadowMode.Receive); rootNode.attachChild(geom); // create the geometry and attach it Spatial teaGeom = assetManager.loadModel("Models/Tree/Tree2.mesh.xml"); teaGeom.setQueueBucket(Bucket.Transparent); teaGeom.setShadowMode(ShadowMode.Cast); makeToonish(teaGeom); AmbientLight al = new AmbientLight(); al.setColor(ColorRGBA.White.mult(2)); rootNode.addLight(al); DirectionalLight dl1 = new DirectionalLight(); dl1.setDirection(new Vector3f(1, -1, 1).normalizeLocal()); dl1.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f)); rootNode.addLight(dl1); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal()); dl.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f)); rootNode.addLight(dl); rootNode.attachChild(teaGeom); FilterPostProcessor fpp=new FilterPostProcessor(assetManager); CartoonEdgeFilter toon=new CartoonEdgeFilter(); toon.setEdgeWidth(0.5f); toon.setEdgeIntensity(1.0f); toon.setNormalThreshold(0.8f); fpp.addFilter(toon); viewPort.addProcessor(fpp); }
Example 20
Source File: PhysicsTestHelper.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public static void createPhysicsTestWorldSoccer(Node rootNode, AssetManager assetManager, PhysicsSpace space) { AmbientLight light = new AmbientLight(); light.setColor(ColorRGBA.LightGray); rootNode.addLight(light); Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); Box floorBox = new Box(140, 0.25f, 140); Geometry floorGeometry = new Geometry("Floor", floorBox); floorGeometry.setMaterial(material); floorGeometry.setLocalTranslation(0, -0.25f, 0); // Plane plane = new Plane(); // plane.setOriginNormal(new Vector3f(0, 0.25f, 0), Vector3f.UNIT_Y); // floorGeometry.addControl(new RigidBodyControl(new PlaneCollisionShape(plane), 0)); floorGeometry.addControl(new RigidBodyControl(0)); rootNode.attachChild(floorGeometry); space.add(floorGeometry); //movable spheres for (int i = 0; i < 5; i++) { Sphere sphere = new Sphere(16, 16, .5f); Geometry ballGeometry = new Geometry("Soccer ball", sphere); ballGeometry.setMaterial(material); ballGeometry.setLocalTranslation(i, 2, -3); //RigidBodyControl automatically uses Sphere collision shapes when attached to single geometry with sphere mesh ballGeometry.addControl(new RigidBodyControl(.001f)); ballGeometry.getControl(RigidBodyControl.class).setRestitution(1); rootNode.attachChild(ballGeometry); space.add(ballGeometry); } //immovable Box with mesh collision shape Box box = new Box(1, 1, 1); Geometry boxGeometry = new Geometry("Box", box); boxGeometry.setMaterial(material); boxGeometry.setLocalTranslation(4, 1, 2); boxGeometry.addControl(new RigidBodyControl(new MeshCollisionShape(box), 0)); rootNode.attachChild(boxGeometry); space.add(boxGeometry); }