use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class TestTangentSpace method simpleInitApp.
@Override
public void simpleInitApp() {
renderManager.setSinglePassLightBatchSize(2);
renderManager.setPreferredLightMode(TechniqueDef.LightMode.SinglePass);
initView();
Spatial s = assetManager.loadModel("Models/Test/BasicCubeLow.obj");
rootNode.attachChild(s);
Material m = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
m.setTexture("NormalMap", assetManager.loadTexture("Models/Test/Normal_pixel.png"));
Geometry g = (Geometry) s;
Geometry g2 = (Geometry) g.deepClone();
g2.move(5, 0, 0);
g.getParent().attachChild(g2);
g.setMaterial(m);
g2.setMaterial(m);
//Regular tangent generation (left geom)
TangentBinormalGenerator.generate(g2.getMesh(), true);
//MikkTSPace Tangent generation (right geom)
MikktspaceTangentGenerator.generate(g);
createDebugTangents(g2);
createDebugTangents(g);
inputManager.addListener(new ActionListener() {
@Override
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("toggleDebug") && isPressed) {
if (debugNode.getParent() == null) {
rootNode.attachChild(debugNode);
} else {
debugNode.removeFromParent();
}
}
}
}, "toggleDebug");
inputManager.addMapping("toggleDebug", new KeyTrigger(KeyInput.KEY_SPACE));
DirectionalLight dl = new DirectionalLight(new Vector3f(-1, -1, -1).normalizeLocal());
rootNode.addLight(dl);
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class TestChaseCamera method simpleInitApp.
public void simpleInitApp() {
// Load a teapot model
teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
Material mat_tea = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
teaGeom.setMaterial(mat_tea);
rootNode.attachChild(teaGeom);
// Load a floor model
Material mat_ground = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat_ground.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
Geometry ground = new Geometry("ground", new Quad(50, 50));
ground.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
ground.setLocalTranslation(-25, -1, 25);
ground.setMaterial(mat_ground);
rootNode.attachChild(ground);
// Disable the default first-person cam!
flyCam.setEnabled(false);
// Enable a chase cam
chaseCam = new ChaseCamera(cam, teaGeom, inputManager);
//Uncomment this to invert the camera's vertical rotation Axis
//chaseCam.setInvertVerticalAxis(true);
//Uncomment this to invert the camera's horizontal rotation Axis
//chaseCam.setInvertHorizontalAxis(true);
//Comment this to disable smooth camera motion
chaseCam.setSmoothMotion(true);
//Uncomment this to disable trailing of the camera
//WARNING, trailing only works with smooth motion enabled. It is true by default.
//chaseCam.setTrailingEnabled(false);
//Uncomment this to look 3 world units above the target
//chaseCam.setLookAtOffset(Vector3f.UNIT_Y.mult(3));
//Uncomment this to enable rotation when the middle mouse button is pressed (like Blender)
//WARNING : setting this trigger disable the rotation on right and left mouse button click
//chaseCam.setToggleRotationTrigger(new MouseButtonTrigger(MouseInput.BUTTON_MIDDLE));
//Uncomment this to set mutiple triggers to enable rotation of the cam
//Here spade bar and middle mouse button
//chaseCam.setToggleRotationTrigger(new MouseButtonTrigger(MouseInput.BUTTON_MIDDLE),new KeyTrigger(KeyInput.KEY_SPACE));
//registering inputs for target's movement
registerInput();
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class RefEnv method simpleUpdate.
@Override
public void simpleUpdate(float tpf) {
frame++;
if (frame == 2) {
final LightProbe probe = LightProbeFactory.makeProbe(stateManager.getState(EnvironmentCamera.class), rootNode, new JobProgressAdapter<LightProbe>() {
@Override
public void done(LightProbe result) {
System.err.println("Done rendering env maps");
tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(result.getPrefilteredEnvMap(), assetManager);
// guiNode.attachChild(tex);
rootNode.getChild("Scene").setCullHint(Spatial.CullHint.Dynamic);
}
});
((BoundingSphere) probe.getBounds()).setRadius(100);
rootNode.addLight(probe);
}
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class TestPBRLighting method simpleUpdate.
@Override
public void simpleUpdate(float tpf) {
frame++;
if (frame == 2) {
modelNode.removeFromParent();
final LightProbe probe = LightProbeFactory.makeProbe(stateManager.getState(EnvironmentCamera.class), rootNode, new JobProgressAdapter<LightProbe>() {
@Override
public void done(LightProbe result) {
System.err.println("Done rendering env maps");
tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(result.getPrefilteredEnvMap(), assetManager);
tex2 = EnvMapUtils.getCubeMapCrossDebugView(result.getIrradianceMap(), assetManager);
}
});
((BoundingSphere) probe.getBounds()).setRadius(100);
rootNode.addLight(probe);
//getStateManager().getState(EnvironmentManager.class).addEnvProbe(probe);
}
if (frame > 10 && modelNode.getParent() == null) {
rootNode.attachChild(modelNode);
}
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class AssetLinkNode method attachLinkedChildren.
/**
* Loads the linked children AssetKeys from the AssetManager and attaches them to the Node<br>
* If they are already attached, they will be reloaded.
* @param manager
*/
public void attachLinkedChildren(AssetManager manager) {
detachLinkedChildren();
for (Iterator<ModelKey> it = assetLoaderKeys.iterator(); it.hasNext(); ) {
ModelKey assetKey = it.next();
Spatial curChild = assetChildren.get(assetKey);
if (curChild != null) {
curChild.removeFromParent();
}
Spatial child = manager.loadAsset(assetKey);
attachChild(child);
assetChildren.put(assetKey, child);
}
}
Aggregations