Java Code Examples for com.jme3.scene.Spatial#setCullHint()

The following examples show how to use com.jme3.scene.Spatial#setCullHint() . 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: TestBloomAlphaThreshold.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void simpleInitApp()
{
	// put the camera in a bad position
	cam.setLocation(new Vector3f(-2.336393f, 11.91392f, -10));
	cam.setRotation(new Quaternion(0.23602544f, 0.11321983f, -0.027698677f, 0.96473104f));
	// cam.setFrustumFar(1000);

	Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");

	mat.setFloat("Shininess", 15f);
	mat.setBoolean("UseMaterialColors", true);
	mat.setColor("Ambient", ColorRGBA.Yellow.mult(0.2f));
	mat.setColor("Diffuse", ColorRGBA.Yellow.mult(0.2f));
	mat.setColor("Specular", ColorRGBA.Yellow.mult(0.8f));
	mat.setColor("GlowColor", ColorRGBA.Green);

	Material matSoil = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
	matSoil.setFloat("Shininess", 15f);
	matSoil.setBoolean("UseMaterialColors", true);
	matSoil.setColor("Ambient", ColorRGBA.Gray);
	matSoil.setColor("Diffuse", ColorRGBA.Black);
	matSoil.setColor("Specular", ColorRGBA.Gray);

	teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
	teapot.setLocalTranslation(0, 0, 10);

	teapot.setMaterial(mat);
	teapot.setShadowMode(ShadowMode.CastAndReceive);
	teapot.setLocalScale(10.0f);
	rootNode.attachChild(teapot);

               Vector3f boxMin1 = new Vector3f(-800f, -23f, -150f);
               Vector3f boxMax1 = new Vector3f(800f, 3f, 1250f);
               Box boxMesh1 = new Box(boxMin1, boxMax1);
	Geometry soil = new Geometry("soil", boxMesh1);
	soil.setMaterial(matSoil);
	soil.setShadowMode(ShadowMode.CastAndReceive);
	rootNode.attachChild(soil);

	Material matBox = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
	matBox.setTexture("ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png"));
	matBox.setFloat("AlphaDiscardThreshold", 0.5f);
   
               Vector3f boxMin2 = new Vector3f(-5.5f, 8f, -4f);
               Vector3f boxMax2 = new Vector3f(-1.5f, 12f, 0f);
               Box boxMesh2 = new Box(boxMin2, boxMax2);
	Geometry box = new Geometry("box", boxMesh2);
	box.setMaterial(matBox);
               box.setQueueBucket(RenderQueue.Bucket.Translucent);
	// box.setShadowMode(ShadowMode.CastAndReceive);
	rootNode.attachChild(box);

	DirectionalLight light = new DirectionalLight();
	light.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
	light.setColor(ColorRGBA.White.mult(1.5f));
	rootNode.addLight(light);

	// load sky
	Spatial sky = SkyFactory.createSky(assetManager, 
                       "Textures/Sky/Bright/FullskiesBlueClear03.dds",
                       EnvMapType.CubeMap);
	sky.setCullHint(Spatial.CullHint.Never);
	rootNode.attachChild(sky);

	fpp = new FilterPostProcessor(assetManager);
	int numSamples = getContext().getSettings().getSamples();
	if (numSamples > 0)
	{
		fpp.setNumSamples(numSamples);
	}

	BloomFilter bloom = new BloomFilter(GlowMode.Objects);
	bloom.setDownSamplingFactor(2);
	bloom.setBlurScale(1.37f);
	bloom.setExposurePower(3.30f);
	bloom.setExposureCutOff(0.2f);
	bloom.setBloomIntensity(2.45f);
	BloomUI ui = new BloomUI(inputManager, bloom);

	viewPort.addProcessor(fpp);
	fpp.addFilter(bloom);
	initInputs();

}
 
Example 2
Source File: TestPosterization.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
    // put the camera in a bad position
    cam.setLocation(new Vector3f(-2.336393f, 11.91392f, -7.139601f));
    cam.setRotation(new Quaternion(0.23602544f, 0.11321983f, -0.027698677f, 0.96473104f));

    Material mat = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
    mat.setFloat("Shininess", 15f);
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Ambient", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Diffuse", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Specular", ColorRGBA.Yellow.mult(0.8f));

    Material matSoil = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
    matSoil.setFloat("Shininess", 15f);
    matSoil.setBoolean("UseMaterialColors", true);
    matSoil.setColor("Ambient", ColorRGBA.Gray);
    matSoil.setColor("Diffuse", ColorRGBA.Black);
    matSoil.setColor("Specular", ColorRGBA.Gray);

    teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    teapot.setLocalTranslation(0,0,10);

    teapot.setMaterial(mat);
    teapot.setShadowMode(ShadowMode.CastAndReceive);
    teapot.setLocalScale(10.0f);
    rootNode.attachChild(teapot);

    Geometry soil = new Geometry("soil", new Box(800, 10, 700));
    soil.setLocalTranslation(0, -13, 550);
    soil.setMaterial(matSoil);
    soil.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(soil);

    DirectionalLight light=new DirectionalLight();
    light.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    light.setColor(ColorRGBA.White.mult(1.5f));
    rootNode.addLight(light);

    // load sky
    Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Bright/FullskiesBlueClear03.dds", SkyFactory.EnvMapType.CubeMap);
    sky.setCullHint(Spatial.CullHint.Never);
    rootNode.attachChild(sky);

    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    int numSamples = getContext().getSettings().getSamples();
    if (numSamples > 0) {
        fpp.setNumSamples(numSamples);
    }
    pf = new PosterizationFilter();
    fpp.addFilter(pf);

    viewPort.addProcessor(fpp);
    initInputs();

}
 
Example 3
Source File: TestBloom.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
    // put the camera in a bad position
    cam.setLocation(new Vector3f(-2.336393f, 11.91392f, -7.139601f));
    cam.setRotation(new Quaternion(0.23602544f, 0.11321983f, -0.027698677f, 0.96473104f));
    //cam.setFrustumFar(1000);


    Material mat = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
    mat.setFloat("Shininess", 15f);
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Ambient", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Diffuse", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Specular", ColorRGBA.Yellow.mult(0.8f));




    Material matSoil = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
    matSoil.setFloat("Shininess", 15f);
    matSoil.setBoolean("UseMaterialColors", true);
    matSoil.setColor("Ambient", ColorRGBA.Gray);
    matSoil.setColor("Diffuse", ColorRGBA.Black);
    matSoil.setColor("Specular", ColorRGBA.Gray);
   


    teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    teapot.setLocalTranslation(0,0,10);

    teapot.setMaterial(mat);
    teapot.setShadowMode(ShadowMode.CastAndReceive);
    teapot.setLocalScale(10.0f);
    rootNode.attachChild(teapot);

  

    Geometry soil = new Geometry("soil", new Box(800, 10, 700));
    soil.setLocalTranslation(0, -13, 550);
    soil.setMaterial(matSoil);
    soil.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(soil);

    DirectionalLight light=new DirectionalLight();
    light.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    light.setColor(ColorRGBA.White.mult(1.5f));
    rootNode.addLight(light);

    // load sky
    Spatial sky = SkyFactory.createSky(assetManager, 
            "Textures/Sky/Bright/FullskiesBlueClear03.dds", 
            EnvMapType.CubeMap);
    sky.setCullHint(Spatial.CullHint.Never);
    rootNode.attachChild(sky);

    fpp=new FilterPostProcessor(assetManager);
   // fpp.setNumSamples(4);
    int numSamples = getContext().getSettings().getSamples();
    if( numSamples > 0 ) {
        fpp.setNumSamples(numSamples); 
    }
    
    BloomFilter bloom=new BloomFilter();
    bloom.setDownSamplingFactor(2);
    bloom.setBlurScale(1.37f);
    bloom.setExposurePower(3.30f);
    bloom.setExposureCutOff(0.2f);
    bloom.setBloomIntensity(2.45f);
    BloomUI ui=new BloomUI(inputManager, bloom);
   

    viewPort.addProcessor(fpp);
    fpp.addFilter(bloom);
    initInputs();

}
 
Example 4
Source File: TestCrossHatch.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
    // put the camera in a bad position
    cam.setLocation(new Vector3f(-2.336393f, 11.91392f, -7.139601f));
    cam.setRotation(new Quaternion(0.23602544f, 0.11321983f, -0.027698677f, 0.96473104f));
    //cam.setFrustumFar(1000);


    Material mat = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
    mat.setFloat("Shininess", 15f);
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Ambient", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Diffuse", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Specular", ColorRGBA.Yellow.mult(0.8f));




    Material matSoil = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
    matSoil.setFloat("Shininess", 15f);
    matSoil.setBoolean("UseMaterialColors", true);
    matSoil.setColor("Ambient", ColorRGBA.Gray);
    matSoil.setColor("Diffuse", ColorRGBA.Black);
    matSoil.setColor("Specular", ColorRGBA.Gray);
   


    teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    teapot.setLocalTranslation(0,0,10);

    teapot.setMaterial(mat);
    teapot.setShadowMode(ShadowMode.CastAndReceive);
    teapot.setLocalScale(10.0f);
    rootNode.attachChild(teapot);

  

    Geometry soil = new Geometry("soil", new Box(800, 10, 700));
    soil.setLocalTranslation(0, -13, 550);
    soil.setMaterial(matSoil);
    soil.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(soil);

    DirectionalLight light=new DirectionalLight();
    light.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    light.setColor(ColorRGBA.White.mult(1.5f));
    rootNode.addLight(light);

    // load sky
    Spatial sky = SkyFactory.createSky(assetManager, 
            "Textures/Sky/Bright/FullskiesBlueClear03.dds",
            EnvMapType.CubeMap);
    sky.setCullHint(Spatial.CullHint.Never);
    rootNode.attachChild(sky);

    fpp=new FilterPostProcessor(assetManager);
    
    int numSamples = getContext().getSettings().getSamples();
    if( numSamples > 0 ) {
        fpp.setNumSamples(numSamples); 
    }
    
    CrossHatchFilter chf=new CrossHatchFilter();
    
   

    viewPort.addProcessor(fpp);
    fpp.addFilter(chf);
    initInputs();

}
 
Example 5
Source File: TestPosterization.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
    // put the camera in a bad position
    cam.setLocation(new Vector3f(-2.336393f, 11.91392f, -7.139601f));
    cam.setRotation(new Quaternion(0.23602544f, 0.11321983f, -0.027698677f, 0.96473104f));
    //cam.setFrustumFar(1000);


    Material mat = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
    mat.setFloat("Shininess", 15f);
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Ambient", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Diffuse", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Specular", ColorRGBA.Yellow.mult(0.8f));




    Material matSoil = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
    matSoil.setFloat("Shininess", 15f);
    matSoil.setBoolean("UseMaterialColors", true);
    matSoil.setColor("Ambient", ColorRGBA.Gray);
    matSoil.setColor("Diffuse", ColorRGBA.Black);
    matSoil.setColor("Specular", ColorRGBA.Gray);
   


    teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    teapot.setLocalTranslation(0,0,10);

    teapot.setMaterial(mat);
    teapot.setShadowMode(ShadowMode.CastAndReceive);
    teapot.setLocalScale(10.0f);
    rootNode.attachChild(teapot);

  

    Geometry soil=new Geometry("soil", new Box(new Vector3f(0, -13, 550), 800, 10, 700));
    soil.setMaterial(matSoil);
    soil.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(soil);

    DirectionalLight light=new DirectionalLight();
    light.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    light.setColor(ColorRGBA.White.mult(1.5f));
    rootNode.addLight(light);

    // load sky
    Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Bright/FullskiesBlueClear03.dds", false);
    sky.setCullHint(Spatial.CullHint.Never);
    rootNode.attachChild(sky);

    fpp=new FilterPostProcessor(assetManager);
    PosterizationFilter pf=new PosterizationFilter();
    
   

    viewPort.addProcessor(fpp);
    fpp.addFilter(pf);
    initInputs();

}
 
Example 6
Source File: TestBloom.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
    // put the camera in a bad position
    cam.setLocation(new Vector3f(-2.336393f, 11.91392f, -7.139601f));
    cam.setRotation(new Quaternion(0.23602544f, 0.11321983f, -0.027698677f, 0.96473104f));
    //cam.setFrustumFar(1000);


    Material mat = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
    mat.setFloat("Shininess", 15f);
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Ambient", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Diffuse", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Specular", ColorRGBA.Yellow.mult(0.8f));




    Material matSoil = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
    matSoil.setFloat("Shininess", 15f);
    matSoil.setBoolean("UseMaterialColors", true);
    matSoil.setColor("Ambient", ColorRGBA.Gray);
    matSoil.setColor("Diffuse", ColorRGBA.Black);
    matSoil.setColor("Specular", ColorRGBA.Gray);
   


    teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    teapot.setLocalTranslation(0,0,10);

    teapot.setMaterial(mat);
    teapot.setShadowMode(ShadowMode.CastAndReceive);
    teapot.setLocalScale(10.0f);
    rootNode.attachChild(teapot);

  

    Geometry soil=new Geometry("soil", new Box(new Vector3f(0, -13, 550), 800, 10, 700));
    soil.setMaterial(matSoil);
    soil.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(soil);

    DirectionalLight light=new DirectionalLight();
    light.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    light.setColor(ColorRGBA.White.mult(1.5f));
    rootNode.addLight(light);

    // load sky
    Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Bright/FullskiesBlueClear03.dds", false);
    sky.setCullHint(Spatial.CullHint.Never);
    rootNode.attachChild(sky);

    fpp=new FilterPostProcessor(assetManager);
   // fpp.setNumSamples(4);
    BloomFilter bloom=new BloomFilter();
    bloom.setDownSamplingFactor(2);
    bloom.setBlurScale(1.37f);
    bloom.setExposurePower(3.30f);
    bloom.setExposureCutOff(0.2f);
    bloom.setBloomIntensity(2.45f);
    BloomUI ui=new BloomUI(inputManager, bloom);
   

    viewPort.addProcessor(fpp);
    fpp.addFilter(bloom);
    initInputs();

}
 
Example 7
Source File: TestCrossHatch.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
    // put the camera in a bad position
    cam.setLocation(new Vector3f(-2.336393f, 11.91392f, -7.139601f));
    cam.setRotation(new Quaternion(0.23602544f, 0.11321983f, -0.027698677f, 0.96473104f));
    //cam.setFrustumFar(1000);


    Material mat = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
    mat.setFloat("Shininess", 15f);
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Ambient", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Diffuse", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Specular", ColorRGBA.Yellow.mult(0.8f));




    Material matSoil = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
    matSoil.setFloat("Shininess", 15f);
    matSoil.setBoolean("UseMaterialColors", true);
    matSoil.setColor("Ambient", ColorRGBA.Gray);
    matSoil.setColor("Diffuse", ColorRGBA.Black);
    matSoil.setColor("Specular", ColorRGBA.Gray);
   


    teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    teapot.setLocalTranslation(0,0,10);

    teapot.setMaterial(mat);
    teapot.setShadowMode(ShadowMode.CastAndReceive);
    teapot.setLocalScale(10.0f);
    rootNode.attachChild(teapot);

  

    Geometry soil=new Geometry("soil", new Box(new Vector3f(0, -13, 550), 800, 10, 700));
    soil.setMaterial(matSoil);
    soil.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(soil);

    DirectionalLight light=new DirectionalLight();
    light.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    light.setColor(ColorRGBA.White.mult(1.5f));
    rootNode.addLight(light);

    // load sky
    Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Bright/FullskiesBlueClear03.dds", false);
    sky.setCullHint(Spatial.CullHint.Never);
    rootNode.attachChild(sky);

    fpp=new FilterPostProcessor(assetManager);
    CrossHatchFilter chf=new CrossHatchFilter();
    
   

    viewPort.addProcessor(fpp);
    fpp.addFilter(chf);
    initInputs();

}