Search in sources :

Example 91 with AssetManager

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

the class TestRagdollCharacter method initWall.

public void initWall(float bLength, float bWidth, float bHeight) {
    Box brick = new Box(bLength, bHeight, bWidth);
    brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
    Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
    key.setGenerateMips(true);
    Texture tex = assetManager.loadTexture(key);
    mat2.setTexture("ColorMap", tex);
    float startpt = bLength / 4;
    float height = -5;
    for (int j = 0; j < 15; j++) {
        for (int i = 0; i < 4; i++) {
            Vector3f ori = new Vector3f(i * bLength * 2 + startpt, bHeight + height, -10);
            Geometry reBoxg = new Geometry("brick", brick);
            reBoxg.setMaterial(mat2);
            reBoxg.setLocalTranslation(ori);
            //for geometry with sphere mesh the physics system automatically uses a sphere collision shape
            reBoxg.addControl(new RigidBodyControl(1.5f));
            reBoxg.setShadowMode(ShadowMode.CastAndReceive);
            reBoxg.getControl(RigidBodyControl.class).setFriction(0.6f);
            this.rootNode.attachChild(reBoxg);
            this.getPhysicsSpace().add(reBoxg);
        }
        startpt = -startpt;
        height += 2 * bHeight;
    }
}
Also used : Geometry(com.jme3.scene.Geometry) TextureKey(com.jme3.asset.TextureKey) Vector2f(com.jme3.math.Vector2f) Vector3f(com.jme3.math.Vector3f) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) Texture(com.jme3.texture.Texture) RigidBodyControl(com.jme3.bullet.control.RigidBodyControl)

Example 92 with AssetManager

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

the class TestRagdollCharacter method simpleInitApp.

public void simpleInitApp() {
    setupKeys();
    bulletAppState = new BulletAppState();
    bulletAppState.setEnabled(true);
    stateManager.attach(bulletAppState);
    //        bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
    initWall(2, 1, 1);
    setupLight();
    cam.setLocation(new Vector3f(-8, 0, -4));
    cam.lookAt(new Vector3f(4, 0, -7), Vector3f.UNIT_Y);
    model = (Node) assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
    model.lookAt(new Vector3f(0, 0, -1), Vector3f.UNIT_Y);
    model.setLocalTranslation(4, 0, -7f);
    ragdoll = new KinematicRagdollControl(0.5f);
    model.addControl(ragdoll);
    getPhysicsSpace().add(ragdoll);
    speed = 1.3f;
    rootNode.attachChild(model);
    AnimControl control = model.getControl(AnimControl.class);
    animChannel = control.createChannel();
    animChannel.setAnim("IdleTop");
    control.addListener(this);
}
Also used : BulletAppState(com.jme3.bullet.BulletAppState) Vector3f(com.jme3.math.Vector3f) KinematicRagdollControl(com.jme3.bullet.control.KinematicRagdollControl) AnimControl(com.jme3.animation.AnimControl)

Example 93 with AssetManager

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

the class TestOrtho method simpleInitApp.

public void simpleInitApp() {
    Picture p = new Picture("Picture");
    // make it appear behind stats view
    p.move(0, 0, -1);
    p.setPosition(0, 0);
    p.setWidth(settings.getWidth());
    p.setHeight(settings.getHeight());
    p.setImage(assetManager, "Interface/Logo/Monkey.png", false);
    // attach geometry to orthoNode
    guiNode.attachChild(p);
}
Also used : Picture(com.jme3.ui.Picture)

Example 94 with AssetManager

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

the class TestSoftwareMouse method simpleInitApp.

@Override
public void simpleInitApp() {
    flyCam.setEnabled(false);
    //        inputManager.setCursorVisible(false);
    Texture tex = assetManager.loadTexture("Interface/Logo/Cursor.png");
    cursor = new Picture("cursor");
    cursor.setTexture(assetManager, (Texture2D) tex, true);
    cursor.setWidth(64);
    cursor.setHeight(64);
    guiNode.attachChild(cursor);
    inputManager.addRawInputListener(inputListener);
//        Image img = tex.getImage();
//        ByteBuffer data = img.getData(0);
//        IntBuffer image = BufferUtils.createIntBuffer(64 * 64);
//        for (int y = 0; y < 64; y++){
//            for (int x = 0; x < 64; x++){
//                int rgba = data.getInt();
//                image.put(rgba);
//            }
//        }
//        image.clear();
//
//        try {
//            Cursor cur = new Cursor(64, 64, 2, 62, 1, image, null);
//            Mouse.setNativeCursor(cur);
//        } catch (LWJGLException ex) {
//            Logger.getLogger(TestSoftwareMouse.class.getName()).log(Level.SEVERE, null, ex);
//        }
}
Also used : Picture(com.jme3.ui.Picture) Texture(com.jme3.texture.Texture)

Example 95 with AssetManager

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

the class HelloAudio method initAudio.

/** We create two audio nodes. */
private void initAudio() {
    /* gun shot sound is to be triggered by a mouse click. */
    audio_gun = new AudioNode(assetManager, "Sound/Effects/Gun.wav", false);
    audio_gun.setPositional(false);
    audio_gun.setLooping(false);
    audio_gun.setVolume(2);
    rootNode.attachChild(audio_gun);
    /* nature sound - keeps playing in a loop. */
    audio_nature = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", true);
    // activate continuous playing
    audio_nature.setLooping(true);
    audio_nature.setPositional(true);
    audio_nature.setVolume(3);
    rootNode.attachChild(audio_nature);
    // play continuously!
    audio_nature.play();
}
Also used : AudioNode(com.jme3.audio.AudioNode)

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