Search in sources :

Example 1 with NanoTimer

use of com.jme3.system.NanoTimer in project jmonkeyengine by jMonkeyEngine.

the class LwjglWindowVR method initInThread.

/**
     * Does LWJGL display initialization in the OpenGL thread
     */
protected boolean initInThread() {
    try {
        if (!JmeSystem.isLowPermissions()) {
            // Enable uncaught exception handler only for current thread
            Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {

                @Override
                public void uncaughtException(Thread thread, Throwable thrown) {
                    listener.handleError("Uncaught exception thrown in " + thread.toString(), thrown);
                    if (needClose.get()) {
                        // listener.handleError() has requested the
                        // context to close. Satisfy request.
                        deinitInThread();
                    }
                }
            });
        }
        loadNatives();
        timer = new NanoTimer();
        // For canvas, this will create a pbuffer,
        // allowing us to query information.
        // When the canvas context becomes available, it will
        // be replaced seamlessly.
        createContext(settings);
        printContextInitInfo();
        created.set(true);
        super.internalCreate();
    } catch (Exception ex) {
        try {
            if (window != NULL) {
                glfwDestroyWindow(window);
                window = NULL;
            }
        } catch (Exception ex2) {
            LOGGER.log(Level.WARNING, null, ex2);
        }
        listener.handleError("Failed to create display", ex);
        // if we failed to create display, do not continue
        return false;
    }
    listener.initialize();
    return true;
}
Also used : NanoTimer(com.jme3.system.NanoTimer)

Example 2 with NanoTimer

use of com.jme3.system.NanoTimer in project jmonkeyengine by jMonkeyEngine.

the class LwjglWindow method initInThread.

/**
     * Does LWJGL display initialization in the OpenGL thread
     */
protected boolean initInThread() {
    try {
        if (!JmeSystem.isLowPermissions()) {
            // Enable uncaught exception handler only for current thread
            Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {

                @Override
                public void uncaughtException(Thread thread, Throwable thrown) {
                    listener.handleError("Uncaught exception thrown in " + thread.toString(), thrown);
                    if (needClose.get()) {
                        // listener.handleError() has requested the
                        // context to close. Satisfy request.
                        deinitInThread();
                    }
                }
            });
        }
        timer = new NanoTimer();
        // For canvas, this will create a pbuffer,
        // allowing us to query information.
        // When the canvas context becomes available, it will
        // be replaced seamlessly.
        createContext(settings);
        printContextInitInfo();
        created.set(true);
        super.internalCreate();
        //Must be done here because the window handle is needed
        if (settings.isOpenCLSupport()) {
            initOpenCL(window);
        }
    } catch (Exception ex) {
        try {
            if (window != NULL) {
                glfwDestroyWindow(window);
                window = NULL;
            }
        } catch (Exception ex2) {
            LOGGER.log(Level.WARNING, null, ex2);
        }
        listener.handleError("Failed to create display", ex);
        // if we failed to create display, do not continue
        return false;
    }
    listener.initialize();
    return true;
}
Also used : NanoTimer(com.jme3.system.NanoTimer)

Example 3 with NanoTimer

use of com.jme3.system.NanoTimer in project jmonkeyengine by jMonkeyEngine.

the class TestBatchNode method simpleInitApp.

@Override
public void simpleInitApp() {
    timer = new NanoTimer();
    batch = new BatchNode("theBatchNode");
    /**
         * A cube with a color "bleeding" through transparent texture. Uses
         * Texture from jme3-test-data library!
         */
    Box boxshape4 = new Box(1f, 1f, 1f);
    cube = new Geometry("cube1", boxshape4);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    cube.setMaterial(mat);
    //        Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");        
    //        mat.setColor("Diffuse", ColorRGBA.Blue);
    //        mat.setBoolean("UseMaterialColors", true);
    /**
         * A cube with a color "bleeding" through transparent texture. Uses
         * Texture from jme3-test-data library!
         */
    Box box = new Box(1f, 1f, 1f);
    cube2 = new Geometry("cube2", box);
    cube2.setMaterial(mat);
    TangentBinormalGenerator.generate(cube);
    TangentBinormalGenerator.generate(cube2);
    n = new Node("aNode");
    // n.attachChild(cube2);
    batch.attachChild(cube);
    //  batch.attachChild(cube2);
    //  batch.setMaterial(mat);
    batch.batch();
    rootNode.attachChild(batch);
    cube.setLocalTranslation(3, 0, 0);
    cube2.setLocalTranslation(0, 20, 0);
    updateBoindPoints(points);
    frustum = new WireFrustum(points);
    frustumMdl = new Geometry("f", frustum);
    frustumMdl.setCullHint(Spatial.CullHint.Never);
    frustumMdl.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"));
    frustumMdl.getMaterial().getAdditionalRenderState().setWireframe(true);
    frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red);
    rootNode.attachChild(frustumMdl);
    dl = new DirectionalLight();
    dl.setColor(ColorRGBA.White.mult(2));
    dl.setDirection(new Vector3f(1, -1, -1));
    rootNode.addLight(dl);
    flyCam.setMoveSpeed(10);
}
Also used : Geometry(com.jme3.scene.Geometry) NanoTimer(com.jme3.system.NanoTimer) WireFrustum(com.jme3.scene.debug.WireFrustum) Node(com.jme3.scene.Node) BatchNode(com.jme3.scene.BatchNode) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) BoundingBox(com.jme3.bounding.BoundingBox) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) BatchNode(com.jme3.scene.BatchNode)

Example 4 with NanoTimer

use of com.jme3.system.NanoTimer in project jmonkeyengine by jMonkeyEngine.

the class TestBatchNodeCluster method simpleInitApp.

//protected
//    protected Geometry player;
@Override
public void simpleInitApp() {
    timer = new NanoTimer();
    batchNode = new SimpleBatchNode("BatchNode");
    xPosition.add(0);
    yPosition.add(0);
    zPosition.add(0);
    mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat1.setColor("Color", ColorRGBA.White);
    mat1.setColor("GlowColor", ColorRGBA.Blue.mult(10));
    mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat2.setColor("Color", ColorRGBA.White);
    mat2.setColor("GlowColor", ColorRGBA.Red.mult(10));
    mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat3.setColor("Color", ColorRGBA.White);
    mat3.setColor("GlowColor", ColorRGBA.Yellow.mult(10));
    mat4 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat4.setColor("Color", ColorRGBA.White);
    mat4.setColor("GlowColor", ColorRGBA.Orange.mult(10));
    randomGenerator();
    //rootNode.attachChild(SkyFactory.createSky(
    //  assetManager, "Textures/SKY02.zip", false));
    inputManager.addMapping("Start Game", new KeyTrigger(KeyInput.KEY_J));
    inputManager.addListener(al, new String[] { "Start Game" });
    cam.setLocation(new Vector3f(-34.403286f, 126.65158f, 434.791f));
    cam.setRotation(new Quaternion(0.022630932f, 0.9749435f, -0.18736298f, 0.11776358f));
    batchNode.batch();
    terrain = new Node("terrain");
    terrain.setLocalTranslation(50, 0, 50);
    terrain.attachChild(batchNode);
    flyCam.setMoveSpeed(100);
    rootNode.attachChild(terrain);
    Vector3f pos = new Vector3f(-40, 0, -40);
    batchNode.setLocalTranslation(pos);
    Arrow a = new Arrow(new Vector3f(0, 50, 0));
    Geometry g = new Geometry("a", a);
    g.setLocalTranslation(terrain.getLocalTranslation());
    Material m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    m.setColor("Color", ColorRGBA.Blue);
    g.setMaterial(m);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(new BloomFilter(BloomFilter.GlowMode.Objects));
    //        SSAOFilter ssao = new SSAOFilter(8.630104f,22.970434f,2.9299977f,0.2999997f);    
    //        fpp.addFilter(ssao);
    viewPort.addProcessor(fpp);
//   viewPort.setBackgroundColor(ColorRGBA.DarkGray);
}
Also used : Arrow(com.jme3.scene.debug.Arrow) NanoTimer(com.jme3.system.NanoTimer) Quaternion(com.jme3.math.Quaternion) KeyTrigger(com.jme3.input.controls.KeyTrigger) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) BloomFilter(com.jme3.post.filters.BloomFilter)

Example 5 with NanoTimer

use of com.jme3.system.NanoTimer in project jmonkeyengine by jMonkeyEngine.

the class TestBatchNodeTower method simpleInitApp.

@Override
public void simpleInitApp() {
    timer = new NanoTimer();
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
    //   bulletAppState.setEnabled(false);
    stateManager.attach(bulletAppState);
    bullet = new Sphere(32, 32, 0.4f, true, false);
    bullet.setTextureMode(TextureMode.Projected);
    bulletCollisionShape = new SphereCollisionShape(0.4f);
    brick = new Box(brickWidth, brickHeight, brickDepth);
    brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
    //bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    initMaterial();
    initTower();
    initFloor();
    initCrossHairs();
    this.cam.setLocation(new Vector3f(0, 25f, 8f));
    cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
    cam.setFrustumFar(80);
    inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(actionListener, "shoot");
    rootNode.setShadowMode(ShadowMode.Off);
    batchNode.batch();
    batchNode.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(batchNode);
    shadowRenderer = new DirectionalLightShadowFilter(assetManager, 1024, 2);
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    shadowRenderer.setLight(dl);
    shadowRenderer.setLambda(0.55f);
    shadowRenderer.setShadowIntensity(0.6f);
    shadowRenderer.setShadowCompareMode(CompareMode.Hardware);
    shadowRenderer.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(shadowRenderer);
    viewPort.addProcessor(fpp);
}
Also used : Sphere(com.jme3.scene.shape.Sphere) SphereCollisionShape(com.jme3.bullet.collision.shapes.SphereCollisionShape) NanoTimer(com.jme3.system.NanoTimer) Vector2f(com.jme3.math.Vector2f) BulletAppState(com.jme3.bullet.BulletAppState) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) Box(com.jme3.scene.shape.Box) FilterPostProcessor(com.jme3.post.FilterPostProcessor) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger) DirectionalLightShadowFilter(com.jme3.shadow.DirectionalLightShadowFilter)

Aggregations

NanoTimer (com.jme3.system.NanoTimer)6 Vector3f (com.jme3.math.Vector3f)3 DirectionalLight (com.jme3.light.DirectionalLight)2 Material (com.jme3.material.Material)2 FilterPostProcessor (com.jme3.post.FilterPostProcessor)2 GL (com.jme3.renderer.opengl.GL)2 GLExt (com.jme3.renderer.opengl.GLExt)2 GLFbo (com.jme3.renderer.opengl.GLFbo)2 GLRenderer (com.jme3.renderer.opengl.GLRenderer)2 Box (com.jme3.scene.shape.Box)2 BoundingBox (com.jme3.bounding.BoundingBox)1 BulletAppState (com.jme3.bullet.BulletAppState)1 SphereCollisionShape (com.jme3.bullet.collision.shapes.SphereCollisionShape)1 KeyTrigger (com.jme3.input.controls.KeyTrigger)1 MouseButtonTrigger (com.jme3.input.controls.MouseButtonTrigger)1 IosInputHandler (com.jme3.input.ios.IosInputHandler)1 Quaternion (com.jme3.math.Quaternion)1 Vector2f (com.jme3.math.Vector2f)1 BloomFilter (com.jme3.post.filters.BloomFilter)1 AndroidGL (com.jme3.renderer.android.AndroidGL)1