Search in sources :

Example 96 with Spatial

use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.

the class PlaceholderAssets method getPlaceholderModel.

public static Spatial getPlaceholderModel(AssetManager assetManager) {
    // What should be the size? Nobody knows
    // the user's expected scale...
    Box box = new Box(1, 1, 1);
    Geometry geom = new Geometry("placeholder", box);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    Texture tex = assetManager.loadTexture("Common/Textures/MissingModel.png");
    tex.setWrap(Texture.WrapMode.Repeat);
    mat.setTexture("ColorMap", tex);
    geom.setMaterial(mat);
    return geom;
}
Also used : Geometry(com.jme3.scene.Geometry) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) Texture(com.jme3.texture.Texture)

Example 97 with Spatial

use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.

the class SkyFactory method createSky.

/**
    * Create a sky using the given cubemap or spheremap texture.
    *
    * @param assetManager from which to load materials
    * @param textureName the path to the texture asset to use    
    * @param envMapType see {@link EnvMapType}
    * @return a new spatial representing the sky, ready to be attached to the
    * scene graph    
    */
public static Spatial createSky(AssetManager assetManager, String textureName, EnvMapType envMapType) {
    TextureKey key = new TextureKey(textureName, true);
    key.setGenerateMips(false);
    if (envMapType == EnvMapType.CubeMap) {
        key.setTextureTypeHint(Texture.Type.CubeMap);
    }
    Texture tex = assetManager.loadTexture(key);
    return createSky(assetManager, tex, envMapType);
}
Also used : TextureKey(com.jme3.asset.TextureKey) Texture(com.jme3.texture.Texture)

Example 98 with Spatial

use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.

the class TerrainTestAdvanced method createSky.

private void createSky() {
    Texture west = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_west.jpg");
    Texture east = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_east.jpg");
    Texture north = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_north.jpg");
    Texture south = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_south.jpg");
    Texture up = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_up.jpg");
    Texture down = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_down.jpg");
    Spatial sky = SkyFactory.createSky(assetManager, west, east, north, south, up, down);
    rootNode.attachChild(sky);
}
Also used : Spatial(com.jme3.scene.Spatial) Texture(com.jme3.texture.Texture)

Example 99 with Spatial

use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.

the class TestPostWaterLake method simpleInitApp.

public void simpleInitApp() {
    this.flyCam.setMoveSpeed(10);
    cam.setLocation(new Vector3f(-27.0f, 1.0f, 75.0f));
    //  cam.setRotation(new Quaternion(0.03f, 0.9f, 0f, 0.4f));
    // load sky
    rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));
    File file = new File("wildhouse.zip");
    if (file.exists()) {
        useHttp = false;
    }
    // load the level from zip or http zip
    if (useHttp) {
        assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/wildhouse.zip", HttpZipLocator.class);
    } else {
        assetManager.registerLocator("wildhouse.zip", ZipLocator.class);
    }
    Spatial scene = assetManager.loadModel("main.scene");
    rootNode.attachChild(scene);
    DirectionalLight sun = new DirectionalLight();
    Vector3f lightDir = new Vector3f(-0.37352666f, -0.50444174f, -0.7784704f);
    sun.setDirection(lightDir);
    sun.setColor(ColorRGBA.White.clone().multLocal(2));
    scene.addLight(sun);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    final WaterFilter water = new WaterFilter(rootNode, lightDir);
    water.setWaterHeight(-20);
    water.setUseFoam(false);
    water.setUseRipples(false);
    water.setDeepWaterColor(ColorRGBA.Brown);
    water.setWaterColor(ColorRGBA.Brown.mult(2.0f));
    water.setWaterTransparency(0.2f);
    water.setMaxAmplitude(0.3f);
    water.setWaveScale(0.008f);
    water.setSpeed(0.7f);
    water.setShoreHardness(1.0f);
    water.setRefractionConstant(0.2f);
    water.setShininess(0.3f);
    water.setSunScale(1.0f);
    water.setColorExtinction(new Vector3f(10.0f, 20.0f, 30.0f));
    fpp.addFilter(water);
    viewPort.addProcessor(fpp);
    inputManager.addListener(new ActionListener() {

        public void onAction(String name, boolean isPressed, float tpf) {
            if (isPressed) {
                if (water.isUseHQShoreline()) {
                    water.setUseHQShoreline(false);
                } else {
                    water.setUseHQShoreline(true);
                }
            }
        }
    }, "HQ");
    inputManager.addMapping("HQ", new KeyTrigger(keyInput.KEY_SPACE));
}
Also used : ActionListener(com.jme3.input.controls.ActionListener) Spatial(com.jme3.scene.Spatial) WaterFilter(com.jme3.water.WaterFilter) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) KeyTrigger(com.jme3.input.controls.KeyTrigger) FilterPostProcessor(com.jme3.post.FilterPostProcessor) File(java.io.File)

Example 100 with Spatial

use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.

the class TestUserData method simpleInitApp.

public void simpleInitApp() {
    Node scene = (Node) assetManager.loadModel("Scenes/DotScene/DotScene.scene");
    System.out.println("Scene: " + scene);
    Spatial testNode = scene.getChild("TestNode");
    System.out.println("TestNode: " + testNode);
    for (String key : testNode.getUserDataKeys()) {
        System.out.println("Property " + key + " = " + testNode.getUserData(key));
    }
}
Also used : Spatial(com.jme3.scene.Spatial) Node(com.jme3.scene.Node)

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