public Material getMaterial() { return getMaterial(null); }
public Material getMaterial(Vector3f worldLocation) { // get the material from one of the children. They all share the same material if (children != null) { for (int i = children.size(); --i >= 0;) { Spatial child = children.get(i); if (child instanceof TerrainQuad) { return ((TerrainQuad)child).getMaterial(worldLocation); } else if (child instanceof TerrainPatch) { return ((TerrainPatch)child).getMaterial(); } } } return null; }
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(); }
q = gridTileLoader.getTerrainQuadAt(quadCell); if(q.getMaterial()==null) q.setMaterial(material.clone()); log.log(Level.FINE, "Loaded TerrainQuad {0} from TerrainQuadGrid", q.getName());
public Material getMaterial() { return getMaterial(null); }
public Material getMaterial(Vector3f worldLocation) { // get the material from one of the children. They all share the same material if (children != null) { for (int i = children.size(); --i >= 0;) { Spatial child = children.get(i); if (child instanceof TerrainQuad) { return ((TerrainQuad)child).getMaterial(worldLocation); } else if (child instanceof TerrainPatch) { return ((TerrainPatch)child).getMaterial(); } } } return null; }
public void randomizeHeightMap() { if(terrain != null) { try { HillHeightMap heightmap = new HillHeightMap(513, 2000, 25, 100, (long)((byte)100 * Math.random())); Material mat = terrain.getMaterial(); Vector3f scale = terrain.getLocalScale(); Vector3f trans = terrain.getLocalTranslation(); rootNode.detachChildNamed("Terrain"); terrain = new TerrainQuad("Terrain", 65, 513, heightmap.getHeightMap()); terrain.setLocalTranslation(trans); terrain.setLocalScale(scale); terrain.setMaterial(mat); terrain.setShadowMode(ShadowMode.Receive); rootNode.attachChild(terrain); } catch(Exception ex) { ex.printStackTrace(); } } }
q = gridTileLoader.getTerrainQuadAt(quadCell); if(q.getMaterial()==null) q.setMaterial(material.clone()); log.log(Level.FINE, "Loaded TerrainQuad {0} from TerrainQuadGrid", q.getName());