Search in sources :

Example 56 with Geometry

use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.

the class TestPbrEnv method simpleInitApp.

@Override
public void simpleInitApp() {
    assetManager.registerLoader(KTXLoader.class, "ktx");
    // put the camera in a bad position
    cam.setLocation(new Vector3f(-52.433647f, 68.69636f, -118.60924f));
    cam.setRotation(new Quaternion(0.10294232f, 0.25269797f, -0.027049713f, 0.96167296f));
    flyCam.setMoveSpeed(100);
    loadScene();
    dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 4);
    dlsr.setLight(l);
    //dlsr.setLambda(0.55f);
    dlsr.setShadowIntensity(0.5f);
    dlsr.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
    //dlsr.displayDebug();
    //       viewPort.addProcessor(dlsr);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(new ToneMapFilter(Vector3f.UNIT_XYZ.mult(6.0f)));
    SSAOFilter ssao = new SSAOFilter();
    ssao.setIntensity(5);
    fpp.addFilter(ssao);
    BloomFilter bloomFilter = new BloomFilter();
    fpp.addFilter(bloomFilter);
    fpp.addFilter(new FXAAFilter());
    //viewPort.addProcessor(fpp);
    initInputs();
    //        envManager = new EnvironmentManager();
    //        getStateManager().attach(envManager);
    //        
    envCam = new EnvironmentCamera();
    getStateManager().attach(envCam);
    debugState = new LightsDebugState();
    debugState.setProbeScale(5);
    getStateManager().attach(debugState);
    camGeom = new Geometry("camGeom", new Sphere(16, 16, 2));
    //        Material m = new Material(assetManager, "Common/MatDefs/Misc/UnshadedNodes.j3md");
    //        m.setColor("Color", ColorRGBA.Green);
    Material m = assetManager.loadMaterial("jme3test/light/pbr/pbrMat3.j3m");
    camGeom.setMaterial(m);
    camGeom.setLocalTranslation(0, 20, 0);
    camGeom.setLocalScale(5);
    rootNode.attachChild(camGeom);
    //     envManager.setScene(rootNode);
    //        MaterialDebugAppState debug = new MaterialDebugAppState();
    //        debug.registerBinding("MatDefs/PBRLighting.frag", rootNode);
    //        getStateManager().attach(debug);
    flyCam.setDragToRotate(true);
    setPauseOnLostFocus(false);
// cam.lookAt(camGeom.getWorldTranslation(), Vector3f.UNIT_Y);
}
Also used : SSAOFilter(com.jme3.post.ssao.SSAOFilter) FXAAFilter(com.jme3.post.filters.FXAAFilter) Quaternion(com.jme3.math.Quaternion) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) LightsDebugState(com.jme3.environment.util.LightsDebugState) BloomFilter(com.jme3.post.filters.BloomFilter) ToneMapFilter(com.jme3.post.filters.ToneMapFilter) Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) BoundingSphere(com.jme3.bounding.BoundingSphere) EnvironmentCamera(com.jme3.environment.EnvironmentCamera) Vector3f(com.jme3.math.Vector3f) DirectionalLightShadowRenderer(com.jme3.shadow.DirectionalLightShadowRenderer)

Example 57 with Geometry

use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.

the class TestBumpModel method simpleInitApp.

@Override
public void simpleInitApp() {
    Spatial signpost = (Spatial) assetManager.loadAsset(new OgreMeshKey("Models/Sign Post/Sign Post.mesh.xml"));
    signpost.setMaterial((Material) assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"));
    TangentBinormalGenerator.generate(signpost);
    rootNode.attachChild(signpost);
    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial((Material) assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    rootNode.attachChild(lightMdl);
    // flourescent main light
    pl = new PointLight();
    pl.setColor(new ColorRGBA(0.88f, 0.92f, 0.95f, 1.0f));
    rootNode.addLight(pl);
    // sunset light
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal());
    dl.setColor(new ColorRGBA(0.44f, 0.30f, 0.20f, 1.0f));
    rootNode.addLight(dl);
    // skylight
    dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.6f, -1, -0.6f).normalizeLocal());
    dl.setColor(new ColorRGBA(0.10f, 0.22f, 0.44f, 1.0f));
    rootNode.addLight(dl);
    // white ambient light
    dl = new DirectionalLight();
    dl.setDirection(new Vector3f(1, -0.5f, -0.1f).normalizeLocal());
    dl.setColor(new ColorRGBA(0.50f, 0.40f, 0.50f, 1.0f));
    rootNode.addLight(dl);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) ColorRGBA(com.jme3.math.ColorRGBA) Spatial(com.jme3.scene.Spatial) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) OgreMeshKey(com.jme3.scene.plugins.ogre.OgreMeshKey) PointLight(com.jme3.light.PointLight)

Example 58 with Geometry

use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.

the class TestColoredTexture method simpleInitApp.

@Override
public void simpleInitApp() {
    Quad quadMesh = new Quad(512, 512);
    Geometry quad = new Geometry("Quad", quadMesh);
    quad.setQueueBucket(Bucket.Gui);
    mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setTexture("ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png"));
    quad.setMaterial(mat);
    guiNode.attachChildAt(quad, 0);
    nextColor = ColorRGBA.randomColor();
    prevColor = ColorRGBA.Black;
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) Material(com.jme3.material.Material)

Example 59 with Geometry

use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.

the class TestGeometryShader method simpleInitApp.

@Override
public void simpleInitApp() {
    Mesh mesh = new Mesh();
    mesh.setBuffer(VertexBuffer.Type.Index, 1, BufferUtils.createIntBuffer(new int[] { 1 }));
    mesh.setBuffer(VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer(new float[] { 0, 0, 0 }));
    mesh.setMode(Mesh.Mode.Points);
    mesh.setBound(new BoundingBox(new Vector3f(0, 0, 0), 10, 10, 10));
    mesh.updateCounts();
    Geometry geometry = new Geometry("Test", mesh);
    geometry.updateGeometricState();
    geometry.setMaterial(new Material(assetManager, "Materials/Geom/SimpleGeom.j3md"));
    //geometry.getMaterial().getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
    //geometry.setMaterial(assetManager.loadMaterial("Materials/Geom/SimpleTess.j3md"));
    rootNode.attachChild(geometry);
    Geometry geometry1 = new Geometry("T1", new Sphere(10, 10, 1));
    geometry1.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"));
    rootNode.attachChild(geometry1);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) BoundingBox(com.jme3.bounding.BoundingBox) Vector3f(com.jme3.math.Vector3f) Mesh(com.jme3.scene.Mesh) Material(com.jme3.material.Material)

Example 60 with Geometry

use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.

the class TestMatParamOverride method createBox.

private void createBox(float location, ColorRGBA color) {
    Geometry geom = new Geometry("Box", box);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", color);
    geom.setMaterial(mat);
    geom.move(location, 0, 0);
    rootNode.attachChild(geom);
}
Also used : Geometry(com.jme3.scene.Geometry) Material(com.jme3.material.Material)

Aggregations

Geometry (com.jme3.scene.Geometry)246 Material (com.jme3.material.Material)175 Vector3f (com.jme3.math.Vector3f)116 Box (com.jme3.scene.shape.Box)92 DirectionalLight (com.jme3.light.DirectionalLight)56 Node (com.jme3.scene.Node)54 Sphere (com.jme3.scene.shape.Sphere)49 Spatial (com.jme3.scene.Spatial)41 Quaternion (com.jme3.math.Quaternion)39 Quad (com.jme3.scene.shape.Quad)33 Texture (com.jme3.texture.Texture)30 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)26 Mesh (com.jme3.scene.Mesh)25 KeyTrigger (com.jme3.input.controls.KeyTrigger)24 AmbientLight (com.jme3.light.AmbientLight)24 ColorRGBA (com.jme3.math.ColorRGBA)21 FilterPostProcessor (com.jme3.post.FilterPostProcessor)21 PointLight (com.jme3.light.PointLight)20 Vector2f (com.jme3.math.Vector2f)17 FloatBuffer (java.nio.FloatBuffer)17