Java Code Examples for com.jme3.scene.shape.Quad#scaleTextureCoordinates()

The following examples show how to use com.jme3.scene.shape.Quad#scaleTextureCoordinates() . 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: TestJaime.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void setupFloor() {
    Quad q = new Quad(20, 20);
   q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(10));
   Geometry geom = new Geometry("floor", q);
   Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
   mat.setColor("Diffuse", ColorRGBA.White);
   mat.setColor("Specular", ColorRGBA.White);
   mat.setColor("Ambient", ColorRGBA.Black);
   mat.setBoolean("UseMaterialColors", true);
   mat.setFloat("Shininess", 0);
   geom.setMaterial(mat);

   geom.rotate(-FastMath.HALF_PI, 0, 0);
   geom.center();
   geom.setShadowMode(RenderQueue.ShadowMode.Receive);
   rootNode.attachChild(geom);
}
 
Example 2
Source File: TestParallax.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void setupFloor() {
    mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m");
            
    Node floorGeom = new Node("floorGeom");
    Quad q = new Quad(100, 100);
    q.scaleTextureCoordinates(new Vector2f(10, 10));
    Geometry g = new Geometry("geom", q);
    g.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
    floorGeom.attachChild(g);
    
    
    TangentBinormalGenerator.generate(floorGeom);
    floorGeom.setLocalTranslation(-50, 22, 60);
    //floorGeom.setLocalScale(100);

    floorGeom.setMaterial(mat);        
    rootNode.attachChild(floorGeom);
}
 
Example 3
Source File: TestParallaxPBR.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void setupFloor() {
    mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWallPBR.j3m");
    //mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWallPBR2.j3m");
            
    Node floorGeom = new Node("floorGeom");
    Quad q = new Quad(100, 100);
    q.scaleTextureCoordinates(new Vector2f(10, 10));
    Geometry g = new Geometry("geom", q);
    g.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
    floorGeom.attachChild(g);
    
    
    TangentBinormalGenerator.generate(floorGeom);
    floorGeom.setLocalTranslation(-50, 22, 60);
    //floorGeom.setLocalScale(100);

    floorGeom.setMaterial(mat);        
    rootNode.attachChild(floorGeom);
}
 
Example 4
Source File: TestAnisotropicFilter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void simpleInitApp() {
    maxAniso = renderer.getLimits().get(Limits.TextureAnisotropy);

    flyCam.setDragToRotate(true);
    flyCam.setMoveSpeed(100);
    cam.setLocation(new Vector3f(197.02617f, 4.6769195f, -194.89545f));
    cam.setRotation(new Quaternion(0.07921988f, 0.8992258f, -0.18292196f, 0.38943136f));
    Quad q = new Quad(1000, 1000);
    q.scaleTextureCoordinates(new Vector2f(1000, 1000));
    Geometry geom = new Geometry("quad", q);
    geom.rotate(-FastMath.HALF_PI, 0, 0);
    geom.setMaterial(createCheckerBoardMaterial(assetManager));
    rootNode.attachChild(geom);

    inputManager.addMapping("higher", new KeyTrigger(KeyInput.KEY_1));
    inputManager.addMapping("lower", new KeyTrigger(KeyInput.KEY_2));
    inputManager.addListener(this, "higher");
    inputManager.addListener(this, "lower");
}
 
Example 5
Source File: DDSPreview.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public DDSPreview(ProjectAssetManager assetManager) {
    this.assetManager = assetManager;

    Quad quadMesh = new Quad(4.5f, 4.5f);
    Quad quadMesh3D = new Quad(4.5f, 4.5f);
    quadMesh3D.scaleTextureCoordinates(new Vector2f(4, 4));
    quad = new Geometry("previewQuad", quadMesh);
    quad.setLocalTranslation(new Vector3f(-2.25f, -2.25f, 0));
    quad3D = new Geometry("previewQuad", quadMesh3D);
    quad3D.setLocalTranslation(new Vector3f(-2.25f, -2.25f, 0));
    material3D = new Material(assetManager, "com/jme3/gde/core/properties/preview/tex3DThumb.j3md");
    material3D.setFloat("InvDepth", 1f / 16f);
    material3D.setInt("Rows", 4);
    material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    SceneApplication.getApplication().addSceneListener(this);
}
 
Example 6
Source File: TestSkeletonControlRefresh.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupFloor() {
    Quad q = new Quad(20, 20);
   q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(10));
   Geometry geom = new Geometry("floor", q);
   Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
   mat.setColor("Color", ColorRGBA.White);       
   geom.setMaterial(mat);

   geom.rotate(-FastMath.HALF_PI, 0, 0);
   geom.center();
   geom.move(0, -0.3f, 0);
   geom.setShadowMode(RenderQueue.ShadowMode.Receive);
   rootNode.attachChild(geom);
}
 
Example 7
Source File: TestTexture3DLoading.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    viewPort.setBackgroundColor(ColorRGBA.DarkGray);
    flyCam.setEnabled(false);


    Quad q = new Quad(10, 10);

    Geometry geom = new Geometry("Quad", q);
    Material material = new Material(assetManager, "jme3test/texture/tex3DThumb.j3md");
    TextureKey key = new TextureKey("Textures/3D/flame.dds");
    key.setGenerateMips(true);
    key.setTextureTypeHint(Texture.Type.ThreeDimensional);

    Texture t = assetManager.loadTexture(key);

    int rows = 4;//4 * 4

    q.scaleTextureCoordinates(new Vector2f(rows, rows));

    //The image only have 8 pictures and we have 16 thumbs, the data will be interpolated by the GPU
    material.setFloat("InvDepth", 1f / 16f);
    material.setInt("Rows", rows);
    material.setTexture("Texture", t);
    geom.setMaterial(material);

    rootNode.attachChild(geom);

    cam.setLocation(new Vector3f(4.7444625f, 5.160054f, 13.1939f));
}
 
Example 8
Source File: Sea.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Sea(AssetManager assetManager, Node sceneNode, ViewPort viewPort) {
    super("water");

    // we create a water processor
    SimpleWaterProcessor waterProcessor = new SimpleWaterProcessor(assetManager);
    waterProcessor.setReflectionScene(sceneNode);

    // we set the water plane
    Vector3f waterLocation = new Vector3f(0, 0, 0);
    waterProcessor.setPlane(new Plane(Vector3f.UNIT_Y, waterLocation.dot(Vector3f.UNIT_Y)));
    viewPort.addProcessor(waterProcessor);

    // we set wave properties
    waterProcessor.setWaterDepth(4);         // transparency of water
    waterProcessor.setDistortionScale(0.15f); // strength of waves
    waterProcessor.setWaveSpeed(0.05f);       // speed of waves

    // we define the wave size by setting the size of the texture coordinates
    Quad quad = new Quad(2000, 2000);
    quad.scaleTextureCoordinates(new Vector2f(6f, 6f));

    // we create the water geometry from the quad
    setMesh(quad);
    setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
    setLocalTranslation(-1000, 0, 1000);
    setShadowMode(RenderQueue.ShadowMode.Receive);
    setMaterial(waterProcessor.getMaterial());
}
 
Example 9
Source File: TestTexture3DLoading.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    viewPort.setBackgroundColor(ColorRGBA.DarkGray);
    flyCam.setEnabled(false);


    Quad q = new Quad(10, 10);

    Geometry geom = new Geometry("Quad", q);
    Material material = new Material(assetManager, "jme3test/texture/tex3DThumb.j3md");
    TextureKey key = new TextureKey("Textures/3D/flame.dds");
    key.setGenerateMips(true);
    key.setAsTexture3D(true);

    Texture t = assetManager.loadTexture(key);

    int rows = 4;//4 * 4

    q.scaleTextureCoordinates(new Vector2f(rows, rows));

    //The image only have 8 pictures and we have 16 thumbs, the data will be interpolated by the GPU
    material.setFloat("InvDepth", 1f / 16f);
    material.setInt("Rows", rows);
    material.setTexture("Texture", t);
    geom.setMaterial(material);

    rootNode.attachChild(geom);

    cam.setLocation(new Vector3f(4.7444625f, 5.160054f, 13.1939f));
}
 
Example 10
Source File: TestTransparentCartoonEdge.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@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 11
Source File: TestTransparentSSAO.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@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 12
Source File: TestTransparentShadow.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@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 13
Source File: TestSceneWater.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
    public void simpleInitApp() {
        File file = new File("wildhouse.zip");
        if (!file.exists()) {
            useHttp = true;
        }
        
        this.flyCam.setMoveSpeed(10);
        Node mainScene=new Node();
        cam.setLocation(new Vector3f(-27.0f, 1.0f, 75.0f));
        cam.setRotation(new Quaternion(0.03f, 0.9f, 0f, 0.4f));

        // load sky
        mainScene.attachChild(SkyFactory.createSky(assetManager, 
                "Textures/Sky/Bright/BrightSky.dds", 
                SkyFactory.EnvMapType.CubeMap));

                
        // create the geometry and attach it
        // 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/wildhouse.zip", HttpZipLocator.class);
        } else {
            assetManager.registerLocator("wildhouse.zip", ZipLocator.class);
        }
        Spatial scene = assetManager.loadModel("main.scene");

        DirectionalLight sun = new DirectionalLight();
        Vector3f lightDir=new Vector3f(-0.37352666f, -0.50444174f, -0.7784704f);
        sun.setDirection(lightDir);
        sun.setColor(ColorRGBA.White.clone().multLocal(2));
        scene.addLight(sun);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
           //add lightPos Geometry
        Sphere lite=new Sphere(8, 8, 3.0f);
        Geometry lightSphere=new Geometry("lightsphere", lite);
        lightSphere.setMaterial(mat);
        Vector3f lightPos=lightDir.multLocal(-400);
        lightSphere.setLocalTranslation(lightPos);
        rootNode.attachChild(lightSphere);


        SimpleWaterProcessor waterProcessor = new SimpleWaterProcessor(assetManager);
        waterProcessor.setReflectionScene(mainScene);
        waterProcessor.setDebug(false);
        waterProcessor.setLightPosition(lightPos);
        waterProcessor.setRefractionClippingOffset(1.0f);


        //setting the water plane
        Vector3f waterLocation=new Vector3f(0,-20,0);
        waterProcessor.setPlane(new Plane(Vector3f.UNIT_Y, waterLocation.dot(Vector3f.UNIT_Y)));
        WaterUI waterUi=new WaterUI(inputManager, waterProcessor);
        waterProcessor.setWaterColor(ColorRGBA.Brown);
        waterProcessor.setDebug(true);
        //lower render size for higher performance
//        waterProcessor.setRenderSize(128,128);
        //raise depth to see through water
//        waterProcessor.setWaterDepth(20);
        //lower the distortion scale if the waves appear too strong
//        waterProcessor.setDistortionScale(0.1f);
        //lower the speed of the waves if they are too fast
//        waterProcessor.setWaveSpeed(0.01f);

        Quad quad = new Quad(400,400);

        //the texture coordinates define the general size of the waves
        quad.scaleTextureCoordinates(new Vector2f(6f,6f));

        Geometry water=new Geometry("water", quad);
        water.setShadowMode(ShadowMode.Receive);
        water.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
        water.setMaterial(waterProcessor.getMaterial());
        water.setLocalTranslation(-200, -20, 250);

        rootNode.attachChild(water);

        viewPort.addProcessor(waterProcessor);

        mainScene.attachChild(scene);
        rootNode.attachChild(mainScene);
    }
 
Example 14
Source File: TestTransparentCartoonEdge.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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 15
Source File: TestTransparentSSAO.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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 16
Source File: TestSceneWater.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void simpleInitApp() {
        this.flyCam.setMoveSpeed(10);
        Node mainScene=new Node();
        cam.setLocation(new Vector3f(-27.0f, 1.0f, 75.0f));
        cam.setRotation(new Quaternion(0.03f, 0.9f, 0f, 0.4f));

        // load sky
        mainScene.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));

        
        File file = new File("wildhouse.zip");
        if (file.exists()) {
            useHttp = false;
        }
        // create the geometry and attach it
        // load the level from zip or http zip
        if (useHttp) {
            assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/wildhouse.zip", HttpZipLocator.class.getName());
        } else {
            assetManager.registerLocator("wildhouse.zip", ZipLocator.class.getName());
        }
        Spatial scene = assetManager.loadModel("main.scene");

        DirectionalLight sun = new DirectionalLight();
        Vector3f lightDir=new Vector3f(-0.37352666f, -0.50444174f, -0.7784704f);
        sun.setDirection(lightDir);
        sun.setColor(ColorRGBA.White.clone().multLocal(2));
        scene.addLight(sun);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
           //add lightPos Geometry
        Sphere lite=new Sphere(8, 8, 3.0f);
        Geometry lightSphere=new Geometry("lightsphere", lite);
        lightSphere.setMaterial(mat);
        Vector3f lightPos=lightDir.multLocal(-400);
        lightSphere.setLocalTranslation(lightPos);
        rootNode.attachChild(lightSphere);


        SimpleWaterProcessor waterProcessor = new SimpleWaterProcessor(assetManager);
        waterProcessor.setReflectionScene(mainScene);
        waterProcessor.setDebug(false);
        waterProcessor.setLightPosition(lightPos);
        waterProcessor.setRefractionClippingOffset(1.0f);


        //setting the water plane
        Vector3f waterLocation=new Vector3f(0,-20,0);
        waterProcessor.setPlane(new Plane(Vector3f.UNIT_Y, waterLocation.dot(Vector3f.UNIT_Y)));
        WaterUI waterUi=new WaterUI(inputManager, waterProcessor);
        waterProcessor.setWaterColor(ColorRGBA.Brown);
        waterProcessor.setDebug(true);
        //lower render size for higher performance
//        waterProcessor.setRenderSize(128,128);
        //raise depth to see through water
//        waterProcessor.setWaterDepth(20);
        //lower the distortion scale if the waves appear too strong
//        waterProcessor.setDistortionScale(0.1f);
        //lower the speed of the waves if they are too fast
//        waterProcessor.setWaveSpeed(0.01f);

        Quad quad = new Quad(400,400);

        //the texture coordinates define the general size of the waves
        quad.scaleTextureCoordinates(new Vector2f(6f,6f));

        Geometry water=new Geometry("water", quad);
        water.setShadowMode(ShadowMode.Receive);
        water.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
        water.setMaterial(waterProcessor.getMaterial());
        water.setLocalTranslation(-200, -20, 250);

        rootNode.attachChild(water);

        viewPort.addProcessor(waterProcessor);

        mainScene.attachChild(scene);
        rootNode.attachChild(mainScene);
    }