Search in sources :

Example 91 with Box

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);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) BoundingSphere(com.jme3.bounding.BoundingSphere) Spatial(com.jme3.scene.Spatial) Vector2f(com.jme3.math.Vector2f) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) AmbientLight(com.jme3.light.AmbientLight)

Example 92 with Box

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();
}
Also used : Geometry(com.jme3.scene.Geometry) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material)

Example 93 with Box

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);
}
Also used : Geometry(com.jme3.scene.Geometry) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material)

Example 94 with Box

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);
}
Also used : Geometry(com.jme3.scene.Geometry) Vector3f(com.jme3.math.Vector3f) Node(com.jme3.scene.Node) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material)

Example 95 with Box

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;
}
Also used : Geometry(com.jme3.scene.Geometry) Vector3f(com.jme3.math.Vector3f) TextureCubeMap(com.jme3.texture.TextureCubeMap) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) Camera(com.jme3.renderer.Camera) FrameBuffer(com.jme3.texture.FrameBuffer)

Aggregations

Geometry (com.jme3.scene.Geometry)106 Box (com.jme3.scene.shape.Box)99 Material (com.jme3.material.Material)83 Vector3f (com.jme3.math.Vector3f)77 Node (com.jme3.scene.Node)31 DirectionalLight (com.jme3.light.DirectionalLight)27 Sphere (com.jme3.scene.shape.Sphere)23 Quaternion (com.jme3.math.Quaternion)20 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)19 Spatial (com.jme3.scene.Spatial)19 BoundingBox (com.jme3.bounding.BoundingBox)17 Vector2f (com.jme3.math.Vector2f)15 Texture (com.jme3.texture.Texture)15 AmbientLight (com.jme3.light.AmbientLight)13 TempVars (com.jme3.util.TempVars)12 BulletAppState (com.jme3.bullet.BulletAppState)11 KeyTrigger (com.jme3.input.controls.KeyTrigger)11 FilterPostProcessor (com.jme3.post.FilterPostProcessor)11 BoundingSphere (com.jme3.bounding.BoundingSphere)8 BoxCollisionShape (com.jme3.bullet.collision.shapes.BoxCollisionShape)8