use of com.jme3.scene.shape.Box in project jmonkeyengine by jMonkeyEngine.
the class TestPbrEnv method loadScene.
public void loadScene() {
renderManager.setPreferredLightMode(TechniqueDef.LightMode.SinglePass);
renderManager.setSinglePassLightBatchSize(3);
obj = new Spatial[2];
// Setup first view
mat = new Material[2];
mat[0] = assetManager.loadMaterial("jme3test/light/pbr/pbrMat.j3m");
//mat[1] = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
mat[1] = assetManager.loadMaterial("jme3test/light/pbr/pbrMat2.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 < 2; i++) {
Spatial t = obj[0].clone(false);
t.setName("Cube" + i);
t.setLocalScale(10f);
t.setMaterial(mat[1].clone());
rootNode.attachChild(t);
t.setLocalTranslation(i * 200f + 100f, 50, 800f * (i));
}
Box b = new Box(1000, 2, 1000);
b.scaleTextureCoordinates(new Vector2f(20, 20));
ground = new Geometry("soil", b);
TangentBinormalGenerator.generate(ground);
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);
matGroundL = assetManager.loadMaterial("jme3test/light/pbr/pbrMat4.j3m");
ground.setMaterial(matGroundL);
//ground.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(ground);
l = new DirectionalLight();
l.setColor(ColorRGBA.White);
//l.setDirection(new Vector3f(0.5973172f, -0.16583486f, 0.7846725f).normalizeLocal());
l.setDirection(new Vector3f(-0.2823181f, -0.41889593f, 0.863031f).normalizeLocal());
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", SkyFactory.EnvMapType.CubeMap);
Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Path.hdr", SkyFactory.EnvMapType.EquirectMap);
sky.setLocalScale(350);
rootNode.attachChild(sky);
}
use of com.jme3.scene.shape.Box in project jmonkeyengine by jMonkeyEngine.
the class HelloInput method simpleInitApp.
@Override
public void simpleInitApp() {
Box b = new Box(1, 1, 1);
player = new Geometry("Player", b);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
player.setMaterial(mat);
rootNode.attachChild(player);
// load my custom keybinding
initKeys();
}
use of com.jme3.scene.shape.Box in project jmonkeyengine by jMonkeyEngine.
the class HelloJME3 method simpleInitApp.
@Override
public void simpleInitApp() {
// create cube shape
Box b = new Box(1, 1, 1);
// create cube geometry from the shape
Geometry geom = new Geometry("Box", b);
Material mat = new Material(assetManager, // create a simple material
"Common/MatDefs/Misc/Unshaded.j3md");
// set color of material to blue
mat.setColor("Color", ColorRGBA.Blue);
// set the cube's material
geom.setMaterial(mat);
// make the cube appear in the scene
rootNode.attachChild(geom);
}
use of com.jme3.scene.shape.Box in project jmonkeyengine by jMonkeyEngine.
the class HelloNode method simpleInitApp.
@Override
public void simpleInitApp() {
/** create a blue box at coordinates (1,-1,1) */
Box box1 = new Box(1, 1, 1);
Geometry blue = new Geometry("Box", box1);
blue.setLocalTranslation(new Vector3f(1, -1, 1));
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat1.setColor("Color", ColorRGBA.Blue);
blue.setMaterial(mat1);
/** create a red box straight above the blue one at (1,3,1) */
Box box2 = new Box(1, 1, 1);
Geometry red = new Geometry("Box", box2);
red.setLocalTranslation(new Vector3f(1, 3, 1));
Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat2.setColor("Color", ColorRGBA.Red);
red.setMaterial(mat2);
/** Create a pivot node at (0,0,0) and attach it to the root node */
Node pivot = new Node("pivot");
// put this node in the scene
rootNode.attachChild(pivot);
/** Attach the two boxes to the *pivot* node. (And transitively to the root node.) */
pivot.attachChild(blue);
pivot.attachChild(red);
/** Rotate the pivot node: Note that both boxes have rotated! */
pivot.rotate(.4f, .4f, 0f);
}
use of com.jme3.scene.shape.Box in project jmonkeyengine by jMonkeyEngine.
the class TestRenderToCubemap method setupOffscreenView.
public Texture setupOffscreenView() {
Camera offCamera = new Camera(512, 512);
offView = renderManager.createPreView("Offscreen View", offCamera);
offView.setClearFlags(true, true, true);
offView.setBackgroundColor(ColorRGBA.DarkGray);
// create offscreen framebuffer
FrameBuffer offBuffer = new FrameBuffer(512, 512, 1);
//setup framebuffer's cam
offCamera.setFrustumPerspective(45f, 1f, 1f, 1000f);
offCamera.setLocation(new Vector3f(0f, 0f, -5f));
offCamera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y);
//setup framebuffer's texture
TextureCubeMap offTex = new TextureCubeMap(512, 512, Format.RGBA8);
offTex.setMinFilter(Texture.MinFilter.Trilinear);
offTex.setMagFilter(Texture.MagFilter.Bilinear);
//setup framebuffer to use texture
offBuffer.setDepthBuffer(Format.Depth);
offBuffer.setMultiTarget(true);
offBuffer.addColorTexture(offTex, TextureCubeMap.Face.NegativeX);
offBuffer.addColorTexture(offTex, TextureCubeMap.Face.PositiveX);
offBuffer.addColorTexture(offTex, TextureCubeMap.Face.NegativeY);
offBuffer.addColorTexture(offTex, TextureCubeMap.Face.PositiveY);
offBuffer.addColorTexture(offTex, TextureCubeMap.Face.NegativeZ);
offBuffer.addColorTexture(offTex, TextureCubeMap.Face.PositiveZ);
//set viewport to render to offscreen framebuffer
offView.setOutputFrameBuffer(offBuffer);
// setup framebuffer's scene
Box boxMesh = new Box(1, 1, 1);
Material material = assetManager.loadMaterial("Interface/Logo/Logo.j3m");
offBox = new Geometry("box", boxMesh);
offBox.setMaterial(material);
// attach the scene to the viewport to be rendered
offView.attachScene(offBox);
return offTex;
}
Aggregations