com.jme3.terrain.heightmap.AbstractHeightMap Java Examples
The following examples show how to use
com.jme3.terrain.heightmap.AbstractHeightMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AddTerrainAction.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
protected Spatial generateTerrain(Node parent, final WizardDescriptor wizardDescriptor) throws IOException { org.openide.nodes.Node selectedNode = (org.openide.nodes.Node) wizardDescriptor.getProperty("main_node"); final Spatial spatial = selectedNode.getLookup().lookup(Spatial.class); String sceneName = selectedNode.getLookup().lookup(DataObject.class).getName(); int totalSize = (Integer) wizardDescriptor.getProperty("totalSize"); int patchSize = (Integer) wizardDescriptor.getProperty("patchSize"); int alphaTextureSize = (Integer) wizardDescriptor.getProperty("alphaTextureSize"); float[] heightmapData = null; AbstractHeightMap heightmap = (AbstractHeightMap) wizardDescriptor.getProperty("abstractHeightMap"); if (heightmap != null) { heightmap.load(); // can take a while heightmapData = heightmap.getHeightMap(); } return doCreateTerrain(parent, totalSize, patchSize, alphaTextureSize, heightmapData, sceneName, selectedNode); }
Example #2
Source File: FractalTileLoader.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private HeightMap getHeightMapAt(Vector3f location) { AbstractHeightMap heightmap = null; FloatBuffer buffer = this.base.getBuffer(location.x * (this.quadSize - 1), location.z * (this.quadSize - 1), 0, this.quadSize); float[] arr = buffer.array(); for (int i = 0; i < arr.length; i++) { arr[i] = arr[i] * this.heightScale; } heightmap = new FloatBufferHeightMap(buffer); heightmap.load(); return heightmap; }
Example #3
Source File: TerrainCollisionTest.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Before public void initQuad() { Texture heightMapImage = getAssetManager().loadTexture("Textures/Terrain/splat/mountains512.png"); AbstractHeightMap map = new ImageBasedHeightMap(heightMapImage.getImage(), 0.25f); map.load(); quad = new TerrainQuad("terrain", 65, 513, map.getHeightMap()); }
Example #4
Source File: FractalTileLoader.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private HeightMap getHeightMapAt(Vector3f location) { AbstractHeightMap heightmap = null; FloatBuffer buffer = this.base.getBuffer(location.x * (this.quadSize - 1), location.z * (this.quadSize - 1), 0, this.quadSize); float[] arr = buffer.array(); for (int i = 0; i < arr.length; i++) { arr[i] = arr[i] * this.heightScale; } heightmap = new FloatBufferHeightMap(buffer); heightmap.load(); return heightmap; }
Example #5
Source File: TerrainEditorTopComponent.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
protected void generateTerrain(final WizardDescriptor wizardDescriptor) { final Spatial node = selectedSpat.getLookup().lookup(Spatial.class); int totalSize = (Integer) wizardDescriptor.getProperty("totalSize"); int patchSize = (Integer) wizardDescriptor.getProperty("patchSize"); int alphaTextureSize = (Integer) wizardDescriptor.getProperty("alphaTextureSize"); float[] heightmapData = null; AbstractHeightMap heightmap = (AbstractHeightMap) wizardDescriptor.getProperty("abstractHeightMap"); if (heightmap != null) { heightmap.load(); // can take a while heightmapData = heightmap.getHeightMap(); } // eg. Scenes/newScene1.j3o String[] split1 = currentRequest.getWindowTitle().split("/"); String[] split2 = split1[split1.length - 1].split("\\."); Terrain terrain = null; try { terrain = editorController.createTerrain((Node) node, totalSize, patchSize, alphaTextureSize, heightmapData, split2[0], selectedSpat); } catch (IOException ex) { Exceptions.printStackTrace(ex); } addSaveNode(selectedSpat); editorController.setNeedsSave(true); editorController.enableTextureButtons(); reinitTextureTable(); // update the UI refreshSelected(); //createTerrainButton.setEnabled(false); // only let the user add one terrain }