use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.
the class TestTessellationShader method simpleInitApp.
@Override
public void simpleInitApp() {
tessellationMaterial = new Material(getAssetManager(), "Materials/Tess/SimpleTess.j3md");
tessellationMaterial.setInt("TessellationFactor", tessFactor);
tessellationMaterial.getAdditionalRenderState().setWireframe(true);
Quad quad = new Quad(10, 10);
quad.clearBuffer(VertexBuffer.Type.Index);
quad.setBuffer(VertexBuffer.Type.Index, 4, BufferUtils.createIntBuffer(0, 1, 2, 3));
quad.setMode(Mesh.Mode.Patch);
quad.setPatchVertexCount(4);
Geometry geometry = new Geometry("tessTest", quad);
geometry.setMaterial(tessellationMaterial);
rootNode.attachChild(geometry);
getInputManager().addMapping("TessUp", new KeyTrigger(KeyInput.KEY_O));
getInputManager().addMapping("TessDo", new KeyTrigger(KeyInput.KEY_L));
getInputManager().addListener(new AnalogListener() {
@Override
public void onAnalog(String name, float value, float tpf) {
if (name.equals("TessUp")) {
tessFactor++;
enqueue(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
tessellationMaterial.setInt("TessellationFactor", tessFactor);
return true;
}
});
}
if (name.equals("TessDo")) {
tessFactor--;
enqueue(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
tessellationMaterial.setInt("TessellationFactor", tessFactor);
return true;
}
});
}
}
}, "TessUp", "TessDo");
}
use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.
the class TestHoverTank method simpleInitApp.
@Override
public void simpleInitApp() {
Node tank = (Node) assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml");
flyCam.setEnabled(false);
ChaseCamera chaseCam = new ChaseCamera(cam, tank, inputManager);
chaseCam.setSmoothMotion(true);
chaseCam.setMaxDistance(100000);
chaseCam.setMinVerticalRotation(-FastMath.PI / 2);
viewPort.setBackgroundColor(ColorRGBA.DarkGray);
Geometry tankGeom = (Geometry) tank.getChild(0);
LodControl control = new LodControl();
tankGeom.addControl(control);
rootNode.attachChild(tank);
Vector3f lightDir = new Vector3f(-0.8719428f, -0.46824604f, 0.14304268f);
DirectionalLight dl = new DirectionalLight();
dl.setColor(new ColorRGBA(1.0f, 0.92f, 0.75f, 1f));
dl.setDirection(lightDir);
Vector3f lightDir2 = new Vector3f(0.70518064f, 0.5902297f, -0.39287305f);
DirectionalLight dl2 = new DirectionalLight();
dl2.setColor(new ColorRGBA(0.7f, 0.85f, 1.0f, 1f));
dl2.setDirection(lightDir2);
rootNode.addLight(dl);
rootNode.addLight(dl2);
rootNode.attachChild(tank);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
BloomFilter bf = new BloomFilter(BloomFilter.GlowMode.Objects);
bf.setBloomIntensity(2.0f);
bf.setExposurePower(1.3f);
fpp.addFilter(bf);
BloomUI bui = new BloomUI(inputManager, bf);
viewPort.addProcessor(fpp);
}
use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.
the class AbstractShadowRendererVR method postFrame.
public void postFrame(FrameBuffer out) {
if (skipPostPass) {
return;
}
if (debug) {
displayShadowMap(renderManager.getRenderer());
}
getReceivers(lightReceivers);
if (lightReceivers.size() != 0) {
//setting params to recieving geometry list
setMatParams(lightReceivers);
Camera cam = viewPort.getCamera();
//some materials in the scene does not have a post shadow technique so we're using the fall back material
if (needsfallBackMaterial) {
renderManager.setForcedMaterial(postshadowMat);
}
//forcing the post shadow technique and render state
renderManager.setForcedTechnique(postTechniqueName);
//rendering the post shadow pass
viewPort.getQueue().renderShadowQueue(lightReceivers, renderManager, cam, false);
//resetting renderManager settings
renderManager.setForcedTechnique(null);
renderManager.setForcedMaterial(null);
renderManager.setCamera(cam, false);
//clearing the params in case there are some other shadow renderers
clearMatParams();
}
}
use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.
the class ShadowUtil method getGeometriesInCamFrustum.
/**
* Populates the outputGeometryList with the geometry of the
* inputGeomtryList that are in the frustum of the given camera
*
* @param inputGeometryList The list containing all geometry to check
* against the camera frustum
* @param camera the camera to check geometries against
* @param outputGeometryList the list of all geometries that are in the
* camera frustum
*/
public static void getGeometriesInCamFrustum(GeometryList inputGeometryList, Camera camera, GeometryList outputGeometryList) {
for (int i = 0; i < inputGeometryList.size(); i++) {
Geometry g = inputGeometryList.get(i);
int planeState = camera.getPlaneState();
camera.setPlaneState(0);
if (camera.contains(g.getWorldBound()) != Camera.FrustumIntersect.Outside) {
outputGeometryList.add(g);
}
camera.setPlaneState(planeState);
}
}
use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.
the class ShadowUtil method addGeometriesInCamFrustumAndViewPortFromNode.
/**
* Helper function to recursively collect the geometries for getLitGeometriesInViewPort function.
*
* @param vpCamera the viewPort camera
* @param cameras the camera array to check geometries against, representing the light viewspace
* @param scene the Node to traverse or geometry to possibly add
* @param outputGeometryList the output list of all geometries that are in the camera frustum
*/
private static void addGeometriesInCamFrustumAndViewPortFromNode(Camera vpCamera, Camera[] cameras, Spatial scene, RenderQueue.ShadowMode mode, GeometryList outputGeometryList) {
if (scene.getCullHint() == Spatial.CullHint.Always)
return;
boolean inFrustum = false;
for (int j = 0; j < cameras.length && inFrustum == false; j++) {
Camera camera = cameras[j];
int planeState = camera.getPlaneState();
camera.setPlaneState(0);
inFrustum = camera.contains(scene.getWorldBound()) != Camera.FrustumIntersect.Outside && scene.checkCulling(vpCamera);
camera.setPlaneState(planeState);
}
if (inFrustum) {
if (scene instanceof Node) {
Node node = (Node) scene;
for (Spatial child : node.getChildren()) {
addGeometriesInCamFrustumAndViewPortFromNode(vpCamera, cameras, child, mode, outputGeometryList);
}
} else if (scene instanceof Geometry) {
if (checkShadowMode(scene.getShadowMode(), mode) && !((Geometry) scene).isGrouped()) {
outputGeometryList.add((Geometry) scene);
}
}
}
}
Aggregations