use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.
the class TestBlenderLoader method simpleInitApp.
@Override
public void simpleInitApp() {
viewPort.setBackgroundColor(ColorRGBA.DarkGray);
//load model with packed images
Spatial ogre = assetManager.loadModel("Blender/2.4x/Sinbad.blend");
rootNode.attachChild(ogre);
//load model with referenced images
Spatial track = assetManager.loadModel("Blender/2.4x/MountainValley_Track.blend");
rootNode.attachChild(track);
// sunset light
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal());
dl.setColor(new ColorRGBA(0.44f, 0.30f, 0.20f, 1.0f));
rootNode.addLight(dl);
// skylight
dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.6f, -1, -0.6f).normalizeLocal());
dl.setColor(new ColorRGBA(0.10f, 0.22f, 0.44f, 1.0f));
rootNode.addLight(dl);
// white ambient light
dl = new DirectionalLight();
dl.setDirection(new Vector3f(1, -0.5f, -0.1f).normalizeLocal());
dl.setColor(new ColorRGBA(0.80f, 0.70f, 0.80f, 1.0f));
rootNode.addLight(dl);
}
use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.
the class TestHoveringTank method simpleInitApp.
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(bulletAppState);
// bulletAppState.getPhysicsSpace().enableDebug(assetManager);
bulletAppState.getPhysicsSpace().setAccuracy(1f / 30f);
rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));
PssmShadowRenderer pssmr = new PssmShadowRenderer(assetManager, 2048, 3);
pssmr.setDirection(new Vector3f(-0.5f, -0.3f, -0.3f).normalizeLocal());
pssmr.setLambda(0.55f);
pssmr.setShadowIntensity(0.6f);
pssmr.setCompareMode(CompareMode.Hardware);
pssmr.setFilterMode(FilterMode.Bilinear);
viewPort.addProcessor(pssmr);
setupKeys();
createTerrain();
buildPlayer();
DirectionalLight dl = new DirectionalLight();
dl.setColor(new ColorRGBA(1.0f, 0.94f, 0.8f, 1f).multLocal(1.3f));
dl.setDirection(new Vector3f(-0.5f, -0.3f, -0.3f).normalizeLocal());
rootNode.addLight(dl);
Vector3f lightDir2 = new Vector3f(0.70518064f, 0.5902297f, -0.39287305f);
DirectionalLight dl2 = new DirectionalLight();
dl2.setColor(new ColorRGBA(0.7f, 0.85f, 1.0f, 1f));
dl2.setDirection(lightDir2);
rootNode.addLight(dl2);
}
use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.
the class TerrainTest method simpleInitApp.
@Override
public void simpleInitApp() {
setupKeys();
// First, we load up our textures and the heightmap texture for the terrain
// TERRAIN TEXTURE material
matRock = new Material(assetManager, "Common/MatDefs/Terrain/Terrain.j3md");
matRock.setBoolean("useTriPlanarMapping", false);
// ALPHA map (for splat textures)
matRock.setTexture("Alpha", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
// HEIGHTMAP image (for the terrain heightmap)
Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
// GRASS texture
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
matRock.setTexture("Tex1", grass);
matRock.setFloat("Tex1Scale", grassScale);
// DIRT texture
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
dirt.setWrap(WrapMode.Repeat);
matRock.setTexture("Tex2", dirt);
matRock.setFloat("Tex2Scale", dirtScale);
// ROCK texture
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
rock.setWrap(WrapMode.Repeat);
matRock.setTexture("Tex3", rock);
matRock.setFloat("Tex3Scale", rockScale);
// WIREFRAME material
matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
matWire.getAdditionalRenderState().setWireframe(true);
matWire.setColor("Color", ColorRGBA.Green);
// CREATE HEIGHTMAP
AbstractHeightMap heightmap = null;
try {
//heightmap = new HillHeightMap(1025, 1000, 50, 100, (byte) 3);
heightmap = new ImageBasedHeightMap(heightMapImage.getImage(), 1f);
heightmap.load();
} catch (Exception e) {
e.printStackTrace();
}
/*
* Here we create the actual terrain. The tiles will be 65x65, and the total size of the
* terrain will be 513x513. It uses the heightmap we created to generate the height values.
*/
/**
* Optimal terrain patch size is 65 (64x64).
* The total size is up to you. At 1025 it ran fine for me (200+FPS), however at
* size=2049, it got really slow. But that is a jump from 2 million to 8 million triangles...
*/
terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
TerrainLodControl control = new TerrainLodControl(terrain, getCamera());
// patch size, and a multiplier
control.setLodCalculator(new DistanceLodCalculator(65, 2.7f));
terrain.addControl(control);
terrain.setMaterial(matRock);
terrain.setLocalTranslation(0, -100, 0);
terrain.setLocalScale(2f, 0.5f, 2f);
rootNode.attachChild(terrain);
DirectionalLight light = new DirectionalLight();
light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize());
rootNode.addLight(light);
cam.setLocation(new Vector3f(0, 10, -10));
cam.lookAtDirection(new Vector3f(0, -1.5f, -1).normalizeLocal(), Vector3f.UNIT_Y);
}
use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.
the class TerrainTestAndroid method simpleInitApp.
@Override
public void simpleInitApp() {
setupKeys();
// First, we load up our textures and the heightmap texture for the terrain
// TERRAIN TEXTURE material
matRock = new Material(assetManager, "Common/MatDefs/Terrain/Terrain.j3md");
matRock.setBoolean("useTriPlanarMapping", false);
// ALPHA map (for splat textures)
matRock.setTexture("Alpha", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
// HEIGHTMAP image (for the terrain heightmap)
Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains128.png");
// GRASS texture
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
matRock.setTexture("Tex1", grass);
matRock.setFloat("Tex1Scale", grassScale);
// DIRT texture
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
dirt.setWrap(WrapMode.Repeat);
matRock.setTexture("Tex2", dirt);
matRock.setFloat("Tex2Scale", dirtScale);
// ROCK texture
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
rock.setWrap(WrapMode.Repeat);
matRock.setTexture("Tex3", rock);
matRock.setFloat("Tex3Scale", rockScale);
// WIREFRAME material
matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
matWire.getAdditionalRenderState().setWireframe(true);
matWire.setColor("Color", ColorRGBA.Green);
// CREATE HEIGHTMAP
AbstractHeightMap heightmap = null;
try {
heightmap = new ImageBasedHeightMap(heightMapImage.getImage(), 1f);
heightmap.load();
} catch (Exception e) {
e.printStackTrace();
}
/*
* Here we create the actual terrain. The tiles will be 33x33, and the total size of the
* terrain will be 129x129. It uses the heightmap we created to generate the height values.
*/
terrain = new TerrainQuad("terrain", 33, 129, heightmap.getHeightMap());
TerrainLodControl control = new TerrainLodControl(terrain, getCamera());
// patch size, and a multiplier
control.setLodCalculator(new DistanceLodCalculator(33, 2.7f));
terrain.addControl(control);
terrain.setMaterial(matRock);
terrain.setLocalTranslation(0, -100, 0);
terrain.setLocalScale(8f, 0.5f, 8f);
rootNode.attachChild(terrain);
DirectionalLight light = new DirectionalLight();
light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize());
rootNode.addLight(light);
cam.setLocation(new Vector3f(0, 10, -10));
cam.lookAtDirection(new Vector3f(0, -1.5f, -1).normalizeLocal(), Vector3f.UNIT_Y);
}
use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.
the class TerrainTestTile method simpleInitApp.
@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);
}
Aggregations