本文整理汇总了Java中com.jme3.terrain.geomipmap.TerrainLodControl类的典型用法代码示例。如果您正苦于以下问题:Java TerrainLodControl类的具体用法?Java TerrainLodControl怎么用?Java TerrainLodControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TerrainLodControl类属于com.jme3.terrain.geomipmap包,在下文中一共展示了TerrainLodControl类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSheet
import com.jme3.terrain.geomipmap.TerrainLodControl; //导入依赖的package包/类
@Override
protected Sheet createSheet() {
Sheet sheet = super.createSheet();
Sheet.Set set = Sheet.createPropertiesSet();
set.setDisplayName("TerrainLodControl");
set.setName(TerrainLodControl.class.getName());
TerrainLodControl obj = terrainLodControl;
if (obj == null) {
return sheet;
}
set.put(makeProperty(obj, boolean.class, "isEnabled", "setEnabled", "Enabled"));
sheet.put(set);
return sheet;
}
示例2: loadTerrain
import com.jme3.terrain.geomipmap.TerrainLodControl; //导入依赖的package包/类
public void loadTerrain(TerrainDefinition terrainDefinition) {
Texture grass = assetManager.loadTexture(terrainDefinition.tx1().path());
grass.setWrap(Texture.WrapMode.Repeat);
Texture water = assetManager.loadTexture(terrainDefinition.tx2().path());
water.setWrap(Texture.WrapMode.Repeat);
Texture land = assetManager.loadTexture(terrainDefinition.tx3().path());
land.setWrap(Texture.WrapMode.Repeat);
float scale = 100;
Material mat_terrain = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
mat_terrain.setTexture("AlphaMap", assetManager.loadTexture("Maps/Adria/AdriaSmall_alpha.png"));
mat_terrain.setTexture("DiffuseMap", texture(terrainDefinition.tx1().path()));
mat_terrain.setFloat("DiffuseMap_0_scale", terrainDefinition.tx1().scale()); //playing with scales
mat_terrain.setTexture("DiffuseMap_2", texture(terrainDefinition.tx2().path()));
mat_terrain.setFloat("DiffuseMap_2_scale", terrainDefinition.tx2().scale());
mat_terrain.setTexture("DiffuseMap_1", texture(terrainDefinition.tx3().path()));
mat_terrain.setFloat("DiffuseMap_1_scale", terrainDefinition.tx3().scale());
int patchSize = 17;
terrain = terrainDefinition.heightMapPath().map(m -> assetManager.loadTexture(m)
.getImage()).map(i -> new ImageBasedHeightMap(i, 10f))
.map(hm -> {
hm.load();
return new TerrainQuad("Terrain", patchSize, hm.getSize()+1, hm.getHeightMap());
}).map(tq -> {
tq.setMaterial(mat_terrain);
tq.setLocalScale(scale, 1f, scale); // 1pixel 1m * scale * m
tq.addControl(new TerrainLodControl(tq, camera.testCamera()));
tq.setShadowMode(RenderQueue.ShadowMode.Receive);
setLocation(tq,99,512,2048,scale);
rootNode.attachChild(tq);
return tq;
});
}
示例3: enableLodControl
import com.jme3.terrain.geomipmap.TerrainLodControl; //导入依赖的package包/类
/**
* Re-attach the camera to the LOD control.
* Called when the scene is opened and will only
* update the control if there is already a terrain present in
* the scene.
*/
public static void enableLodControl(Camera camera, Node rootNode) {
Terrain terrain = (Terrain) findTerrain(rootNode);
if (terrain == null)
return;
TerrainLodControl control = ((Spatial)terrain).getControl(TerrainLodControl.class);
if (control != null) {
control.setCamera(camera);
}
}
示例4: JmeTerrainLodControl
import com.jme3.terrain.geomipmap.TerrainLodControl; //导入依赖的package包/类
public JmeTerrainLodControl(TerrainLodControl control, Children children) {
super(children);
getLookupContents().add(control);
getLookupContents().add(this);
this.terrainLodControl = control;
this.control = control;
setName("TerrainLodControl");
}
示例5: createNodes
import com.jme3.terrain.geomipmap.TerrainLodControl; //导入依赖的package包/类
@Override
public org.openide.nodes.Node[] createNodes(Object key, DataObject key2, boolean cookie) {
TerrainLodControlChildren children = new TerrainLodControlChildren((TerrainLodControl) key);
children.setReadOnly(cookie);
children.setDataObject(key2);
return new org.openide.nodes.Node[]{new JmeTerrainLodControl((TerrainLodControl) key, children).setReadOnly(cookie)};
}
示例6: JmeDistanceLodCalculator
import com.jme3.terrain.geomipmap.TerrainLodControl; //导入依赖的package包/类
public JmeDistanceLodCalculator(TerrainLodControl lodControl, DistanceLodCalculator lodCalculator, DataObject dataObject) {
super(Children.LEAF);
this.lodControl=lodControl;
this.lodCalculator = lodCalculator;
this.dataObject = dataObject;
getLookupContents().add(lodCalculator);
getLookupContents().add(this);
setName("DistanceLodCalculator");
}
示例7: JmeTerrainLodControl
import com.jme3.terrain.geomipmap.TerrainLodControl; //导入依赖的package包/类
public JmeTerrainLodControl(TerrainLodControl control, Children children) {
super(children);
getLookupContents().add(control);
getLookupContents().add(this);
this.terrainLodControl = control;
setName("TerrainLodControl");
}
示例8: simpleInitApp
import com.jme3.terrain.geomipmap.TerrainLodControl; //导入依赖的package包/类
@Override
public void simpleInitApp() {
loadHintText();
initCrossHairs();
setupKeys();
// First, we load up our textures and the heightmap texture for the terrain
// TERRAIN TEXTURE material
matTerrain = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
matTerrain.setBoolean("useTriPlanarMapping", false);
matTerrain.setBoolean("WardIso", true);
// ALPHA map (for splat textures)
matTerrain.setTexture("AlphaMap", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
// GRASS texture
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
matTerrain.setTexture("DiffuseMap", grass);
matTerrain.setFloat("DiffuseMap_0_scale", grassScale);
// DIRT texture
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
dirt.setWrap(WrapMode.Repeat);
matTerrain.setTexture("DiffuseMap_1", dirt);
matTerrain.setFloat("DiffuseMap_1_scale", dirtScale);
// ROCK texture
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
rock.setWrap(WrapMode.Repeat);
matTerrain.setTexture("DiffuseMap_2", rock);
matTerrain.setFloat("DiffuseMap_2_scale", rockScale);
// WIREFRAME material
matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
matWire.getAdditionalRenderState().setWireframe(true);
matWire.setColor("Color", ColorRGBA.Green);
// CREATE THE TERRAIN
terrain = new TerrainQuad("terrain", 65, 513, null);
List<Camera> cameras = new ArrayList<Camera>();
cameras.add(getCamera());
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
terrain.addControl(control);
terrain.setMaterial(matTerrain);
terrain.setLocalTranslation(0, -100, 0);
terrain.setLocalScale(2f, 1f, 2f);
rootNode.attachChild(terrain);
DirectionalLight light = new DirectionalLight();
light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize());
rootNode.addLight(light);
AmbientLight ambLight = new AmbientLight();
ambLight.setColor(new ColorRGBA(1f, 1f, 0.8f, 0.2f));
rootNode.addLight(ambLight);
cam.setLocation(new Vector3f(0, 10, -10));
cam.lookAtDirection(new Vector3f(0, -1.5f, -1).normalizeLocal(), Vector3f.UNIT_Y);
}
示例9: getExplorerObjectClass
import com.jme3.terrain.geomipmap.TerrainLodControl; //导入依赖的package包/类
@Override
public Class getExplorerObjectClass() {
return TerrainLodControl.class;
}
示例10: TerrainLodControlChildren
import com.jme3.terrain.geomipmap.TerrainLodControl; //导入依赖的package包/类
public TerrainLodControlChildren(TerrainLodControl control) {
this.control = control;
}
示例11: doCreateTerrain
import com.jme3.terrain.geomipmap.TerrainLodControl; //导入依赖的package包/类
protected Spatial doCreateTerrain(Node parent,
int totalSize,
int patchSize,
int alphaTextureSize,
float[] heightmapData,
String sceneName,
org.openide.nodes.Node selectedNode) throws IOException
{
final ProjectAssetManager manager = selectedNode.getLookup().lookup(ProjectAssetManager.class);
Terrain terrain = new TerrainQuad("terrain-"+sceneName, patchSize, totalSize, heightmapData); //TODO make this pluggable for different Terrain implementations
com.jme3.material.Material mat = new com.jme3.material.Material(manager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
String assetFolder = "";
if (manager != null && manager instanceof ProjectAssetManager)
assetFolder = ((ProjectAssetManager)manager).getAssetFolderName();
// write out 3 alpha blend images
for (int i=0; i<TerrainEditorController.NUM_ALPHA_TEXTURES; i++) {
BufferedImage alphaBlend = new BufferedImage(alphaTextureSize, alphaTextureSize, BufferedImage.TYPE_INT_ARGB);
if (i == 0) {
// the first alpha level should be opaque so we see the first texture over the whole terrain
for (int h=0; h<alphaTextureSize; h++)
for (int w=0; w<alphaTextureSize; w++)
alphaBlend.setRGB(w, h, 0x00FF0000);//argb
}
File alphaFolder = new File(assetFolder+"/Textures/terrain-alpha/");
if (!alphaFolder.exists())
alphaFolder.mkdir();
String alphaBlendFileName = "/Textures/terrain-alpha/"+sceneName+"-"+((Node)terrain).getName()+"-alphablend"+i+".png";
File alphaImageFile = new File(assetFolder+alphaBlendFileName);
ImageIO.write(alphaBlend, "png", alphaImageFile);
Texture tex = manager.loadAsset(new TextureKey(alphaBlendFileName, false));
if (i == 0)
mat.setTexture("AlphaMap", tex);
else if (i == 1)
mat.setTexture("AlphaMap_1", tex);
else if (i == 2)
mat.setTexture("AlphaMap_2", tex);
}
Texture defaultTexture = manager.loadTexture(TerrainEditorController.DEFAULT_TERRAIN_TEXTURE);
// copy the default texture to the assets folder if it doesn't exist there yet
String dirtTextureName = "/Textures/dirt.jpg";
File dirtTextureFile = new File(assetFolder+dirtTextureName);
if (!dirtTextureFile.exists()) {
BufferedImage bi = ImageToAwt.convert(defaultTexture.getImage(), false, true, 0);
ImageIO.write(bi, "jpg", dirtTextureFile);
}
// give the first layer default texture
Texture dirtTexture = manager.loadTexture(dirtTextureName);
dirtTexture.setWrap(WrapMode.Repeat);
mat.setTexture("DiffuseMap", dirtTexture);
mat.setFloat("DiffuseMap_0_scale", TerrainEditorController.DEFAULT_TEXTURE_SCALE);
mat.setBoolean("WardIso", true);
((Node)terrain).setMaterial(mat);
((Node)terrain).setModelBound(new BoundingBox());
((Node)terrain).updateModelBound();
((Node)terrain).setLocalTranslation(0, 0, 0);
((Node)terrain).setLocalScale(1f, 1f, 1f);
// add the lod control
TerrainLodControl control = new TerrainLodControl(terrain, SceneApplication.getApplication().getCamera());
control.setLodCalculator(new DistanceLodCalculator(patchSize, 2.7f));
((Node)terrain).addControl(control);
parent.attachChild((Node)terrain);
//setNeedsSave(true);
//addSpatialUndo(parent, (Node)terrain, jmeNodeParent);
return (Spatial)terrain;
}
示例12: getExplorerObjectClass
import com.jme3.terrain.geomipmap.TerrainLodControl; //导入依赖的package包/类
public Class getExplorerObjectClass() {
return TerrainLodControl.class;
}