use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class TestOgreConvert method simpleInitApp.
@Override
public void simpleInitApp() {
Spatial ogreModel = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
DirectionalLight dl = new DirectionalLight();
dl.setColor(ColorRGBA.White);
dl.setDirection(new Vector3f(0, -1, -1).normalizeLocal());
rootNode.addLight(dl);
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BinaryExporter exp = new BinaryExporter();
exp.save(ogreModel, baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
BinaryImporter imp = new BinaryImporter();
imp.setAssetManager(assetManager);
Node ogreModelReloaded = (Node) imp.load(bais, null, null);
AnimControl control = ogreModelReloaded.getControl(AnimControl.class);
AnimChannel chan = control.createChannel();
chan.setAnim("Walk");
rootNode.attachChild(ogreModelReloaded);
} catch (IOException ex) {
ex.printStackTrace();
}
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class TestPhysicsRayCast method simpleInitApp.
@Override
public void simpleInitApp() {
stateManager.attach(bulletAppState);
initCrossHair();
Spatial s = assetManager.loadModel("Models/Elephant/Elephant.mesh.xml");
s.setLocalScale(0.1f);
CollisionShape collisionShape = CollisionShapeFactory.createMeshShape(s);
Node n = new Node("elephant");
n.addControl(new RigidBodyControl(collisionShape, 1));
n.getControl(RigidBodyControl.class).setKinematic(true);
bulletAppState.getPhysicsSpace().add(n);
rootNode.attachChild(n);
bulletAppState.setDebugEnabled(true);
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class TestWalkingChar method collision.
public void collision(PhysicsCollisionEvent event) {
if (event.getObjectA() instanceof BombControl) {
final Spatial node = event.getNodeA();
effect.killAllParticles();
effect.setLocalTranslation(node.getLocalTranslation());
effect.emitAllParticles();
} else if (event.getObjectB() instanceof BombControl) {
final Spatial node = event.getNodeB();
effect.killAllParticles();
effect.setLocalTranslation(node.getLocalTranslation());
effect.emitAllParticles();
}
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class TestMousePick method makeCharacter.
protected Spatial makeCharacter() {
// load a character from jme3test-test-data
Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
golem.scale(0.5f);
golem.setLocalTranslation(-1.0f, -1.5f, -0.6f);
// We must add a light to make the model visible
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal());
golem.addLight(sun);
return golem;
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class FbxNode method tryCreateGeometry.
private Spatial tryCreateGeometry(int materialIndex, Mesh jmeMesh, boolean single) {
// Map meshes without material indices to material 0.
if (materialIndex == -1) {
materialIndex = 0;
}
Material jmeMat;
if (materialIndex >= materials.size()) {
// Material index does not exist. Create default material.
jmeMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
jmeMat.setReceivesShadows(true);
} else {
FbxMaterial fbxMat = materials.get(materialIndex);
jmeMat = fbxMat.getJmeObject();
}
String geomName = getName();
if (single) {
geomName += "-submesh";
} else {
geomName += "-mat-" + materialIndex + "-submesh";
}
Spatial spatial = new Geometry(geomName, jmeMesh);
spatial.setMaterial(jmeMat);
if (jmeMat.isTransparent()) {
spatial.setQueueBucket(Bucket.Transparent);
}
if (jmeMat.isReceivesShadows()) {
spatial.setShadowMode(ShadowMode.Receive);
}
spatial.updateModelBound();
return spatial;
}
Aggregations