use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.
the class TestOgreLoading method simpleInitApp.
public void simpleInitApp() {
// PointLight pl = new PointLight();
// pl.setPosition(new Vector3f(10, 10, -10));
// rootNode.addLight(pl);
flyCam.setMoveSpeed(10f);
// sunset light
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal());
dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
rootNode.addLight(dl);
lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
rootNode.attachChild(lightMdl);
lightMd2 = new Geometry("Light", new Sphere(10, 10, 0.1f));
lightMd2.setMaterial(assetManager.loadMaterial("Common/Materials/WhiteColor.j3m"));
rootNode.attachChild(lightMd2);
pl = new PointLight();
pl.setColor(new ColorRGBA(1, 0.9f, 0.9f, 0));
pl.setPosition(new Vector3f(0f, 0f, 4f));
rootNode.addLight(pl);
p2 = new PointLight();
p2.setColor(new ColorRGBA(0.9f, 1, 0.9f, 0));
p2.setPosition(new Vector3f(0f, 0f, 3f));
rootNode.addLight(p2);
// create the geometry and attach it
Spatial elephant = (Spatial) assetManager.loadModel("Models/Elephant/Elephant.mesh.xml");
float scale = 0.05f;
elephant.scale(scale, scale, scale);
rootNode.attachChild(elephant);
}
use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.
the class TestAnimationFactory method simpleInitApp.
@Override
public void simpleInitApp() {
AmbientLight al = new AmbientLight();
rootNode.addLight(al);
DirectionalLight dl = new DirectionalLight();
dl.setDirection(Vector3f.UNIT_XYZ.negate());
rootNode.addLight(dl);
// Create model
Box box = new Box(1, 1, 1);
Geometry geom = new Geometry("box", box);
geom.setMaterial(assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m"));
Node model = new Node("model");
model.attachChild(geom);
Box child = new Box(0.5f, 0.5f, 0.5f);
Geometry childGeom = new Geometry("box", child);
childGeom.setMaterial(assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m"));
Node childModel = new Node("childmodel");
childModel.setLocalTranslation(2, 2, 2);
childModel.attachChild(childGeom);
model.attachChild(childModel);
TangentBinormalGenerator.generate(model);
//creating quite complex animation witht the AnimationHelper
// animation of 6 seconds named "anim" and with 25 frames per second
AnimationFactory animationFactory = new AnimationFactory(6, "anim", 25);
//creating a translation keyFrame at time = 3 with a translation on the x axis of 5 WU
animationFactory.addTimeTranslation(3, new Vector3f(5, 0, 0));
//reseting the translation to the start position at time = 6
animationFactory.addTimeTranslation(6, new Vector3f(0, 0, 0));
//Creating a scale keyFrame at time = 2 with the unit scale.
animationFactory.addTimeScale(2, new Vector3f(1, 1, 1));
//Creating a scale keyFrame at time = 4 scaling to 1.5
animationFactory.addTimeScale(4, new Vector3f(1.5f, 1.5f, 1.5f));
//reseting the scale to the start value at time = 5
animationFactory.addTimeScale(5, new Vector3f(1, 1, 1));
//Creating a rotation keyFrame at time = 0.5 of quarter PI around the Z axis
animationFactory.addTimeRotation(0.5f, new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_Z));
//rotating back to initial rotation value at time = 1
animationFactory.addTimeRotation(1, Quaternion.IDENTITY);
//Creating a rotation keyFrame at time = 2. Note that i used the Euler angle version because the angle is higher than PI
//this should result in a complete revolution of the spatial around the x axis in 1 second (from 1 to 2)
animationFactory.addTimeRotationAngles(2, FastMath.TWO_PI, 0, 0);
AnimControl control = new AnimControl();
control.addAnim(animationFactory.buildAnimation());
model.addControl(control);
rootNode.attachChild(model);
//run animation
control.createChannel().setAnim("anim");
}
use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.
the class TestBlenderAnim method simpleInitApp.
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(10f);
cam.setLocation(new Vector3f(6.4013605f, 7.488437f, 12.843031f));
cam.setRotation(new Quaternion(-0.060740203f, 0.93925786f, -0.2398315f, -0.2378785f));
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal());
dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
rootNode.addLight(dl);
BlenderKey blenderKey = new BlenderKey("Blender/2.4x/BaseMesh_249.blend");
Spatial scene = (Spatial) assetManager.loadModel(blenderKey);
rootNode.attachChild(scene);
Spatial model = this.findNode(rootNode, "BaseMesh_01");
model.center();
control = model.getControl(AnimControl.class);
channel = control.createChannel();
channel.setAnim("run_01");
}
use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.
the class TestBlenderObjectAnim method simpleInitApp.
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(10f);
cam.setLocation(new Vector3f(6.4013605f, 7.488437f, 12.843031f));
cam.setRotation(new Quaternion(-0.060740203f, 0.93925786f, -0.2398315f, -0.2378785f));
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal());
dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
rootNode.addLight(dl);
BlenderKey blenderKey = new BlenderKey("Blender/2.4x/animtest.blend");
Spatial scene = (Spatial) assetManager.loadModel(blenderKey);
rootNode.attachChild(scene);
Spatial model = this.findNode(rootNode, "TestAnim");
model.center();
control = model.getControl(AnimControl.class);
channel = control.createChannel();
channel.setAnim("TestAnim");
}
use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.
the class TestPosterization method simpleInitApp.
@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();
}
Aggregations