normen made me do it!
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8712 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
4e34217111
commit
2253690024
@ -152,6 +152,14 @@ public interface Terrain {
|
|||||||
*/
|
*/
|
||||||
public void generateEntropy(ProgressMonitor monitor);
|
public void generateEntropy(ProgressMonitor monitor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the material that this terrain uses.
|
||||||
|
* If it uses many materials, just return the one you think is best.
|
||||||
|
* For TerrainQuads this is sufficient. For TerrainGrid you want to call
|
||||||
|
* getMaterial(Vector3f) instead.
|
||||||
|
*/
|
||||||
|
public Material getMaterial();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the material that this terrain uses.
|
* Returns the material that this terrain uses.
|
||||||
* Terrain can have different materials in different locations.
|
* Terrain can have different materials in different locations.
|
||||||
|
@ -378,6 +378,10 @@ public class TerrainQuad extends Node implements Terrain {
|
|||||||
return (getParent() != null && !(getParent() instanceof TerrainQuad) );
|
return (getParent() != null && !(getParent() instanceof TerrainQuad) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Material getMaterial() {
|
||||||
|
return getMaterial(null);
|
||||||
|
}
|
||||||
|
|
||||||
public Material getMaterial(Vector3f worldLocation) {
|
public Material getMaterial(Vector3f worldLocation) {
|
||||||
// get the material from one of the children. They all share the same material
|
// get the material from one of the children. They all share the same material
|
||||||
if (children != null) {
|
if (children != null) {
|
||||||
|
@ -197,7 +197,7 @@ public class TerrainGridAlphaMapTest extends SimpleApplication {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
alpha = assetManager.loadTexture("TerrainAlphaTest/alpha_default.png");
|
alpha = assetManager.loadTexture("TerrainAlphaTest/alpha_default.png");
|
||||||
}
|
}
|
||||||
quad.getMaterial(null).setTexture("AlphaMap", alpha);
|
quad.getMaterial().setTexture("AlphaMap", alpha);
|
||||||
if (usePhysics) {
|
if (usePhysics) {
|
||||||
quad.addControl(new RigidBodyControl(new HeightfieldCollisionShape(quad.getHeightMap(), terrain.getLocalScale()), 0));
|
quad.addControl(new RigidBodyControl(new HeightfieldCollisionShape(quad.getHeightMap(), terrain.getLocalScale()), 0));
|
||||||
bulletAppState.getPhysicsSpace().add(quad);
|
bulletAppState.getPhysicsSpace().add(quad);
|
||||||
|
@ -335,7 +335,7 @@ public class TerrainEditorController implements NodeListener {
|
|||||||
if (terrain == null)
|
if (terrain == null)
|
||||||
return 1f;
|
return 1f;
|
||||||
MatParam matParam = null;
|
MatParam matParam = null;
|
||||||
matParam = terrain.getMaterial(null).getParam("DiffuseMap_"+layer+"_scale");
|
matParam = terrain.getMaterial().getParam("DiffuseMap_"+layer+"_scale");
|
||||||
if (matParam == null)
|
if (matParam == null)
|
||||||
return -1f;
|
return -1f;
|
||||||
return (Float) matParam.getValue();
|
return (Float) matParam.getValue();
|
||||||
@ -367,7 +367,7 @@ public class TerrainEditorController implements NodeListener {
|
|||||||
Terrain terrain = (Terrain) getTerrain(null);
|
Terrain terrain = (Terrain) getTerrain(null);
|
||||||
if (terrain == null)
|
if (terrain == null)
|
||||||
return;
|
return;
|
||||||
terrain.getMaterial(null).setFloat("DiffuseMap_"+layer+"_scale", scale);
|
terrain.getMaterial().setFloat("DiffuseMap_"+layer+"_scale", scale);
|
||||||
setNeedsSave(true);
|
setNeedsSave(true);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@ -397,9 +397,9 @@ public class TerrainEditorController implements NodeListener {
|
|||||||
return null;
|
return null;
|
||||||
MatParam matParam = null;
|
MatParam matParam = null;
|
||||||
if (layer == 0)
|
if (layer == 0)
|
||||||
matParam = terrain.getMaterial(null).getParam("DiffuseMap");
|
matParam = terrain.getMaterial().getParam("DiffuseMap");
|
||||||
else
|
else
|
||||||
matParam = terrain.getMaterial(null).getParam("DiffuseMap_"+layer);
|
matParam = terrain.getMaterial().getParam("DiffuseMap_"+layer);
|
||||||
|
|
||||||
if (matParam == null || matParam.getValue() == null) {
|
if (matParam == null || matParam.getValue() == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -430,11 +430,11 @@ public class TerrainEditorController implements NodeListener {
|
|||||||
return null;
|
return null;
|
||||||
MatParam matParam = null;
|
MatParam matParam = null;
|
||||||
if (alphaLayer == 0)
|
if (alphaLayer == 0)
|
||||||
matParam = terrain.getMaterial(null).getParam("AlphaMap");
|
matParam = terrain.getMaterial().getParam("AlphaMap");
|
||||||
else if(alphaLayer == 1)
|
else if(alphaLayer == 1)
|
||||||
matParam = terrain.getMaterial(null).getParam("AlphaMap_1");
|
matParam = terrain.getMaterial().getParam("AlphaMap_1");
|
||||||
else if(alphaLayer == 2)
|
else if(alphaLayer == 2)
|
||||||
matParam = terrain.getMaterial(null).getParam("AlphaMap_2");
|
matParam = terrain.getMaterial().getParam("AlphaMap_2");
|
||||||
|
|
||||||
if (matParam == null || matParam.getValue() == null) {
|
if (matParam == null || matParam.getValue() == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -471,9 +471,9 @@ public class TerrainEditorController implements NodeListener {
|
|||||||
if (terrain == null)
|
if (terrain == null)
|
||||||
return;
|
return;
|
||||||
if (layer == 0)
|
if (layer == 0)
|
||||||
terrain.getMaterial(null).setTexture("DiffuseMap", texture);
|
terrain.getMaterial().setTexture("DiffuseMap", texture);
|
||||||
else
|
else
|
||||||
terrain.getMaterial(null).setTexture("DiffuseMap_"+layer, texture);
|
terrain.getMaterial().setTexture("DiffuseMap_"+layer, texture);
|
||||||
|
|
||||||
setNeedsSave(true);
|
setNeedsSave(true);
|
||||||
} else {
|
} else {
|
||||||
@ -522,9 +522,9 @@ public class TerrainEditorController implements NodeListener {
|
|||||||
if (terrain == null)
|
if (terrain == null)
|
||||||
return;
|
return;
|
||||||
if (layer == 0)
|
if (layer == 0)
|
||||||
terrain.getMaterial(null).clearParam("DiffuseMap");
|
terrain.getMaterial().clearParam("DiffuseMap");
|
||||||
else
|
else
|
||||||
terrain.getMaterial(null).clearParam("DiffuseMap_"+layer);
|
terrain.getMaterial().clearParam("DiffuseMap_"+layer);
|
||||||
|
|
||||||
setNeedsSave(true);
|
setNeedsSave(true);
|
||||||
}
|
}
|
||||||
@ -535,9 +535,9 @@ public class TerrainEditorController implements NodeListener {
|
|||||||
if (terrain == null)
|
if (terrain == null)
|
||||||
return;
|
return;
|
||||||
if (layer == 0)
|
if (layer == 0)
|
||||||
terrain.getMaterial(null).clearParam("NormalMap");
|
terrain.getMaterial().clearParam("NormalMap");
|
||||||
else
|
else
|
||||||
terrain.getMaterial(null).clearParam("NormalMap_"+layer);
|
terrain.getMaterial().clearParam("NormalMap_"+layer);
|
||||||
|
|
||||||
setNeedsSave(true);
|
setNeedsSave(true);
|
||||||
}
|
}
|
||||||
@ -553,9 +553,9 @@ public class TerrainEditorController implements NodeListener {
|
|||||||
return null;
|
return null;
|
||||||
MatParam matParam = null;
|
MatParam matParam = null;
|
||||||
if (layer == 0)
|
if (layer == 0)
|
||||||
matParam = terrain.getMaterial(null).getParam("NormalMap");
|
matParam = terrain.getMaterial().getParam("NormalMap");
|
||||||
else
|
else
|
||||||
matParam = terrain.getMaterial(null).getParam("NormalMap_"+layer);
|
matParam = terrain.getMaterial().getParam("NormalMap_"+layer);
|
||||||
|
|
||||||
if (matParam == null || matParam.getValue() == null) {
|
if (matParam == null || matParam.getValue() == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -616,18 +616,18 @@ public class TerrainEditorController implements NodeListener {
|
|||||||
if (texture == null) {
|
if (texture == null) {
|
||||||
// remove the texture if it is null
|
// remove the texture if it is null
|
||||||
if (layer == 0)
|
if (layer == 0)
|
||||||
terrain.getMaterial(null).clearParam("NormalMap");
|
terrain.getMaterial().clearParam("NormalMap");
|
||||||
else
|
else
|
||||||
terrain.getMaterial(null).clearParam("NormalMap_"+layer);
|
terrain.getMaterial().clearParam("NormalMap_"+layer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
texture.setWrap(WrapMode.Repeat);
|
texture.setWrap(WrapMode.Repeat);
|
||||||
|
|
||||||
if (layer == 0)
|
if (layer == 0)
|
||||||
terrain.getMaterial(null).setTexture("NormalMap", texture);
|
terrain.getMaterial().setTexture("NormalMap", texture);
|
||||||
else
|
else
|
||||||
terrain.getMaterial(null).setTexture("NormalMap_"+layer, texture);
|
terrain.getMaterial().setTexture("NormalMap_"+layer, texture);
|
||||||
|
|
||||||
setNeedsSave(true);
|
setNeedsSave(true);
|
||||||
} else {
|
} else {
|
||||||
@ -957,7 +957,7 @@ public class TerrainEditorController implements NodeListener {
|
|||||||
Terrain terrain = (Terrain) getTerrain(null);
|
Terrain terrain = (Terrain) getTerrain(null);
|
||||||
if (terrain == null)
|
if (terrain == null)
|
||||||
return false;
|
return false;
|
||||||
MatParam param = terrain.getMaterial(null).getParam("useTriPlanarMapping");
|
MatParam param = terrain.getMaterial().getParam("useTriPlanarMapping");
|
||||||
if (param != null)
|
if (param != null)
|
||||||
return (Boolean)param.getValue();
|
return (Boolean)param.getValue();
|
||||||
|
|
||||||
@ -992,7 +992,7 @@ public class TerrainEditorController implements NodeListener {
|
|||||||
Terrain terrain = (Terrain) getTerrain(null);
|
Terrain terrain = (Terrain) getTerrain(null);
|
||||||
if (terrain == null)
|
if (terrain == null)
|
||||||
return;
|
return;
|
||||||
terrain.getMaterial(null).setBoolean("useTriPlanarMapping", enabled);
|
terrain.getMaterial().setBoolean("useTriPlanarMapping", enabled);
|
||||||
|
|
||||||
float size = terrain.getTerrainSize();
|
float size = terrain.getTerrainSize();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user