Search in sources :

Example 86 with AssetManager

use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.

the class TestParticleExportingCloning method simpleInitApp.

@Override
public void simpleInitApp() {
    ParticleEmitter emit = new ParticleEmitter("Emitter", Type.Triangle, 200);
    emit.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f));
    emit.setGravity(0, 0, 0);
    emit.setLowLife(5);
    emit.setHighLife(10);
    emit.setInitialVelocity(new Vector3f(0, 0, 0));
    emit.setImagesX(15);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Smoke/Smoke.png"));
    emit.setMaterial(mat);
    ParticleEmitter emit2 = emit.clone();
    emit2.move(3, 0, 0);
    rootNode.attachChild(emit);
    rootNode.attachChild(emit2);
    ParticleEmitter emit3 = BinaryExporter.saveAndLoad(assetManager, emit);
    emit3.move(-3, 0, 0);
    rootNode.attachChild(emit3);
}
Also used : ParticleEmitter(com.jme3.effect.ParticleEmitter) Vector3f(com.jme3.math.Vector3f) EmitterSphereShape(com.jme3.effect.shapes.EmitterSphereShape) Material(com.jme3.material.Material)

Example 87 with AssetManager

use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.

the class TestPointSprite method simpleInitApp.

@Override
public void simpleInitApp() {
    final ParticleEmitter emit = new ParticleEmitter("Emitter", Type.Point, 10000);
    emit.setShape(new EmitterBoxShape(new Vector3f(-1.8f, -1.8f, -1.8f), new Vector3f(1.8f, 1.8f, 1.8f)));
    emit.setGravity(0, 0, 0);
    emit.setLowLife(60);
    emit.setHighLife(60);
    emit.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0));
    emit.setImagesX(15);
    emit.setStartSize(0.05f);
    emit.setEndSize(0.05f);
    emit.setStartColor(ColorRGBA.White);
    emit.setEndColor(ColorRGBA.White);
    emit.setSelectRandomImage(true);
    emit.emitAllParticles();
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setBoolean("PointSprite", true);
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Smoke/Smoke.png"));
    emit.setMaterial(mat);
    rootNode.attachChild(emit);
    inputManager.addListener(new ActionListener() {

        public void onAction(String name, boolean isPressed, float tpf) {
            if ("setNum".equals(name) && isPressed) {
                emit.setNumParticles(5000);
                emit.emitAllParticles();
            }
        }
    }, "setNum");
    inputManager.addMapping("setNum", new KeyTrigger(KeyInput.KEY_SPACE));
}
Also used : ParticleEmitter(com.jme3.effect.ParticleEmitter) ActionListener(com.jme3.input.controls.ActionListener) Vector3f(com.jme3.math.Vector3f) KeyTrigger(com.jme3.input.controls.KeyTrigger) EmitterBoxShape(com.jme3.effect.shapes.EmitterBoxShape) Material(com.jme3.material.Material)

Example 88 with AssetManager

use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.

the class TestSoftParticles method createParticles.

private void createParticles() {
    Material material = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    material.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png"));
    // 
    material.setFloat("Softness", 3f);
    //Fire
    ParticleEmitter fire = new ParticleEmitter("Fire", ParticleMesh.Type.Triangle, 30);
    fire.setMaterial(material);
    fire.setShape(new EmitterSphereShape(Vector3f.ZERO, 0.1f));
    fire.setImagesX(2);
    // 2x2 texture animation
    fire.setImagesY(2);
    // red
    fire.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f));
    // yellow
    fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f));
    fire.setStartSize(0.6f);
    fire.setEndSize(0.01f);
    fire.setGravity(0, -0.3f, 0);
    fire.setLowLife(0.5f);
    fire.setHighLife(3f);
    fire.setLocalTranslation(0, 0.2f, 0);
    particleNode.attachChild(fire);
    ParticleEmitter smoke = new ParticleEmitter("Smoke", ParticleMesh.Type.Triangle, 30);
    smoke.setMaterial(material);
    smoke.setShape(new EmitterSphereShape(Vector3f.ZERO, 5));
    smoke.setImagesX(1);
    // 2x2 texture animation
    smoke.setImagesY(1);
    // dark gray
    smoke.setStartColor(new ColorRGBA(0.1f, 0.1f, 0.1f, 1f));
    // gray      
    smoke.setEndColor(new ColorRGBA(0.5f, 0.5f, 0.5f, 0.3f));
    smoke.setStartSize(3f);
    smoke.setEndSize(5f);
    smoke.setGravity(0, -0.001f, 0);
    smoke.setLowLife(100f);
    smoke.setHighLife(100f);
    smoke.setLocalTranslation(0, 0.1f, 0);
    smoke.emitAllParticles();
    particleNode.attachChild(smoke);
}
Also used : ParticleEmitter(com.jme3.effect.ParticleEmitter) ColorRGBA(com.jme3.math.ColorRGBA) EmitterSphereShape(com.jme3.effect.shapes.EmitterSphereShape) Material(com.jme3.material.Material)

Example 89 with AssetManager

use of com.jme3.asset.AssetManager 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 90 with AssetManager

use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.

the class TestRagDoll method simpleInitApp.

@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    bulletAppState.setDebugEnabled(true);
    inputManager.addMapping("Pull ragdoll up", new MouseButtonTrigger(0));
    inputManager.addListener(this, "Pull ragdoll up");
    PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
    createRagDoll();
}
Also used : BulletAppState(com.jme3.bullet.BulletAppState) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger)

Aggregations

Material (com.jme3.material.Material)213 Geometry (com.jme3.scene.Geometry)138 Vector3f (com.jme3.math.Vector3f)137 Box (com.jme3.scene.shape.Box)73 Texture (com.jme3.texture.Texture)73 DirectionalLight (com.jme3.light.DirectionalLight)66 Node (com.jme3.scene.Node)52 Sphere (com.jme3.scene.shape.Sphere)47 Quaternion (com.jme3.math.Quaternion)46 Spatial (com.jme3.scene.Spatial)43 FilterPostProcessor (com.jme3.post.FilterPostProcessor)38 ColorRGBA (com.jme3.math.ColorRGBA)37 KeyTrigger (com.jme3.input.controls.KeyTrigger)31 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)27 BulletAppState (com.jme3.bullet.BulletAppState)26 Quad (com.jme3.scene.shape.Quad)23 TextureKey (com.jme3.asset.TextureKey)22 ActionListener (com.jme3.input.controls.ActionListener)21 AmbientLight (com.jme3.light.AmbientLight)20 Texture2D (com.jme3.texture.Texture2D)20