/** * Creates a terrain with: * <ul> * <li>the total, real-world, size of the terrain</li> * <li>the patchSize, or the size of each geometry tile of the terrain</li> * <li>the heightmap that defines the height of the terrain</li> * </ul> * <p> * A TerrainQuad of totalSize 513x513 will be 513 units wide and 513 units long. * PatchSize is just used to subdivide the terrain into tiles that can be culled. * </p> * @param name the name of the scene element. This is required for * identification and comparison purposes. * @param patchSize size of the individual patches (geometry). Power of 2 plus 1, * must be smaller than totalSize. (eg. 33, 65...) * @param totalSize the size of this entire terrain (on one side). Power of 2 plus 1 * (eg. 513, 1025, 2049...) * @param heightMap The height map to generate the terrain from (a flat * height map will be generated if this is null). The size of one side of the heightmap * must match the totalSize. So a 513x513 heightmap is needed for a terrain with totalSize of 513. */ public TerrainQuad(String name, int patchSize, int totalSize, float[] heightMap) { this(name, patchSize, totalSize, Vector3f.UNIT_XYZ, heightMap); affectedAreaBBox = new BoundingBox(new Vector3f(0,0,0), size*2, Float.MAX_VALUE, size*2); fixNormalEdges(affectedAreaBBox); addControl(new NormalRecalcControl(this)); }
public void tileAttached(Vector3f cell, TerrainQuad quad) { while(quad.getControl(RigidBodyControl.class)!=null){ quad.removeControl(RigidBodyControl.class); } quad.addControl(new RigidBodyControl(new HeightfieldCollisionShape(quad.getHeightMap(), terrain.getLocalScale()), 0)); bulletAppState.getPhysicsSpace().add(quad); }
public void tileAttached(Vector3f cell, TerrainQuad quad) { while(quad.getControl(RigidBodyControl.class)!=null){ quad.removeControl(RigidBodyControl.class); } quad.addControl(new RigidBodyControl(new HeightfieldCollisionShape(quad.getHeightMap(), terrain.getLocalScale()), 0)); bulletAppState.getPhysicsSpace().add(quad); }
public void tileAttached(Vector3f cell, TerrainQuad quad) { //workaround for bugged test j3o's while(quad.getControl(RigidBodyControl.class)!=null){ quad.removeControl(RigidBodyControl.class); } quad.addControl(new RigidBodyControl(new HeightfieldCollisionShape(quad.getHeightMap(), terrain.getLocalScale()), 0)); bulletAppState.getPhysicsSpace().add(quad); }
public void tileAttached(Vector3f cell, TerrainQuad quad) { Texture alpha = null; try { alpha = assetManager.loadTexture("TerrainAlphaTest/alpha_" + (int)cell.x+ "_" + (int)cell.z + ".png"); } catch (Exception e) { alpha = assetManager.loadTexture("TerrainAlphaTest/alpha_default.png"); } quad.getMaterial().setTexture("AlphaMap", alpha); if (usePhysics) { quad.addControl(new RigidBodyControl(new HeightfieldCollisionShape(quad.getHeightMap(), terrain.getLocalScale()), 0)); bulletAppState.getPhysicsSpace().add(quad); } updateMarkerElevations(); }
else { control = new TerrainLodControl(terrain, cam); terrain.addControl(control);
cameras.add(getCamera()); TerrainLodControl control = new TerrainLodControl(terrain, cameras); terrain.addControl(control); terrain.setMaterial(matRock); terrain.setLocalScale(new Vector3f(2, 2, 2)); terrain.addControl(new RigidBodyControl(0)); rootNode.attachChild(terrain); getPhysicsSpace().addAll(terrain);
cameras.add(getCamera()); TerrainLodControl control = new TerrainLodControl(terrain, cameras); terrain.addControl(control); terrain.setMaterial(matRock); terrain.setLocalScale(new Vector3f(2, 2, 2)); terrain.addControl(terrainPhysicsNode); rootNode.attachChild(terrain); getPhysicsSpace().add(terrainPhysicsNode);
cameras.add(getCamera()); TerrainLodControl control = new TerrainLodControl(terrain, cameras); terrain.addControl(control); terrain.addControl(new RigidBodyControl(0));
TerrainLodControl control = new TerrainLodControl(terrain, getCamera()); control.setLodCalculator( new DistanceLodCalculator(65, 2.7f) ); // patch size, and a multiplier terrain.addControl(control); terrain.setMaterial(matRock); terrain.setLocalScale(new Vector3f(2, 2, 2)); terrain.addControl(new RigidBodyControl(0)); bulletAppState.getPhysicsSpace().addAll(terrain);
TerrainLodControl control = new TerrainLodControl(terrain, getCamera()); control.setLodCalculator( new DistanceLodCalculator(65, 2.7f) ); // patch size, and a multiplier terrain.addControl(control); terrain.setMaterial(matTerrain); terrain.setLocalTranslation(0, -100, 0);
TerrainLodControl control = new TerrainLodControl(terrainQuad, getCamera()); control.setLodCalculator( new DistanceLodCalculator(65, 2.7f) ); // patch size, and a multiplier terrainQuad.addControl(control); terrainQuad.setMaterial(matTerrain); terrainQuad.setLocalTranslation(0, -100, 0);
TerrainLodControl control = new TerrainLodControl(terrain, getCamera()); control.setLodCalculator( new DistanceLodCalculator(65, 2.7f) ); // patch size, and a multiplier terrain.addControl(control); terrain.setMaterial(matRock); terrain.setLocalTranslation(0, -100, 0);
TerrainLodControl control = new TerrainLodControl(terrain, getCamera()); control.setLodCalculator( new DistanceLodCalculator(33, 2.7f) ); // patch size, and a multiplier terrain.addControl(control); terrain.setMaterial(matRock); terrain.setLocalTranslation(0, -100, 0);
terrain.addControl(control);
TerrainLodControl control = new TerrainLodControl(terrain, getCamera()); control.setLodCalculator( new DistanceLodCalculator(65, 2.7f) ); terrain.addControl(control); terrain.setMaterial(matTerrain); terrain.setModelBound(new BoundingBox());
this.terrain.addControl(control);
TerrainLodControl control = new TerrainLodControl(terrain, getCamera()); control.setLodCalculator( new DistanceLodCalculator(65, 2.7f) ); // patch size, and a multiplier terrain.addControl(control); terrain.setMaterial(matTerrain); terrain.setModelBound(new BoundingBox());
/** * Creates a terrain with: * <ul> * <li>the total, real-world, size of the terrain</li> * <li>the patchSize, or the size of each geometry tile of the terrain</li> * <li>the heightmap that defines the height of the terrain</li> * </ul> * <p> * A TerrainQuad of totalSize 513x513 will be 513 units wide and 513 units long. * PatchSize is just used to subdivide the terrain into tiles that can be culled. * </p> * @param name the name of the scene element. This is required for * identification and comparison purposes. * @param patchSize size of the individual patches (geometry). Power of 2 plus 1, * must be smaller than totalSize. (eg. 33, 65...) * @param totalSize the size of this entire terrain (on one side). Power of 2 plus 1 * (eg. 513, 1025, 2049...) * @param heightMap The height map to generate the terrain from (a flat * height map will be generated if this is null). The size of one side of the heightmap * must match the totalSize. So a 513x513 heightmap is needed for a terrain with totalSize of 513. */ public TerrainQuad(String name, int patchSize, int totalSize, float[] heightMap) { this(name, patchSize, totalSize, Vector3f.UNIT_XYZ, heightMap); affectedAreaBBox = new BoundingBox(new Vector3f(0,0,0), size*2, Float.MAX_VALUE, size*2); fixNormalEdges(affectedAreaBBox); addControl(new NormalRecalcControl(this)); }
public void setStaticGeometry(Node staticNode) { this.staticNode = staticNode; // Add SKY direct to Root Spatial sky = staticNode.getChild("Skymap"); if(sky != null) { sky.removeFromParent(); this.rootNode.attachChild(sky); } // Add TERRAIN direct to Root Spatial terra = staticNode.getChild("Terrain"); if(terra != null) { terra.removeFromParent(); // ShadowMode mode = terra.getShadowMode(); terrain = (TerrainQuad)terra; terrain.setLocalTranslation(appScaled / 2, 0, appScaled / 2); this.rootNode.attachChild(terrain); /** 5. The LOD (level of detail) depends on were the camera is: */ TerrainLodControl control = new TerrainLodControl(terrain, cam); terrain.addControl(control); terrain.setShadowMode(ShadowMode.Receive); } GeometryBatchFactory.optimize(this.staticNode, true); this.rootNode.attachChild(this.staticNode); }