use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class AssetLinkNode method read.
@Override
public void read(JmeImporter e) throws IOException {
super.read(e);
InputCapsule capsule = e.getCapsule(this);
BinaryImporter importer = BinaryImporter.getInstance();
AssetManager loaderManager = e.getAssetManager();
assetLoaderKeys = (ArrayList<ModelKey>) capsule.readSavableArrayList("assetLoaderKeyList", new ArrayList<ModelKey>());
for (Iterator<ModelKey> it = assetLoaderKeys.iterator(); it.hasNext(); ) {
ModelKey modelKey = it.next();
AssetInfo info = loaderManager.locateAsset(modelKey);
Spatial child = null;
if (info != null) {
child = (Spatial) importer.load(info);
}
if (child != null) {
child.parent = this;
children.add(child);
assetChildren.put(modelKey, child);
} else {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot locate {0} for asset link node {1}", new Object[] { modelKey, key });
}
}
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class StaticPassLightingLogic method makeCurrent.
@Override
public Shader makeCurrent(AssetManager assetManager, RenderManager renderManager, EnumSet<Caps> rendererCaps, LightList lights, DefineList defines) {
// TODO: if it ever changes that render isn't called
// right away with the same geometry after makeCurrent, it would be
// a problem.
// Do a radix sort.
tempDirLights.clear();
tempPointLights.clear();
tempSpotLights.clear();
for (Light light : lights) {
switch(light.getType()) {
case Directional:
tempDirLights.add((DirectionalLight) light);
break;
case Point:
tempPointLights.add((PointLight) light);
break;
case Spot:
tempSpotLights.add((SpotLight) light);
break;
}
}
defines.set(numDirLightsDefineId, tempDirLights.size());
defines.set(numPointLightsDefineId, tempPointLights.size());
defines.set(numSpotLightsDefineId, tempSpotLights.size());
return techniqueDef.getShader(assetManager, rendererCaps, defines);
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class CubeField method createFirstCube.
private Geometry createFirstCube() {
Vector3f loc = player.getLocalTranslation();
loc.addLocal(4, 0, 0);
Box b = new Box(1, 1, 1);
Geometry geom = new Geometry("Box", b);
geom.setLocalTranslation(loc);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
geom.setMaterial(mat);
return geom;
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class CubeField method randomizeCube.
/**
* Randomly Places a cube on the map between 30 and 90 paces away from player
*/
private void randomizeCube() {
Geometry cube = fcube.clone();
int playerX = (int) player.getLocalTranslation().getX();
int playerZ = (int) player.getLocalTranslation().getZ();
// float x = FastMath.nextRandomInt(playerX + difficulty + 10, playerX + difficulty + 150);
float x = FastMath.nextRandomInt(playerX + difficulty + 30, playerX + difficulty + 90);
float z = FastMath.nextRandomInt(playerZ - difficulty - 50, playerZ + difficulty + 50);
cube.getLocalTranslation().set(x, 0, z);
// playerX+difficulty+30,playerX+difficulty+90
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
if (!solidBox) {
mat.getAdditionalRenderState().setWireframe(true);
}
mat.setColor("Color", obstacleColors.get(FastMath.nextRandomInt(0, obstacleColors.size() - 1)));
cube.setMaterial(mat);
rootNode.attachChild(cube);
cubeField.add(cube);
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class CubeField method createPlayer.
private Node createPlayer() {
Dome b = new Dome(Vector3f.ZERO, 10, 100, 1);
Geometry playerMesh = new Geometry("Box", b);
playerMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
playerMaterial.setColor("Color", ColorRGBA.Red);
playerMesh.setMaterial(playerMaterial);
playerMesh.setName("player");
Box floor = new Box(100, 0, 100);
Geometry floorMesh = new Geometry("Box", floor);
Vector3f translation = Vector3f.ZERO.add(playerMesh.getLocalTranslation().getX(), playerMesh.getLocalTranslation().getY() - 1, 0);
floorMesh.setLocalTranslation(translation);
floorMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
floorMaterial.setColor("Color", ColorRGBA.LightGray);
floorMesh.setMaterial(floorMaterial);
floorMesh.setName("floor");
Node playerNode = new Node();
playerNode.attachChild(playerMesh);
playerNode.attachChild(floorMesh);
return playerNode;
}
Aggregations