Java Code Examples for com.jme3.scene.Spatial#setShadowMode()
The following examples show how to use
com.jme3.scene.Spatial#setShadowMode() .
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: TestParallaxPBR.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setupSignpost() { Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); TangentBinormalGenerator.generate(signpost); signpost.setMaterial(mat); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 23.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(signpost); }
Example 2
Source File: TestParallax.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void setupSignpost() { Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); TangentBinormalGenerator.generate(signpost); signpost.setMaterial(mat); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 23.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(signpost); }
Example 3
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 4
Source File: TestSpotLight.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void setupSignpost(){ Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); // mat.setBoolean("VertexLighting", true); signpost.setMaterial(mat); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 3.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); TangentBinormalGenerator.generate(signpost); rootNode.attachChild(signpost); }
Example 5
Source File: TestPostFilters.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void setupSignpost() { Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); signpost.setMaterial(mat); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 3.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(signpost); }
Example 6
Source File: TestEverything.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setupSignpost(){ Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); signpost.setMaterial(mat); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 3.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(signpost); }
Example 7
Source File: TestParallax.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setupSignpost() { Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material matSp = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); TangentBinormalGenerator.generate(signpost); signpost.setMaterial(matSp); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 23.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(signpost); }
Example 8
Source File: TestEverything.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void setupSignpost(){ Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); signpost.setMaterial(mat); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 3.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(signpost); }
Example 9
Source File: TestSpotLight.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setupSignpost(){ Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); // mat.setBoolean("VertexLighting", true); signpost.setMaterial(mat); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 3.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); TangentBinormalGenerator.generate(signpost); rootNode.attachChild(signpost); }
Example 10
Source File: TestSpotLightShadows.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setupSignpost() { Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); // mat.setBoolean("VertexLighting", true); signpost.setMaterial(mat); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 3.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); TangentBinormalGenerator.generate(signpost); rootNode.attachChild(signpost); }
Example 11
Source File: TestPostFilters.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setupSignpost() { Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); signpost.setMaterial(mat); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 3.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(signpost); }
Example 12
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)); }
Example 13
Source File: TestTransparentShadow.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { cam.setLocation(new Vector3f(5.700248f, 6.161693f, 5.1404157f)); cam.setRotation(new Quaternion(-0.09441641f, 0.8993388f, -0.24089815f, -0.35248178f)); viewPort.setBackgroundColor(ColorRGBA.DarkGray); Quad q = new Quad(20, 20); q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(10)); TangentBinormalGenerator.generate(q); 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.CastAndReceive); rootNode.attachChild(geom); AmbientLight al = new AmbientLight(); al.setColor(ColorRGBA.White.mult(0.7f)); rootNode.addLight(al); DirectionalLight dl1 = new DirectionalLight(); dl1.setDirection(new Vector3f(0, -1, 0.5f).normalizeLocal()); dl1.setColor(ColorRGBA.White.mult(1.5f)); rootNode.addLight(dl1); // create the geometry and attach it Spatial tree = assetManager.loadModel("Models/Tree/Tree.mesh.j3o"); tree.setQueueBucket(Bucket.Transparent); tree.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(tree); // Uses Texture from jme3-test-data library! ParticleEmitter fire = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30); Material mat_red = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat_red.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png")); fire.setShadowMode(ShadowMode.Cast); fire.setMaterial(mat_red); fire.setImagesX(2); fire.setImagesY(2); // 2x2 texture animation fire.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f)); // red fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0)); fire.setStartSize(0.6f); fire.setEndSize(0.1f); fire.setGravity(0, 0, 0); fire.setLowLife(0.5f); fire.setHighLife(1.5f); fire.getParticleInfluencer().setVelocityVariation(0.3f); fire.setLocalTranslation(5.0f, 0, 1.0f); fire.setLocalScale(0.3f); fire.setQueueBucket(Bucket.Translucent); rootNode.attachChild(fire); Material mat2 = assetManager.loadMaterial("Common/Materials/RedColor.j3m"); Geometry ball = new Geometry("sphere", new Sphere(16, 16, 0.5f)); ball.setMaterial(mat2); ball.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(ball); ball.setLocalTranslation(-1.0f, 1.5f, 1.0f); final DirectionalLightShadowRenderer dlsRenderer = new DirectionalLightShadowRenderer(assetManager, 1024, 1); dlsRenderer.setLight(dl1); dlsRenderer.setLambda(0.55f); dlsRenderer.setShadowIntensity(0.8f); dlsRenderer.setShadowCompareMode(CompareMode.Software); dlsRenderer.setEdgeFilteringMode(EdgeFilteringMode.Nearest); dlsRenderer.displayDebug(); viewPort.addProcessor(dlsRenderer); inputManager.addMapping("stabilize", new KeyTrigger(KeyInput.KEY_B)); inputManager.addListener(new ActionListener() { @Override public void onAction(String name, boolean isPressed, float tpf) { if (name.equals("stabilize") && isPressed) { dlsRenderer.setEnabledStabilization(!dlsRenderer.isEnabledStabilization()) ; } } }, "stabilize"); }
Example 14
Source File: TestLightScattering.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { // put the camera in a bad position cam.setLocation(new Vector3f(55.35316f, -0.27061665f, 27.092093f)); cam.setRotation(new Quaternion(0.010414706f, 0.9874893f, 0.13880467f, -0.07409228f)); // cam.setDirection(new Vector3f(0,-0.5f,1.0f)); // cam.setLocation(new Vector3f(0, 300, -500)); //cam.setFrustumFar(1000); flyCam.setMoveSpeed(10); Material mat = assetManager.loadMaterial("Textures/Terrain/Rocky/Rocky.j3m"); Spatial scene = assetManager.loadModel("Models/Terrain/Terrain.mesh.xml"); TangentBinormalGenerator.generate(((Geometry)((Node)scene).getChild(0)).getMesh()); scene.setMaterial(mat); scene.setShadowMode(ShadowMode.CastAndReceive); scene.setLocalScale(400); scene.setLocalTranslation(0, -10, -120); rootNode.attachChild(scene); // load sky rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/FullskiesBlueClear03.dds", SkyFactory.EnvMapType.CubeMap)); DirectionalLight sun = new DirectionalLight(); Vector3f lightDir = new Vector3f(-0.12f, -0.3729129f, 0.74847335f); sun.setDirection(lightDir); sun.setColor(ColorRGBA.White.clone().multLocal(2)); scene.addLight(sun); FilterPostProcessor fpp = new FilterPostProcessor(assetManager); int numSamples = getContext().getSettings().getSamples(); if (numSamples > 0) { fpp.setNumSamples(numSamples); } Vector3f lightPos = lightDir.multLocal(-3000); LightScatteringFilter filter = new LightScatteringFilter(lightPos); LightScatteringUI ui = new LightScatteringUI(inputManager, filter); fpp.addFilter(filter); viewPort.addProcessor(fpp); }
Example 15
Source File: TestCinematic.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
private void createScene() { model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml"); model.center(); model.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(model); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Cyan); teapot = assetManager.loadModel("Models/Teapot/Teapot.obj"); teapot.setLocalTranslation(10, 0, 10); teapot.setMaterial(mat); teapot.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(teapot); Material matSoil = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); matSoil.setBoolean("UseMaterialColors", true); matSoil.setColor("Ambient", ColorRGBA.Gray); matSoil.setColor("Diffuse", ColorRGBA.Green); matSoil.setColor("Specular", ColorRGBA.Black); Geometry soil = new Geometry("soil", new Box(new Vector3f(0, -6.0f, 0), 50, 1, 50)); soil.setMaterial(matSoil); soil.setShadowMode(ShadowMode.Receive); rootNode.attachChild(soil); DirectionalLight light = new DirectionalLight(); light.setDirection(new Vector3f(0, -1, -1).normalizeLocal()); light.setColor(ColorRGBA.White.mult(1.5f)); rootNode.addLight(light); fpp = new FilterPostProcessor(assetManager); fade = new FadeFilter(); fpp.addFilter(fade); if (renderer.getCaps().contains(Caps.GLSL100)){ PssmShadowRenderer pssm = new PssmShadowRenderer(assetManager, 512, 1); pssm.setDirection(new Vector3f(0, -1, -1).normalizeLocal()); pssm.setShadowIntensity(0.4f); viewPort.addProcessor(pssm); viewPort.addProcessor(fpp); } }
Example 16
Source File: TestLightScattering.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void simpleInitApp() { // put the camera in a bad position cam.setLocation(new Vector3f(55.35316f, -0.27061665f, 27.092093f)); cam.setRotation(new Quaternion(0.010414706f, 0.9874893f, 0.13880467f, -0.07409228f)); // cam.setDirection(new Vector3f(0,-0.5f,1.0f)); // cam.setLocation(new Vector3f(0, 300, -500)); //cam.setFrustumFar(1000); flyCam.setMoveSpeed(10); Material mat = assetManager.loadMaterial("Textures/Terrain/Rocky/Rocky.j3m"); Spatial scene = assetManager.loadModel("Models/Terrain/Terrain.mesh.xml"); TangentBinormalGenerator.generate(((Geometry)((Node)scene).getChild(0)).getMesh()); scene.setMaterial(mat); scene.setShadowMode(ShadowMode.CastAndReceive); scene.setLocalScale(400); scene.setLocalTranslation(0, -10, -120); rootNode.attachChild(scene); // load sky rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/FullskiesBlueClear03.dds", false)); DirectionalLight sun = new DirectionalLight(); Vector3f lightDir = new Vector3f(-0.12f, -0.3729129f, 0.74847335f); sun.setDirection(lightDir); sun.setColor(ColorRGBA.White.clone().multLocal(2)); scene.addLight(sun); PssmShadowRenderer pssmRenderer = new PssmShadowRenderer(assetManager,1024,4); pssmRenderer.setDirection(lightDir); pssmRenderer.setShadowIntensity(0.55f); // viewPort.addProcessor(pssmRenderer); FilterPostProcessor fpp = new FilterPostProcessor(assetManager); // SSAOFilter ssaoFilter= new SSAOFilter(viewPort, new SSAOConfig(0.36f,1.8f,0.84f,0.16f,false,true)); // fpp.addFilter(ssaoFilter); // Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); // mat2.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); // // Sphere lite=new Sphere(8, 8, 10.0f); // Geometry lightSphere=new Geometry("lightsphere", lite); // lightSphere.setMaterial(mat2); Vector3f lightPos = lightDir.multLocal(-3000); // lightSphere.setLocalTranslation(lightPos); // rootNode.attachChild(lightSphere); LightScatteringFilter filter = new LightScatteringFilter(lightPos); LightScatteringUI ui = new LightScatteringUI(inputManager, filter); fpp.addFilter(filter); //fpp.setNumSamples(4); //fpp.addFilter(new RadialBlurFilter(0.3f,15.0f)); // SSAOUI ui=new SSAOUI(inputManager, ssaoFilter.getConfig()); viewPort.addProcessor(fpp); }
Example 17
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 18
Source File: TestTransparentSSAO.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); 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 19
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 20
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); }