當前位置: 首頁>>代碼示例>>Java>>正文


Java HeightMap類代碼示例

本文整理匯總了Java中com.jme3.terrain.heightmap.HeightMap的典型用法代碼示例。如果您正苦於以下問題:Java HeightMap類的具體用法?Java HeightMap怎麽用?Java HeightMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


HeightMap類屬於com.jme3.terrain.heightmap包,在下文中一共展示了HeightMap類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import com.jme3.terrain.heightmap.HeightMap; //導入依賴的package包/類
public void run() {
    for (int i = centerOnly ? 1 : 0; i < (centerOnly ? 3 : 4); i++) {
        for (int j = centerOnly ? 1 : 0; j < (centerOnly ? 3 : 4); j++) {
            Vector3f temp = location.add(quadIndex[i * 4 + j]);
            if (cache.get(temp) == null) {
                HeightMap heightMapAt = heightMapGrid.getHeightMapAt(temp);
                TerrainQuad q = new TerrainQuad(getName() + "Quad" + temp, patchSize, quadSize, heightMapAt == null ? null : heightMapAt.getHeightMap(), lodCalculatorFactory);
                Material mat = material.clone();
                for (TerrainGridListener l : listeners.values()) {
                    mat = l.tileLoaded(mat, temp);
                }
                q.setMaterial(mat);
                cache.put(temp, q);
            }
        }
    }

}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:19,代碼來源:TerrainGrid.java

示例2: getHeightMapAt

import com.jme3.terrain.heightmap.HeightMap; //導入依賴的package包/類
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;
}
 
開發者ID:chototsu,項目名稱:MikuMikuStudio,代碼行數:14,代碼來源:FractalTileLoader.java

示例3: getTerrainQuadAt

import com.jme3.terrain.heightmap.HeightMap; //導入依賴的package包/類
public TerrainQuad getTerrainQuadAt(Vector3f location) {
    HeightMap heightMapAt = getHeightMapAt(location);
    TerrainQuad q = new TerrainQuad("Quad" + location, patchSize, quadSize, heightMapAt == null ? null : heightMapAt.getHeightMap());
    return q;
}
 
開發者ID:chototsu,項目名稱:MikuMikuStudio,代碼行數:6,代碼來源:FractalTileLoader.java

示例4: run

import com.jme3.terrain.heightmap.HeightMap; //導入依賴的package包/類
/**
 * This is executed if the camera has moved into a new CameraCell and will load in
 * the new TerrainQuad tiles to be children of this TerrainGrid parent.
 * It will first check the LRU cache to see if the terrain tile is already there,
 * if it is not there, it will load it in and then cache that tile.
 * The terrain tiles get added to the quad tree back on the OGL thread using the
 * attachQuadAt() method. It also resets any cached values in TerrainQuad (such as
 * neighbours).
 */
public void run() {
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            int quadIdx = i * 4 + j;
            final Vector3f quadCell = location.add(quadIndex[quadIdx]);
            TerrainQuad q = cache.get(quadCell);
            if (q == null) {
                if (heightMapGrid != null) {
                    // create the new Quad since it doesn't exist
                    HeightMap heightMapAt = heightMapGrid.getHeightMapAt(quadCell);
                    q = new TerrainQuad(getName() + "Quad" + quadCell, patchSize, quadSize, heightMapAt == null ? null : heightMapAt.getHeightMap());
                    q.setMaterial(material.clone());
                    log.log(Level.FINE, "Loaded TerrainQuad {0} from HeightMapGrid", q.getName());
                } else if (gridTileLoader != null) {
                    q = gridTileLoader.getTerrainQuadAt(quadCell);
                    // only clone the material to the quad if it doesn't have a material of its own
                    if(q.getMaterial()==null) q.setMaterial(material.clone());
                    log.log(Level.FINE, "Loaded TerrainQuad {0} from TerrainQuadGrid", q.getName());
                }
            }
            cache.put(quadCell, q);

            
            final int quadrant = getQuadrant(quadIdx);
            final TerrainQuad newQuad = q;
            
            if (isCenter(quadIdx)) {
                // if it should be attached as a child right now, attach it
                getControl(UpdateControl.class).enqueue(new Callable() {
                    // back on the OpenGL thread:
                    public Object call() throws Exception {
                        if (newQuad.getParent() != null) {
                            attachQuadAt(newQuad, quadrant, quadCell, true);
                        }
                        else {
                            attachQuadAt(newQuad, quadrant, quadCell, false);
                        }
                        return null;
                    }
                });
            } else {
                getControl(UpdateControl.class).enqueue(new Callable() {
                    public Object call() throws Exception {
                        removeQuad(newQuad);
                        return null;
                    }
                });
            }
        }
    }

    getControl(UpdateControl.class).enqueue(new Callable() {
            // back on the OpenGL thread:
            public Object call() throws Exception {
                for (Spatial s : getChildren()) {
                    if (s instanceof TerrainQuad) {
                        TerrainQuad tq = (TerrainQuad)s;
                        tq.resetCachedNeighbours();
                    }
                }
                System.out.println("fixed normals "+location.clone().mult(size));
                setNeedToRecalculateNormals();
                return null;
            }
    });
}
 
開發者ID:chototsu,項目名稱:MikuMikuStudio,代碼行數:76,代碼來源:TerrainGrid.java


注:本文中的com.jme3.terrain.heightmap.HeightMap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。