Search in sources :

Example 61 with Spatial

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();
    }
}
Also used : BinaryExporter(com.jme3.export.binary.BinaryExporter) BinaryImporter(com.jme3.export.binary.BinaryImporter) Spatial(com.jme3.scene.Spatial) ByteArrayInputStream(java.io.ByteArrayInputStream) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) Node(com.jme3.scene.Node) AnimChannel(com.jme3.animation.AnimChannel) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) AnimControl(com.jme3.animation.AnimControl)

Example 62 with Spatial

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);
}
Also used : CollisionShape(com.jme3.bullet.collision.shapes.CollisionShape) Spatial(com.jme3.scene.Spatial) Node(com.jme3.scene.Node) RigidBodyControl(com.jme3.bullet.control.RigidBodyControl)

Example 63 with Spatial

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();
    }
}
Also used : Spatial(com.jme3.scene.Spatial)

Example 64 with Spatial

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;
}
Also used : Spatial(com.jme3.scene.Spatial) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f)

Example 65 with Spatial

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;
}
Also used : Geometry(com.jme3.scene.Geometry) Spatial(com.jme3.scene.Spatial) Material(com.jme3.material.Material) FbxMaterial(com.jme3.scene.plugins.fbx.material.FbxMaterial) FbxMaterial(com.jme3.scene.plugins.fbx.material.FbxMaterial)

Aggregations

Spatial (com.jme3.scene.Spatial)123 Vector3f (com.jme3.math.Vector3f)74 Node (com.jme3.scene.Node)56 Geometry (com.jme3.scene.Geometry)50 DirectionalLight (com.jme3.light.DirectionalLight)46 Material (com.jme3.material.Material)39 Quaternion (com.jme3.math.Quaternion)34 FilterPostProcessor (com.jme3.post.FilterPostProcessor)17 Box (com.jme3.scene.shape.Box)17 KeyTrigger (com.jme3.input.controls.KeyTrigger)15 AmbientLight (com.jme3.light.AmbientLight)14 ColorRGBA (com.jme3.math.ColorRGBA)14 Camera (com.jme3.renderer.Camera)13 Sphere (com.jme3.scene.shape.Sphere)13 Texture (com.jme3.texture.Texture)12 TempVars (com.jme3.util.TempVars)12 InputCapsule (com.jme3.export.InputCapsule)11 ActionListener (com.jme3.input.controls.ActionListener)11 AnimControl (com.jme3.animation.AnimControl)10 OutputCapsule (com.jme3.export.OutputCapsule)9