Package javara.world.environment

Examples of javara.world.environment.Celestial


        if (attrs.getValue("size") != null)
          size = Float.parseFloat(attrs.getValue("size"));
        if (attrs.getValue("visible") != null)
          visible = parseBoolean(attrs.getValue("visible"));

        Celestial cel = new Celestial(world, color, intensity, azimuth, elevation, size, visible);
        world.addWorldObject(cel);

        if (intensity > 0)
          numLights++;
      }
      else if (localName.equalsIgnoreCase("starfield")) {
        long seed = world.getName().hashCode();
        int count = 500;
        boolean monochrome = false;
        ColorRGBA minColor = ColorRGBA.White;
        ColorRGBA maxColor = ColorRGBA.White;
        float minSize = 0.025f;
        float maxSize = 0.025f;

        if (attrs.getValue("seed") != null)
          seed = Long.parseLong(attrs.getValue("seed"));
        if (attrs.getValue("count") != null)
          count = Integer.parseInt(attrs.getValue("count"));
        if (attrs.getValue("monochrome") != null)
          monochrome = parseBoolean(attrs.getValue("monochrome"));
        if (attrs.getValue("minColor") != null)
          minColor = parseColor(attrs.getValue("minColor"));
        if (attrs.getValue("maxColor") != null)
          maxColor = parseColor(attrs.getValue("maxColor"));
        if (attrs.getValue("minSize") != null)
          minSize = Float.parseFloat(attrs.getValue("minSize"));
        if (attrs.getValue("maxSize") != null)
          minSize = Float.parseFloat(attrs.getValue("maxSize"));

        Random rand = new Random(seed);

        float minR = minColor.r;
        float deltaR = maxColor.r - minR;
        float minG = minColor.g;
        float deltaG = maxColor.g - minG;
        float minB = minColor.b;
        float deltaB = maxColor.b - minB;

        for (int i = 0; i < count; i++) {
          // Note: in order to end up with an even distribution of stars, we can't just
          // use two raw random numbers.
          // We need to scale them such that tere are fewer stars near the poles than near
          // the equator.
          // The following lines should result in an even distribution.
          float theta = FastMath.TWO_PI * rand.nextFloat();
          float phi = FastMath.abs(FastMath.HALF_PI - FastMath.acos(rand.nextFloat()));
          float r, g, b;

          if (monochrome) {
            float dice = rand.nextFloat();
            r = minR + dice * deltaR;
            g = minG + dice * deltaG;
            b = minB + dice * deltaB;
          }
          else {
            r = minR + rand.nextFloat() * deltaR;
            g = minG + rand.nextFloat() * deltaG;
            b = minB + rand.nextFloat() * deltaB;
          }
          ColorRGBA color = new ColorRGBA(r, g, b, (phi / FastMath.HALF_PI));
          float size = minSize + rand.nextFloat() * (maxSize - minSize);

          Celestial cel = new Celestial(world, color, 0.0f, theta, phi, size, true);
          world.addWorldObject(cel);
        }
      }
      else if (localName.equalsIgnoreCase("incarnator")) {
        Vector3f location;
View Full Code Here


    @Override
    public void endElement(String uri, String localName, String qName) {
      // If the map has no celestials, add the defaults.
      if (localName.equalsIgnoreCase("map")) {
        if (numLights == 0) {
          Celestial c1 = new Celestial(world, new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f), 0.4f, World.compassToRadians(20), 45 * FastMath.DEG_TO_RAD,
              1.0f, false);
          Celestial c2 = new Celestial(world, new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f), 0.3f, World.compassToRadians(200), 20 * FastMath.DEG_TO_RAD,
              1.0f, false);
          world.addWorldObject(c1);
          world.addWorldObject(c2);
        }
      }
View Full Code Here

TOP

Related Classes of javara.world.environment.Celestial

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.