Code Monkey home page Code Monkey logo

hmapprocessor's Introduction

HMapProcessor

There are tools that can sculpt a Terrain by hand (like SceneEditor); this instead is an API for programmatically alter the heightmap of a Terrain. For example, you can create a randomly generated terrain that has a volcano on the north, a pear-shaped lake on the south and a road in between.

The core concepts

You provide an initial HeightMap to the Heightmap processor, which apply a transformation and outputs the processed Terrain in .j3o format (so that you can use it as is or loat it on the SceneEditor for further manual editing). The neat thing is that transformation can be chained together to create interesting combination!

How to use a HeightmapProcessor

We use here a basic HeightmapProcessor that sets the height to a fixed value.

    float f[] = new float[1089];
    for (int i = 0; i < f.length; i++) {
        f[i] = 200;
    }
    HeightmapProcessor hmp = new HeightmapProcessor(f);
    FixedHeightProcessor.fixedHeight(hmp, 22);

Regardless of the input, the Terrain output should be perfectly flat at the height 22. Awesome! But before you start throwing rotten eggs at me, please let me introduce…

Masks

The Mask is basically an editing selection for the HeightmapProcessor: it allows or forbid the modification of subregions of the Terrain. By default, the NoMask is applied (so that all the Terrain can be modified). Here we use a simple maks that allow modification only on the “western” area of the Terrain

    HeightmapProcessor hmp = new HeightmapProcessor(f);
    hmp.setFilter(new HorizontalMask(10, true));
    FixedHeightProcessor.fixedHeight(hmp, 0);

Boolean logic masks

Masks can be combined together with boolean logic. In the next example, we create a mask that allow editing on the “north-west” area of the Terrain.

    HeightmapProcessor hmp = new HeightmapProcessor(f);
    hmp.setFilter(new BooleanANDMask(
            new VerticalMask(10, true), new HorizontalMask(10, true));
    FixedHeightProcessor.fixedHeight(hmp, 0);

The allowed boolean masks are: AND OR NOT

???Processor

We have talked about HeightmapProcessor for editing the heightmap of a Terrain. However, we could think of a heightmap as a “just a map”. For example, if I decide that “0” on the map is an empty space, “1” is a wall, “2” is a monster an so on, then the processor can be abused as a level editor.

hmapprocessor's People

Contributors

pesegato avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

vcgato29

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.