use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TestPssmShadow method loadScene.
public void loadScene() {
obj = new Spatial[2];
mat = new Material[2];
mat[0] = assetManager.loadMaterial("Common/Materials/RedColor.j3m");
mat[1] = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
mat[1].setBoolean("UseMaterialColors", true);
mat[1].setColor("Ambient", ColorRGBA.White.mult(0.5f));
mat[1].setColor("Diffuse", ColorRGBA.White.clone());
obj[0] = new Geometry("sphere", new Sphere(30, 30, 2));
obj[0].setShadowMode(ShadowMode.CastAndReceive);
obj[1] = new Geometry("cube", new Box(1.0f, 1.0f, 1.0f));
obj[1].setShadowMode(ShadowMode.CastAndReceive);
TangentBinormalGenerator.generate(obj[1]);
TangentBinormalGenerator.generate(obj[0]);
for (int i = 0; i < 60; i++) {
Spatial t = obj[FastMath.nextRandomInt(0, obj.length - 1)].clone(false);
t.setLocalScale(FastMath.nextRandomFloat() * 10f);
t.setMaterial(mat[FastMath.nextRandomInt(0, mat.length - 1)]);
rootNode.attachChild(t);
t.setLocalTranslation(FastMath.nextRandomFloat() * 200f, FastMath.nextRandomFloat() * 30f + 20, 30f * (i + 2f));
}
Box b = new Box(1000, 2, 1000);
b.scaleTextureCoordinates(new Vector2f(10, 10));
ground = new Geometry("soil", b);
ground.setLocalTranslation(0, 10, 550);
matGroundU = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
matGroundU.setColor("Color", ColorRGBA.Green);
matGroundL = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
matGroundL.setTexture("DiffuseMap", grass);
ground.setMaterial(matGroundL);
ground.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(ground);
l = new DirectionalLight();
l.setDirection(new Vector3f(-1, -1, -1));
rootNode.addLight(l);
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(0.5f));
rootNode.addLight(al);
Spatial sky = SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", false);
sky.setLocalScale(350);
rootNode.attachChild(sky);
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TestShadowBug method makeFloor.
protected Geometry makeFloor() {
Box box = new Box(220, .2f, 220);
box.scaleTextureCoordinates(new Vector2f(10, 10));
Geometry floor = new Geometry("the Floor", box);
floor.setLocalTranslation(200, -9, 200);
Material matGroundL = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
matGroundL.setTexture("DiffuseMap", grass);
floor.setMaterial(matGroundL);
floor.setShadowMode(ShadowMode.CastAndReceive);
return floor;
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TestSpotLight method setupFloor.
public void setupFloor() {
Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
// mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
mat.setFloat("Shininess", 3);
// mat.setBoolean("VertexLighting", true);
Box floor = new Box(50, 1f, 50);
TangentBinormalGenerator.generate(floor);
floor.scaleTextureCoordinates(new Vector2f(5, 5));
Geometry floorGeom = new Geometry("Floor", floor);
floorGeom.setMaterial(mat);
floorGeom.setShadowMode(ShadowMode.Receive);
rootNode.attachChild(floorGeom);
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TestJoystick method pick.
private static CollisionResults pick(Camera cam, Vector2f mouseLoc, Node node) {
CollisionResults results = new CollisionResults();
Ray ray = new Ray();
Vector3f pos = new Vector3f(mouseLoc.x, mouseLoc.y, -1);
Vector3f dir = new Vector3f(mouseLoc.x, mouseLoc.y, 1);
dir.subtractLocal(pos).normalizeLocal();
ray.setOrigin(pos);
ray.setDirection(dir);
node.collideWith(ray, results);
return results;
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TestJoystick method pickGamePad.
private void pickGamePad(Vector2f mouseLoc) {
if (lastButton != null) {
CollisionResults cresults = pick(cam, mouseLoc, gamepad);
for (CollisionResult cr : cresults) {
Node n = cr.getGeometry().getParent();
if (n != null && (n instanceof ButtonView)) {
String b = ((ButtonView) n).getName().substring("Button:".length());
String name = lastButton.getJoystick().getName().replaceAll(" ", "\\\\ ");
String id = lastButton.getLogicalId().replaceAll(" ", "\\\\ ");
System.out.println(name + "." + id + "=" + b);
return;
}
}
}
}
Aggregations