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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations