Android Open Source - acceptableLosses Asteroid Generator






From Project

Back to project page acceptableLosses.

License

The source code is released under:

MIT License

If you think the Android project acceptableLosses listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package acceptableLosses.map;
/* ww w .  java 2  s .  c om*/

import acceptableLosses.assets.TileType;
import acceptableLosses.work.jobs.DigJob;
import com.stewsters.util.math.Point3i;
import com.stewsters.util.noise.OpenSimplexNoise;

public class AsteroidGenerator {

    public static Region generateBasicAsteroid(Region region) {
        Point3i center = new Point3i(region.xSize / 2, region.ySize / 2, region.zSize / 2);
        int radius = Math.max(region.xSize, Math.max(region.ySize, region.zSize)) / 4;  //diameter is half the total space
        float radiusRange = radius / 25f;
        float edgeRandomness = 5f;
        float oreClumpRandomness = 10f;
        return generateGeneralAsteroid(region, center, radius, radiusRange, edgeRandomness, oreClumpRandomness);
    }

    public static Region generateGeneralAsteroid(Region region, Point3i center, int radius, float radiusRange, float edgeRandomness, float oreClumpRandomness) {

        OpenSimplexNoise openSimplexNoise = new OpenSimplexNoise();
        OpenSimplexNoise alternateOpenSimplexNoise = new OpenSimplexNoise();
        for (int x = 0; x < region.xSize; x++) {
            for (int y = 0; y < region.ySize; y++) {
                for (int z = 0; z < region.zSize; z++) {

                    int distSquared = ((x - center.x) * (x - center.x)) +
                            ((y - center.y) * (y - center.y)) +
                            ((z - center.z) * (z - center.z));
                    double randomValue = openSimplexNoise.eval(x / edgeRandomness, y / edgeRandomness, z / edgeRandomness);
                    double randomRadius = radius + (randomValue * radiusRange);

                    if (randomRadius * randomRadius > distSquared) {
                        region.tiles[x][y][z] = (alternateOpenSimplexNoise.eval(x / oreClumpRandomness, y / oreClumpRandomness, z / oreClumpRandomness) >= 0)
                                ? TileType.CARBON_ORE
                                : TileType.SILICON_ORE;
                    }

                }
            }
        }


        return region;
    }
}




Java Source Code List

acceptableLosses.AcceptableLossesGame.java
acceptableLosses.android.AndroidLauncher.java
acceptableLosses.assets.AssetLoader.java
acceptableLosses.assets.FurnitureType.java
acceptableLosses.assets.TileType.java
acceptableLosses.components.Appearance.java
acceptableLosses.components.Cargo.java
acceptableLosses.components.Citizen.java
acceptableLosses.components.Destination.java
acceptableLosses.components.Health.java
acceptableLosses.components.Path.java
acceptableLosses.components.Position.java
acceptableLosses.components.Resume.java
acceptableLosses.components.Sentience.java
acceptableLosses.components.Task.java
acceptableLosses.controls.GestureDetectorController.java
acceptableLosses.controls.InputManager.java
acceptableLosses.controls.ZoomInputProcessor.java
acceptableLosses.controls.commands.Command.java
acceptableLosses.controls.commands.TapCommand.java
acceptableLosses.desktop.DesktopLauncher.java
acceptableLosses.desktop.ImagePacker.java
acceptableLosses.map.AsteroidGenerator.java
acceptableLosses.map.Chunk.java
acceptableLosses.map.Furniture.java
acceptableLosses.map.MapTools.java
acceptableLosses.map.Region.java
acceptableLosses.map.Spawner.java
acceptableLosses.pathing.FastNonOptimalHeuristic.java
acceptableLosses.screens.GameScreen.java
acceptableLosses.screens.SplashScreen.java
acceptableLosses.systems.AiSystem.java
acceptableLosses.systems.AppearanceRenderSystem.java
acceptableLosses.systems.ElevationSystem.java
acceptableLosses.systems.FurnitureRenderSystem.java
acceptableLosses.systems.JobAssignerSystem.java
acceptableLosses.systems.MapRenderSystem.java
acceptableLosses.systems.MovementSystem.java
acceptableLosses.systems.PathFinderSystem.java
acceptableLosses.work.CivilianMover.java
acceptableLosses.work.jobs.DigJob.java
acceptableLosses.work.jobs.Job.java