public void simpleInitApp() {
    renderManager.setAlphaToCoverage(true);
    cam.setLocation(new Vector3f(0.14914267f, 0.58147097f, 4.7686534f));
    cam.setRotation(new Quaternion(-0.0044764364f, 0.9767943f, 0.21314798f, 0.020512417f));

    //        cam.setLocation(new Vector3f(2.0606942f, 3.20342f, 6.7860126f));
    //        cam.setRotation(new Quaternion(-0.017481906f, 0.98241085f, -0.12393151f,
    // -0.13857932f));

    viewPort.setBackgroundColor(ColorRGBA.DarkGray);

    Quad q = new Quad(20, 20);
    q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(5));
    Geometry geom = new Geometry("floor", q);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    geom.setMaterial(mat);

    geom.rotate(-FastMath.HALF_PI, 0, 0);
    geom.center();
    geom.setShadowMode(ShadowMode.Receive);
    rootNode.attachChild(geom);

    // create the geometry and attach it
    Spatial teaGeom = assetManager.loadModel("Models/Tree/Tree.mesh.j3o");
    teaGeom.setQueueBucket(Bucket.Transparent);
    teaGeom.setShadowMode(ShadowMode.Cast);
    makeToonish(teaGeom);

    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(2));
    rootNode.addLight(al);

    DirectionalLight dl1 = new DirectionalLight();
    dl1.setDirection(new Vector3f(1, -1, 1).normalizeLocal());
    dl1.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
    rootNode.addLight(dl1);

    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    dl.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
    rootNode.addLight(dl);

    rootNode.attachChild(teaGeom);

    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    CartoonEdgeFilter toon = new CartoonEdgeFilter();
    toon.setEdgeWidth(0.5f);
    toon.setEdgeIntensity(1.0f);
    toon.setNormalThreshold(0.8f);
    fpp.addFilter(toon);
    viewPort.addProcessor(fpp);
  }
Exemplo n.º 2
0
  public void loadLight() {

    XMLImporter imp = XMLImporter.getInstance();
    imp.setAssetManager(assetManager);

    try {
      InputStream fis =
          assetManager
              .locateAsset(new AssetKey("Scenes/" + map + "/directlightsave.xml"))
              .openStream();
      DirectionalLight dl = (DirectionalLight) imp.load(new BufferedInputStream(fis));
      rootNode.addLight(dl);
    } catch (Exception e) {
    }

    try {
      InputStream fis =
          assetManager
              .locateAsset(new AssetKey("Scenes/" + map + "/ambientlightsave.xml"))
              .openStream();
      AmbientLight al = (AmbientLight) imp.load(new BufferedInputStream(fis));
      rootNode.addLight(al);
    } catch (Exception e) {
    }

    try {
      InputStream fis =
          assetManager.locateAsset(new AssetKey("Scenes/" + map + "/fogsave.xml")).openStream();
      FogFilter fog = (FogFilter) imp.load(new BufferedInputStream(fis));

      FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
      fpp.addFilter(fog);
      viewPort.addProcessor(fpp);
    } catch (Exception e) {
    }

    /*
    try{
        InputStream fis = assetManager.locateAsset(new AssetKey("Scenes/"+map+"/shadowsave.xml")).openStream();
        PssmShadowRenderer pssmRenderer = (PssmShadowRenderer) imp.load(new BufferedInputStream(fis));
         viewPort.addProcessor(pssmRenderer);
    }catch(Exception e){}
     *
     */
  }
Exemplo n.º 3
0
  /** (re-)Sets scene processors to the view port */
  public void setViewProcessors() {

    // Clear the old ones
    viewPort.clearProcessors();

    // Add SSAO
    if (getUserSettings().getSettingBoolean(Settings.Setting.SSAO)) {
      FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
      SSAOFilter ssaoFilter =
          new SSAOFilter(
              getUserSettings().getSettingFloat(Settings.Setting.SSAO_SAMPLE_RADIUS),
              getUserSettings().getSettingFloat(Settings.Setting.SSAO_INTENSITY),
              getUserSettings().getSettingFloat(Settings.Setting.SSAO_SCALE),
              getUserSettings().getSettingFloat(Settings.Setting.SSAO_BIAS));
      fpp.addFilter(ssaoFilter);
      viewPort.addProcessor(fpp);
    }
  }
Exemplo n.º 4
0
 public void initPPcWater() {
   FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
   water = new WaterFilter(rootNode, lightDir);
   water.setUseHQShoreline(true);
   water.setUseRefraction(true);
   water.setUseRipples(true);
   water.setUseSpecular(true);
   water.setShoreHardness(0.05f);
   water.setUnderWaterFogDistance(80);
   water.setWindDirection(new Vector2f(0.7f, 0.2f));
   water.setCenter(Vector3f.ZERO);
   water.setRadius(2600);
   water.setWaveScale(0.003f);
   water.setMaxAmplitude(6.0f);
   water.setFoamExistence(new Vector3f(1.0f, 4.0f, 0.5f));
   water.setFoamTexture(
       (Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
   water.setRefractionStrength(0.2f);
   water.setWaterHeight(5.0f);
   fpp.addFilter(water);
   viewPort.addProcessor(fpp);
 }
  public EffectCenter(Simulator sim) {
    this.sim = sim;
    AssetManager assetManager = sim.getAssetManager();

    WeatherSettings weatherSettings =
        Simulator.getDrivingTask().getScenarioLoader().getWeatherSettings();
    snowingPercentage =
        Math.max(
            weatherSettings.getSnowingPercentage(),
            -1); // use -1 to suppress construction of SnowParticleEmitter
    rainingPercentage =
        Math.max(
            weatherSettings.getRainingPercentage(),
            -1); // use -1 to suppress construction of RainParticleEmitter
    fogPercentage =
        Math.max(
            weatherSettings.getFogPercentage(), -1); // use -1 to suppress construction of FogFilter
    isSnowing = (snowingPercentage >= 0);
    isRaining = (rainingPercentage >= 0);
    isFog = (fogPercentage >= 0);
    isBloom = !Simulator.oculusRiftAttached; // switch off bloom filter when Oculus Rift is used
    isShadow = true;

    if (isSnowing) {
      // init snow
      snowParticleEmitter = new SnowParticleEmitter(assetManager, snowingPercentage);
      sim.getSceneNode().attachChild(snowParticleEmitter);
    }

    if (isRaining) {
      // init rain
      rainParticleEmitter = new RainParticleEmitter(assetManager, rainingPercentage);
      sim.getSceneNode().attachChild(rainParticleEmitter);
    }

    if (isFog || isBloom) {
      for (ViewPort viewPort : CameraFactory.getViewPortList()) {
        FilterPostProcessor processor = new FilterPostProcessor(assetManager);

        int numSamples = sim.getContext().getSettings().getSamples();
        if (numSamples > 0) processor.setNumSamples(numSamples);

        if (isFog) {
          FogFilter fogFilter = new FogFilter();
          fogFilter.setFogColor(new ColorRGBA(0.9f, 0.9f, 0.9f, 1.0f));
          fogFilter.setFogDistance(155);
          fogFilter.setFogDensity(2.0f * (fogPercentage / 100f));
          fogFilterList.add(fogFilter);
          processor.addFilter(fogFilter);
        }

        if (isBloom) {
          // ensure any object is set to glow, e.g. car chassis:
          // chassis.getMaterial().setColor("GlowColor", ColorRGBA.Orange);

          BloomFilter bloom = new BloomFilter(GlowMode.Objects);
          processor.addFilter(bloom);
        }

        viewPort.addProcessor(processor);
      }
    }

    if (isShadow) { // TODO
      DirectionalLight sun = new DirectionalLight();
      Vector3f sunLightDirection = new Vector3f(-0.2f, -0.9f, 0.2f); // TODO get from DT files
      sun.setDirection(sunLightDirection.normalizeLocal());

      ArrayList<ViewPort> viewPortList = CameraFactory.getViewPortList();

      if (sim.getNumberOfScreens() > 1) {
        int shadowMapSize = 4096;
        if (viewPortList.size() > 1) shadowMapSize = 1024;

        for (ViewPort viewPort : viewPortList) {
          DirectionalLightShadowRenderer dlsr =
              new DirectionalLightShadowRenderer(assetManager, shadowMapSize, 1);
          dlsr.setLight(sun);
          dlsr.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
          viewPort.addProcessor(dlsr);
        }

        shadowMapSize = 1024;
        DirectionalLightShadowRenderer dlsrBack =
            new DirectionalLightShadowRenderer(assetManager, shadowMapSize, 1);
        dlsrBack.setLight(sun);
        CameraFactory.getBackViewPort().addProcessor(dlsrBack);

        DirectionalLightShadowRenderer dlsrLeft =
            new DirectionalLightShadowRenderer(assetManager, shadowMapSize, 1);
        dlsrLeft.setLight(sun);
        CameraFactory.getLeftBackViewPort().addProcessor(dlsrLeft);

        DirectionalLightShadowRenderer dlsrRight =
            new DirectionalLightShadowRenderer(assetManager, shadowMapSize, 1);
        dlsrRight.setLight(sun);
        CameraFactory.getRightBackViewPort().addProcessor(dlsrRight);
      } else {
        // does not work with more than one screen
        for (ViewPort viewPort : viewPortList) {
          DirectionalLightShadowFilter dlsf =
              new DirectionalLightShadowFilter(assetManager, 1024, 3);
          dlsf.setLight(sun);
          dlsf.setLambda(1f);
          dlsf.setShadowIntensity(0.3f);
          dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
          dlsf.setEnabled(true);

          FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
          fpp.addFilter(dlsf);

          viewPort.addProcessor(fpp);
        }
      }
    }
  }
Exemplo n.º 6
0
  @Override
  public void simpleInitApp() {
    timer = new NanoTimer();

    batchNode = new SimpleBatchNode("BatchNode");

    xPosition.add(0);
    yPosition.add(0);
    zPosition.add(0);

    mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat1.setColor("Color", ColorRGBA.White);
    mat1.setColor("GlowColor", ColorRGBA.Blue.mult(10));

    mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat2.setColor("Color", ColorRGBA.White);
    mat2.setColor("GlowColor", ColorRGBA.Red.mult(10));

    mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat3.setColor("Color", ColorRGBA.White);
    mat3.setColor("GlowColor", ColorRGBA.Yellow.mult(10));

    mat4 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat4.setColor("Color", ColorRGBA.White);
    mat4.setColor("GlowColor", ColorRGBA.Orange.mult(10));

    randomGenerator();

    // rootNode.attachChild(SkyFactory.createSky(
    //  assetManager, "Textures/SKY02.zip", false));
    inputManager.addMapping("Start Game", new KeyTrigger(KeyInput.KEY_J));
    inputManager.addListener(al, new String[] {"Start Game"});

    getCam().setLocation(new Vector3f(-34.403286f, 126.65158f, 434.791f));
    getCam().setRotation(new Quaternion(0.022630932f, 0.9749435f, -0.18736298f, 0.11776358f));

    batchNode.batch();

    terrain = new Node("terrain");
    terrain.setLocalTranslation(50, 0, 50);
    terrain.attachChild(batchNode);

    flyCam.setMoveSpeed(100);
    rootNode.attachChild(terrain);
    Vector3f pos = new Vector3f(-40, 0, -40);
    batchNode.setLocalTranslation(pos);

    Arrow a = new Arrow(new Vector3f(0, 50, 0));
    Geometry g = new Geometry("a", a);
    g.setLocalTranslation(terrain.getLocalTranslation());
    Material m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    m.setColor("Color", ColorRGBA.Blue);
    g.setMaterial(m);

    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(new BloomFilter(BloomFilter.GlowMode.Objects));
    //        SSAOFilter ssao = new SSAOFilter(8.630104f,22.970434f,2.9299977f,0.2999997f);
    //        fpp.addFilter(ssao);
    viewPort.addProcessor(fpp);
    //   viewPort.setBackgroundColor(ColorRGBA.DarkGray);
  }
Exemplo n.º 7
0
  @Override
  public void simpleInitApp() {
    //        setup camera for 2D games
    cam.setParallelProjection(true);
    cam.setLocation(new Vector3f(0, 0, 0.5f));
    getFlyByCamera().setEnabled(false);

    //        turn off stats (you can leave it on, if you want)
    setDisplayStatView(false);
    setDisplayFps(false);

    //        initializing the bloom filter
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    BloomFilter bloom = new BloomFilter();
    bloom.setBloomIntensity(2f);
    bloom.setExposurePower(2);
    bloom.setExposureCutOff(0f);
    bloom.setBlurScale(1.5f);
    fpp.addFilter(bloom);
    guiViewPort.addProcessor(fpp);
    guiViewPort.setClearColor(true);

    //        setup input handling
    inputManager.setMouseCursor((JmeCursor) assetManager.loadAsset("Textures/Pointer.ico"));

    inputManager.addMapping("mousePick", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(this, "mousePick");

    inputManager.addMapping("left", new KeyTrigger(KeyInput.KEY_A));
    inputManager.addMapping("right", new KeyTrigger(KeyInput.KEY_D));
    inputManager.addMapping("up", new KeyTrigger(KeyInput.KEY_W));
    inputManager.addMapping("down", new KeyTrigger(KeyInput.KEY_S));
    inputManager.addMapping("return", new KeyTrigger(KeyInput.KEY_RETURN));
    inputManager.addListener(this, "left");
    inputManager.addListener(this, "right");
    inputManager.addListener(this, "up");
    inputManager.addListener(this, "down");
    inputManager.addListener(this, "return");

    //        setup the hud
    hud = new Hud(assetManager, guiNode, settings.getWidth(), settings.getHeight());
    hud.reset();

    //        sounds
    sound = new Sound(assetManager);
    sound.startMusic();
    sound.spawn();

    //        particles
    particleManager =
        new ParticleManager(
            guiNode,
            getSpatial("Laser"),
            getSpatial("Glow"),
            settings.getWidth(),
            settings.getHeight());

    //        grid
    Rectangle size = new Rectangle(0, 0, settings.getWidth(), settings.getHeight());
    Vector2f spacing = new Vector2f(25, 25);
    grid = new Grid(size, spacing, guiNode, assetManager);

    //        setup the player
    player = getSpatial("Player");
    player.setUserData("alive", true);
    player.move(settings.getWidth() / 2, settings.getHeight() / 2, 0);
    player.addControl(
        new PlayerControl(settings.getWidth(), settings.getHeight(), particleManager));
    guiNode.attachChild(player);

    //        setup the bulletNode
    bulletNode = new Node("bullets");
    guiNode.attachChild(bulletNode);
    //        setup the enemyNode
    enemyNode = new Node("enemies");
    guiNode.attachChild(enemyNode);
    //        setup the blackholeNode
    blackHoleNode = new Node("black_holes");
    guiNode.attachChild(blackHoleNode);
    //        setup the particleNode
    particleNode = new Node("particles");
    guiNode.attachChild(particleNode);
  }
Exemplo n.º 8
0
  @Override
  public void simpleInitApp() {

    setDisplayFps(false);
    setDisplayStatView(false);

    bap = new BulletAppState();
    stateManager.attach(bap);
    bap.getPhysicsSpace().setGravity(Vector3f.ZERO);
    bap.getPhysicsSpace().addCollisionListener(this);

    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    showText = new BitmapText(guiFont, false);
    showText.setSize(50);
    showText.setColor(ColorRGBA.Red);
    showText.setLocalTranslation((settings.getWidth() / 2) - 200, settings.getHeight() / 2, 0);

    score = 0;
    scoreText = new BitmapText(guiFont, false);
    scoreText.setSize(guiFont.getCharSet().getRenderedSize());
    scoreText.setColor(ColorRGBA.White);
    scoreText.setText("Score: " + score);
    scoreText.setLocalTranslation(settings.getWidth() - 200, settings.getHeight() - 30, 0);
    guiNode.attachChild(scoreText);

    lives = 3;
    /*
    livespic = new Picture[lives];
    for(int i=0; i < lives; i++){
        livespic[i] = new Picture("Live "+i);
        livespic[i].setImage(assetManager, "Textures/LifeLogo.png", true);
        livespic[i].setWidth(50);
        livespic[i].setHeight(50);
        livespic[i].setPosition(i*50, settings.getHeight()-50);
        guiNode.attachChild(livespic[i]);
    }
     *
     */

    planets = new Planet[9];

    Material mat10 = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat10.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Sun.jpg"));
    mat10.setTexture("GlowMap", assetManager.loadTexture("Textures/Sun.jpg"));
    mat10.setColor("Specular", ColorRGBA.White);
    mat10.setBoolean("UseAlpha", true);
    sun = new Planet("Sun", 5f, mat10);
    sun.registerPhysics(bap.getPhysicsSpace());
    rootNode.attachChild(sun);

    Material mat1 = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat1.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Mercury.jpg"));
    mat1.setColor("Specular", ColorRGBA.White);
    mercury = new Planet("Mercury", 2f, mat1);
    mercury.setInitLocation(new Vector3f(16.0f, 0f, -6.0f));
    mercury.setRotationSpeed((float) Math.random());
    mercury.setTranslationSpeed(0.76f);
    mercury.registerPhysics(bap.getPhysicsSpace());
    planets[0] = mercury;
    rootNode.attachChild(mercury);

    Material mat2 = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat2.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Venus.jpg"));
    mat2.setColor("Specular", ColorRGBA.White);
    venus = new Planet("Venus", 2.6f, mat2);
    venus.setInitLocation(new Vector3f(23.0f, 0f, -6.0f));
    venus.setRotationSpeed((float) Math.random());
    venus.setTranslationSpeed(0.65f);
    venus.registerPhysics(bap.getPhysicsSpace());
    planets[1] = venus;
    rootNode.attachChild(venus);

    Material mat3 = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat3.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Earth/Color.jpg"));
    mat3.setTexture("ParallaxMap", assetManager.loadTexture("Textures/Earth/Bump.jpg"));
    mat3.setTexture("SpecularMap", assetManager.loadTexture("Textures/Earth/Specular.jpg"));
    earth = new Planet("Earth", 2.7f, mat3);
    earth.setInitLocation(new Vector3f(31.0f, 0f, -6.0f));
    earth.setRotationSpeed((float) Math.random());
    earth.setTranslationSpeed(0.6f);
    earth.registerPhysics(bap.getPhysicsSpace());
    planets[2] = earth;
    rootNode.attachChild(earth);

    Material mat4 = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat4.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Mars.jpg"));
    mat4.setColor("Specular", ColorRGBA.White);
    mars = new Planet("Mars", 2.5f, mat4);
    mars.setInitLocation(new Vector3f(40.0f, 0f, -6.0f));
    mars.setRotationSpeed((float) Math.random());
    mars.setTranslationSpeed(0.56f);
    mars.registerPhysics(bap.getPhysicsSpace());
    planets[3] = mars;
    rootNode.attachChild(mars);

    Material mat5 = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat5.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Jupiter.jpg"));
    mat5.setColor("Specular", ColorRGBA.White);
    jupiter = new Planet("Jupiter", 3.1f, mat5);
    jupiter.setInitLocation(new Vector3f(49.0f, 0f, -6.0f));
    jupiter.setRotationSpeed((float) Math.random());
    jupiter.setTranslationSpeed(0.5f);
    jupiter.registerPhysics(bap.getPhysicsSpace());
    planets[4] = jupiter;
    rootNode.attachChild(jupiter);

    Material mat6 = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat6.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Saturn.jpg"));
    mat6.setColor("Specular", ColorRGBA.White);
    saturn = new Planet("Saturn", 2.9f, mat6);
    saturn.setInitLocation(new Vector3f(57.0f, 0f, -6.0f));
    saturn.setRotationSpeed((float) Math.random());
    saturn.setTranslationSpeed(0.44f);
    saturn.registerPhysics(bap.getPhysicsSpace());
    planets[5] = saturn;
    rootNode.attachChild(saturn);

    Material mat7 = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat7.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Uranus.jpg"));
    mat7.setColor("Specular", ColorRGBA.White);
    uranus = new Planet("Uranus", 2.8f, mat7);
    uranus.setInitLocation(new Vector3f(65.0f, 0f, -6.0f));
    uranus.setRotationSpeed((float) Math.random());
    uranus.setTranslationSpeed(0.4f);
    uranus.registerPhysics(bap.getPhysicsSpace());
    planets[6] = uranus;
    rootNode.attachChild(uranus);

    Material mat8 = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat8.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Neptune.jpg"));
    mat8.setColor("Specular", ColorRGBA.White);
    neptune = new Planet("Neptune", 2.65f, mat8);
    neptune.setInitLocation(new Vector3f(75.0f, 0f, -6.0f));
    neptune.setRotationSpeed((float) Math.random());
    neptune.setTranslationSpeed(0.34f);
    neptune.registerPhysics(bap.getPhysicsSpace());
    planets[7] = neptune;
    rootNode.attachChild(neptune);

    Material mat9 = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat9.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Pluto.jpg"));
    mat9.setColor("Specular", ColorRGBA.White);
    pluto = new Planet("Pluto", 1.5f, mat9);
    pluto.setInitLocation(new Vector3f(82.0f, 0f, -6.0f));
    pluto.setRotationSpeed((float) Math.random());
    pluto.setTranslationSpeed(0.2f);
    pluto.registerPhysics(bap.getPhysicsSpace());
    planets[8] = pluto;
    rootNode.attachChild(pluto);

    spaceship = new Spaceship("Spaceship", assetManager.loadModel("Models/X-WING/X-WING.j3o"));
    spaceship.addTurbines(
        new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"),
        assetManager.loadTexture("Effects/Explosion/flame.png"));
    spaceship.setLocalTranslation(0, 20, 40);
    spaceship.getModel().scale(0.1f);
    spaceship.registerPhysics(bap.getPhysicsSpace());

    rootNode.attachChild(spaceship);

    Material laserMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    laserMaterial.setColor("GlowColor", ColorRGBA.Green);
    laserMaterial.setColor("Ambient", ColorRGBA.Green);
    laserMaterial.setColor("Diffuse", ColorRGBA.Green);
    laserMaterial.setBoolean("UseMaterialColors", true);
    spaceship.setLaserMaterial(laserMaterial);

    lasers = new Node("Lasers");
    rootNode.attachChild(lasers);

    flyCam.setEnabled(false);

    cam.setLocation(spaceship.getRear().getWorldTranslation());
    cam.lookAt(spaceship.getFront().getWorldTranslation(), Vector3f.UNIT_Y);

    PointLight sunLight = new PointLight();
    sunLight.setColor(ColorRGBA.White);
    sunLight.setPosition(new Vector3f(0f, 0f, 0f));
    sunLight.setRadius(100f);
    rootNode.addLight(sunLight);

    AmbientLight ambient = new AmbientLight();
    rootNode.addLight(ambient);

    fpp = new FilterPostProcessor(assetManager);
    bloom = new BloomFilter(BloomFilter.GlowMode.Objects);
    bloom.setExposurePower(30f);
    bloom.setBloomIntensity(1f);
    fpp.addFilter(bloom);
    viewPort.addProcessor(fpp);

    rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Stars5.jpeg", true));

    bloomDirection = 1;
    noComet = 1;
    moving = up = down = left = right = leftSide = rightSide = false;

    asteroids = new Node("Asteroids");
    rootNode.attachChild(asteroids);

    explosions = new Node("Explosions");
    rootNode.attachChild(explosions);

    initKeys();
    initAudio();
  }