use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.
the class TestOgreAnim 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);
Spatial model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
model.center();
control = model.getControl(AnimControl.class);
control.addListener(this);
channel = control.createChannel();
for (String anim : control.getAnimationNames()) System.out.println(anim);
channel.setAnim("stand");
geom = (Geometry) ((Node) model).getChild(0);
SkeletonControl skeletonControl = model.getControl(SkeletonControl.class);
Box b = new Box(.25f, 3f, .25f);
Geometry item = new Geometry("Item", b);
item.move(0, 1.5f, 0);
item.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
Node n = skeletonControl.getAttachmentsNode("hand.right");
n.attachChild(item);
rootNode.attachChild(model);
inputManager.addListener(this, "Attack");
inputManager.addMapping("Attack", new KeyTrigger(KeyInput.KEY_SPACE));
}
use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.
the class TestSkeletonControlRefresh method simpleInitApp.
@Override
public void simpleInitApp() {
viewPort.setBackgroundColor(ColorRGBA.White);
flyCam.setMoveSpeed(10f);
cam.setLocation(new Vector3f(3.8664846f, 6.2704787f, 9.664585f));
cam.setRotation(new Quaternion(-0.054774776f, 0.94064945f, -0.27974048f, -0.18418397f));
makeHudText();
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);
Material m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
TextureKey k = new TextureKey("Models/Oto/Oto.jpg", false);
m.setTexture("ColorMap", assetManager.loadTexture(k));
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
Spatial model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
//setting a different material
model.setMaterial(m.clone());
model.setLocalScale(0.1f);
model.setLocalTranslation(i - SIZE / 2, 0, j - SIZE / 2);
control = model.getControl(AnimControl.class);
channel = control.createChannel();
channel.setAnim(animNames[(i + j) % 4]);
channel.setLoopMode(LoopMode.DontLoop);
SkeletonControl skeletonControl = model.getControl(SkeletonControl.class);
//This is a workaround the issue. this call will make the SkeletonControl gather the targets again.
//skeletonControl.setSpatial(model);
skeletonControl.setHardwareSkinningPreferred(hwSkinningEnable);
skControls.add(skeletonControl);
rootNode.attachChild(model);
}
}
rootNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
setupFloor();
inputManager.addListener(this, "toggleHWS");
inputManager.addMapping("toggleHWS", new KeyTrigger(KeyInput.KEY_SPACE));
// DirectionalLightShadowRenderer pssm = new DirectionalLightShadowRenderer(assetManager, 1024, 2);
// pssm.setLight(dl);
// viewPort.addProcessor(pssm);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
DirectionalLightShadowFilter sf = new DirectionalLightShadowFilter(assetManager, 1024, 2);
sf.setLight(dl);
fpp.addFilter(sf);
fpp.addFilter(new SSAOFilter());
viewPort.addProcessor(fpp);
}
use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.
the class TestSpatialAnim 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);
//animation parameters
float animTime = 5;
int fps = 25;
float totalXLength = 10;
//calculating frames
int totalFrames = (int) (fps * animTime);
float dT = animTime / totalFrames, t = 0;
float dX = totalXLength / totalFrames, x = 0;
float[] times = new float[totalFrames];
Vector3f[] translations = new Vector3f[totalFrames];
Quaternion[] rotations = new Quaternion[totalFrames];
Vector3f[] scales = new Vector3f[totalFrames];
for (int i = 0; i < totalFrames; ++i) {
times[i] = t;
t += dT;
translations[i] = new Vector3f(x, 0, 0);
x += dX;
rotations[i] = Quaternion.IDENTITY;
scales[i] = Vector3f.UNIT_XYZ;
}
SpatialTrack spatialTrack = new SpatialTrack(times, translations, rotations, scales);
//creating the animation
Animation spatialAnimation = new Animation("anim", animTime);
spatialAnimation.setTracks(new SpatialTrack[] { spatialTrack });
//create spatial animation control
AnimControl control = new AnimControl();
HashMap<String, Animation> animations = new HashMap<String, Animation>();
animations.put("anim", spatialAnimation);
control.setAnimations(animations);
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 TestParallax method setupLighting.
public void setupLighting() {
dl = new DirectionalLight();
dl.setDirection(lightDir);
dl.setColor(new ColorRGBA(.9f, .9f, .9f, 1));
rootNode.addLight(dl);
}
use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.
the class TestParallaxPBR method setupLighting.
public void setupLighting() {
dl = new DirectionalLight();
dl.setDirection(lightDir);
dl.setColor(new ColorRGBA(.9f, .9f, .9f, 1));
rootNode.addLight(dl);
}
Aggregations