use of com.jme3.bounding.BoundingSphere in project jmonkeyengine by jMonkeyEngine.
the class RefEnv method simpleUpdate.
@Override
public void simpleUpdate(float tpf) {
frame++;
if (frame == 2) {
final LightProbe probe = LightProbeFactory.makeProbe(stateManager.getState(EnvironmentCamera.class), rootNode, new JobProgressAdapter<LightProbe>() {
@Override
public void done(LightProbe result) {
System.err.println("Done rendering env maps");
tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(result.getPrefilteredEnvMap(), assetManager);
// guiNode.attachChild(tex);
rootNode.getChild("Scene").setCullHint(Spatial.CullHint.Dynamic);
}
});
((BoundingSphere) probe.getBounds()).setRadius(100);
rootNode.addLight(probe);
}
}
use of com.jme3.bounding.BoundingSphere in project jmonkeyengine by jMonkeyEngine.
the class TestPBRLighting method simpleUpdate.
@Override
public void simpleUpdate(float tpf) {
frame++;
if (frame == 2) {
modelNode.removeFromParent();
final LightProbe probe = LightProbeFactory.makeProbe(stateManager.getState(EnvironmentCamera.class), rootNode, new JobProgressAdapter<LightProbe>() {
@Override
public void done(LightProbe result) {
System.err.println("Done rendering env maps");
tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(result.getPrefilteredEnvMap(), assetManager);
tex2 = EnvMapUtils.getCubeMapCrossDebugView(result.getIrradianceMap(), assetManager);
}
});
((BoundingSphere) probe.getBounds()).setRadius(100);
rootNode.addLight(probe);
//getStateManager().getState(EnvironmentManager.class).addEnvProbe(probe);
}
if (frame > 10 && modelNode.getParent() == null) {
rootNode.attachChild(modelNode);
}
}
use of com.jme3.bounding.BoundingSphere in project jmonkeyengine by jMonkeyEngine.
the class TestRayCasting method simpleInitApp.
@Override
public void simpleInitApp() {
// flyCam.setEnabled(false);
// load material
Material mat = (Material) assetManager.loadMaterial("Interface/Logo/Logo.j3m");
Mesh q = new Mesh();
q.setBuffer(Type.Position, 3, new float[] { 1, 0, 0, 0, 1.5f, 0, -1, 0, 0 });
q.setBuffer(Type.Index, 3, new int[] { 0, 1, 2 });
q.setBound(new BoundingSphere());
q.updateBound();
// Geometry teapot = new Geometry("MyGeom", q);
teapot = assetManager.loadModel("Models/Teapot/Teapot.mesh.xml");
// teapot.scale(2f, 2f, 2f);
// teapot.move(2f, 2f, -.5f);
teapot.rotate(FastMath.HALF_PI, FastMath.HALF_PI, FastMath.HALF_PI);
teapot.setMaterial(mat);
rootNode.attachChild(teapot);
// cam.setLocation(cam.getLocation().add(0,1,0));
// cam.lookAt(teapot.getWorldBound().getCenter(), Vector3f.UNIT_Y);
tracer = new RayTrace(rootNode, cam, 160, 128);
tracer.show();
tracer.update();
}
use of com.jme3.bounding.BoundingSphere in project jmonkeyengine by jMonkeyEngine.
the class BoundingCollisionTest method testSphereSphereCollision.
@Test
public void testSphereSphereCollision() {
BoundingSphere sphere1 = new BoundingSphere(1, Vector3f.ZERO);
BoundingSphere sphere2 = new BoundingSphere(1, Vector3f.ZERO);
checkCollision(sphere1, sphere2, 1);
// Put it at the very edge - should still intersect.
sphere2.setCenter(new Vector3f(2f, 0f, 0f));
checkCollision(sphere1, sphere2, 1);
// Put it a wee bit farther - no intersection expected
sphere2.setCenter(new Vector3f(2f + FastMath.ZERO_TOLERANCE, 0, 0));
checkCollision(sphere1, sphere2, 0);
}
use of com.jme3.bounding.BoundingSphere in project jmonkeyengine by jMonkeyEngine.
the class BoundingCollisionTest method testBoxSphereCollision.
@Test
public void testBoxSphereCollision() {
BoundingBox box1 = new BoundingBox(Vector3f.ZERO, 1, 1, 1);
BoundingSphere sphere2 = new BoundingSphere(1, Vector3f.ZERO);
checkCollision(box1, sphere2, 1);
// Put it at the very edge - for sphere vs. box, it will not intersect
sphere2.setCenter(new Vector3f(2f, 0f, 0f));
checkCollision(box1, sphere2, 0);
// Put it a wee bit closer - should intersect.
sphere2.setCenter(new Vector3f(2f - FastMath.ZERO_TOLERANCE, 0, 0));
checkCollision(box1, sphere2, 1);
// Test if the algorithm converts the sphere
// to a box before testing the collision (incorrect)
float sqrt3 = FastMath.sqrt(3);
sphere2.setCenter(Vector3f.UNIT_XYZ.mult(2));
sphere2.setRadius(sqrt3);
checkCollision(box1, sphere2, 0);
// Make it a wee bit larger.
sphere2.setRadius(sqrt3 + FastMath.ZERO_TOLERANCE);
checkCollision(box1, sphere2, 1);
}
Aggregations