use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class TestWalkingChar method createTerrain.
private void createTerrain() {
matRock = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
matRock.setBoolean("useTriPlanarMapping", false);
matRock.setBoolean("WardIso", true);
matRock.setTexture("AlphaMap", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
matRock.setTexture("DiffuseMap", grass);
matRock.setFloat("DiffuseMap_0_scale", 64);
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
dirt.setWrap(WrapMode.Repeat);
matRock.setTexture("DiffuseMap_1", dirt);
matRock.setFloat("DiffuseMap_1_scale", 16);
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
rock.setWrap(WrapMode.Repeat);
matRock.setTexture("DiffuseMap_2", rock);
matRock.setFloat("DiffuseMap_2_scale", 128);
Texture normalMap0 = assetManager.loadTexture("Textures/Terrain/splat/grass_normal.jpg");
normalMap0.setWrap(WrapMode.Repeat);
Texture normalMap1 = assetManager.loadTexture("Textures/Terrain/splat/dirt_normal.png");
normalMap1.setWrap(WrapMode.Repeat);
Texture normalMap2 = assetManager.loadTexture("Textures/Terrain/splat/road_normal.png");
normalMap2.setWrap(WrapMode.Repeat);
matRock.setTexture("NormalMap", normalMap0);
matRock.setTexture("NormalMap_1", normalMap2);
matRock.setTexture("NormalMap_2", normalMap2);
AbstractHeightMap heightmap = null;
try {
heightmap = new ImageBasedHeightMap(heightMapImage.getImage(), 0.25f);
heightmap.load();
} catch (Exception e) {
e.printStackTrace();
}
terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
List<Camera> cameras = new ArrayList<Camera>();
cameras.add(getCamera());
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
terrain.addControl(control);
terrain.setMaterial(matRock);
terrain.setLocalScale(new Vector3f(2, 2, 2));
terrainPhysicsNode = new RigidBodyControl(CollisionShapeFactory.createMeshShape(terrain), 0);
terrain.addControl(terrainPhysicsNode);
rootNode.attachChild(terrain);
getPhysicsSpace().add(terrainPhysicsNode);
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class TestMousePick method makeCube.
/** A cube object for target practice */
protected Geometry makeCube(String name, float x, float y, float z) {
Box box = new Box(1, 1, 1);
Geometry cube = new Geometry(name, box);
cube.setLocalTranslation(x, y, z);
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat1.setColor("Color", ColorRGBA.randomColor());
cube.setMaterial(mat1);
return cube;
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class TestMousePick method makeFloor.
/** A floor to show that the "shot" can go through several objects. */
protected Geometry makeFloor() {
Box box = new Box(15, .2f, 15);
Geometry floor = new Geometry("the Floor", box);
floor.setLocalTranslation(0, -4, -5);
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat1.setColor("Color", ColorRGBA.Gray);
floor.setMaterial(mat1);
return floor;
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class TestWalkingChar method setupFilter.
private void setupFilter() {
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
BloomFilter bloom = new BloomFilter(BloomFilter.GlowMode.Objects);
fpp.addFilter(bloom);
viewPort.addProcessor(fpp);
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class FbxImage method createImage.
private Image createImage() {
AssetManager assetManager = scene.assetManager;
Image image = null;
if (filename != null) {
// Try load by absolute path
File file = new File(filename);
if (file.exists() && file.isFile()) {
File dir = new File(file.getParent());
String locatorPath = dir.getAbsolutePath();
Texture tex = null;
try {
assetManager.registerLocator(locatorPath, com.jme3.asset.plugins.FileLocator.class);
tex = assetManager.loadTexture(file.getName());
} catch (Exception e) {
} finally {
assetManager.unregisterLocator(locatorPath, com.jme3.asset.plugins.FileLocator.class);
}
if (tex != null)
image = tex.getImage();
}
}
if (image == null && relativeFilename != null) {
// Try load by relative path
File dir = new File(scene.sceneFolderName);
String locatorPath = dir.getAbsolutePath();
Texture tex = null;
try {
assetManager.registerLocator(locatorPath, com.jme3.asset.plugins.FileLocator.class);
tex = assetManager.loadTexture(relativeFilename);
} catch (Exception e) {
} finally {
assetManager.unregisterLocator(locatorPath, com.jme3.asset.plugins.FileLocator.class);
}
if (tex != null)
image = tex.getImage();
}
if (image == null && content != null) {
// Try load from content
String filename = null;
if (this.filename != null)
filename = new File(this.filename).getName();
if (filename != null && this.relativeFilename != null)
filename = this.relativeFilename;
// Filename is required to aquire asset loader by extension
if (filename != null) {
String locatorPath = scene.sceneFilename;
// Unique path
filename = scene.sceneFilename + File.separatorChar + filename;
Texture tex = null;
try {
assetManager.registerLocator(locatorPath, ContentTextureLocator.class);
tex = assetManager.loadTexture(new ContentTextureKey(filename, content));
} catch (Exception e) {
} finally {
assetManager.unregisterLocator(locatorPath, ContentTextureLocator.class);
}
if (tex != null)
image = tex.getImage();
}
}
if (image == null) {
// Try to load from files near
if (relativeFilename != null) {
String[] split = relativeFilename.split("[\\\\/]");
String filename = split[split.length - 1];
Texture tex = null;
try {
tex = assetManager.loadTexture(new ContentTextureKey(scene.currentAssetInfo.getKey().getFolder() + filename, content));
} catch (Exception e) {
}
if (tex != null)
image = tex.getImage();
}
}
if (image == null)
return new Image(Image.Format.RGB8, 1, 1, BufferUtils.createByteBuffer((int) ((long) 1 * (long) 1 * (long) Image.Format.RGB8.getBitsPerPixel() / 8L)), ColorSpace.Linear);
return image;
}
Aggregations