Search in sources :

Example 81 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class OpaqueComparatorTest method testSortByTechnique.

@Test
public void testSortByTechnique() {
    Material lightingMatDefault = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingPreShadow = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingPostShadow = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingMatPreNormalPass = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingMatGBuf = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingMatGlow = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    lightingMatDefault.setName("TechDefault");
    lightingMatDefault.selectTechnique(TechniqueDef.DEFAULT_TECHNIQUE_NAME, renderManager);
    lightingPostShadow.setName("TechPostShad");
    lightingPostShadow.selectTechnique("PostShadow", renderManager);
    lightingPreShadow.setName("TechPreShad");
    lightingPreShadow.selectTechnique("PreShadow", renderManager);
    lightingMatPreNormalPass.setName("TechNorm");
    lightingMatPreNormalPass.selectTechnique("PreNormalPass", renderManager);
    lightingMatGlow.setName("TechGlow");
    lightingMatGlow.selectTechnique("Glow", renderManager);
    testSort(lightingMatGlow, lightingPreShadow, lightingMatPreNormalPass, lightingMatDefault, lightingPostShadow);
}
Also used : Material(com.jme3.material.Material) Test(org.junit.Test)

Example 82 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class MaterialMatParamTest method testTextureMpoOnly.

@Test
public void testTextureMpoOnly() {
    material("Common/MatDefs/Light/Lighting.j3md");
    Texture2D tex = new Texture2D(128, 128, Format.RGBA8);
    inputMpo(mpoTexture2D("DiffuseMap", tex));
    outDefines(def("DIFFUSEMAP", VarType.Texture2D, tex));
    outUniforms(uniform("DiffuseMap", VarType.Int, 0));
    outTextures(tex);
}
Also used : Texture2D(com.jme3.texture.Texture2D) Test(org.junit.Test)

Example 83 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class MaterialMatParamTest method testTextureOverride.

@Test
public void testTextureOverride() {
    material("Common/MatDefs/Light/Lighting.j3md");
    Texture2D tex1 = new Texture2D(128, 128, Format.RGBA8);
    Texture2D tex2 = new Texture2D(128, 128, Format.RGBA8);
    inputMp(mpoTexture2D("DiffuseMap", tex1));
    inputMpo(mpoTexture2D("DiffuseMap", tex2));
    outDefines(def("DIFFUSEMAP", VarType.Texture2D, tex2));
    outUniforms(uniform("DiffuseMap", VarType.Int, 0));
    outTextures(tex2);
}
Also used : Texture2D(com.jme3.texture.Texture2D) Test(org.junit.Test)

Example 84 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class TestBatchNode method simpleInitApp.

@Override
public void simpleInitApp() {
    timer = new NanoTimer();
    batch = new BatchNode("theBatchNode");
    /**
         * A cube with a color "bleeding" through transparent texture. Uses
         * Texture from jme3-test-data library!
         */
    Box boxshape4 = new Box(1f, 1f, 1f);
    cube = new Geometry("cube1", boxshape4);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    cube.setMaterial(mat);
    //        Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");        
    //        mat.setColor("Diffuse", ColorRGBA.Blue);
    //        mat.setBoolean("UseMaterialColors", true);
    /**
         * A cube with a color "bleeding" through transparent texture. Uses
         * Texture from jme3-test-data library!
         */
    Box box = new Box(1f, 1f, 1f);
    cube2 = new Geometry("cube2", box);
    cube2.setMaterial(mat);
    TangentBinormalGenerator.generate(cube);
    TangentBinormalGenerator.generate(cube2);
    n = new Node("aNode");
    // n.attachChild(cube2);
    batch.attachChild(cube);
    //  batch.attachChild(cube2);
    //  batch.setMaterial(mat);
    batch.batch();
    rootNode.attachChild(batch);
    cube.setLocalTranslation(3, 0, 0);
    cube2.setLocalTranslation(0, 20, 0);
    updateBoindPoints(points);
    frustum = new WireFrustum(points);
    frustumMdl = new Geometry("f", frustum);
    frustumMdl.setCullHint(Spatial.CullHint.Never);
    frustumMdl.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"));
    frustumMdl.getMaterial().getAdditionalRenderState().setWireframe(true);
    frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red);
    rootNode.attachChild(frustumMdl);
    dl = new DirectionalLight();
    dl.setColor(ColorRGBA.White.mult(2));
    dl.setDirection(new Vector3f(1, -1, -1));
    rootNode.addLight(dl);
    flyCam.setMoveSpeed(10);
}
Also used : Geometry(com.jme3.scene.Geometry) NanoTimer(com.jme3.system.NanoTimer) WireFrustum(com.jme3.scene.debug.WireFrustum) Node(com.jme3.scene.Node) BatchNode(com.jme3.scene.BatchNode) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) BoundingBox(com.jme3.bounding.BoundingBox) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) BatchNode(com.jme3.scene.BatchNode)

Example 85 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class PhysicsTestHelper method createPhysicsTestWorld.

/**
     * 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);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) MeshCollisionShape(com.jme3.bullet.collision.shapes.MeshCollisionShape) Material(com.jme3.material.Material) Box(com.jme3.scene.shape.Box) RigidBodyControl(com.jme3.bullet.control.RigidBodyControl) AmbientLight(com.jme3.light.AmbientLight)

Aggregations

Vector3f (com.jme3.math.Vector3f)64 Material (com.jme3.material.Material)61 DirectionalLight (com.jme3.light.DirectionalLight)55 Geometry (com.jme3.scene.Geometry)52 PointLight (com.jme3.light.PointLight)27 Spatial (com.jme3.scene.Spatial)27 Box (com.jme3.scene.shape.Box)26 Sphere (com.jme3.scene.shape.Sphere)26 ColorRGBA (com.jme3.math.ColorRGBA)24 Quaternion (com.jme3.math.Quaternion)21 Node (com.jme3.scene.Node)21 AmbientLight (com.jme3.light.AmbientLight)20 Texture (com.jme3.texture.Texture)18 SpotLight (com.jme3.light.SpotLight)16 FilterPostProcessor (com.jme3.post.FilterPostProcessor)15 KeyTrigger (com.jme3.input.controls.KeyTrigger)11 Test (org.junit.Test)11 TempVars (com.jme3.util.TempVars)10 Light (com.jme3.light.Light)9 Camera (com.jme3.renderer.Camera)9