Custom Terrain Editor in Java

Started by mopa42, April 02, 2011, 05:00:16 PM

Previous topic - Next topic

MadMag

1. Functions
2. Interface
3. More pre buildt brushes
4. Terrains

mopa42

I'm glad you guys like the editor. I wasn't sure about releasing it, with CW2 almost out, but thought that there was no penalty for just putting it out there if anyone wanted to use it.

Quote from: DarthVader12 on April 04, 2011, 02:37:28 PM
you are going to update it right? ;)
Yes. I plan to keep working on the editor until it is as useful and complete as I can make it.
But to do that, I need to know what broken features to fix and what new features people would like me to add.
Here's my short list of stuff I want to add:

  • Ability to read and display the custom background image when opening an existing map file
  • Ability to set the custom background to a new image (and have it show up if you save to a cwm file
  • Save dialogs that add the appropriate file extension so you don't have to type it yourself
  • Help / documentation, like an example of what happens when you use each tool

Quote from: MadMag on April 09, 2011, 01:35:56 PM
1. Functions
2. Interface
3. More pre buildt brushes
4. Terrains
Can you be more specific? What new brushes should I add?

So in general, if you guys can suggest improvements or new tools or whatever, there's a good chance I'll add them to the code.

mopa42

#17
First update is here!
(download TerrainEdit-Latest.zip on the first post).

New features:

  • Documentation!
  • Displays the custom background of a map (and you can set it to a new custom background image).
  • New tool option - pick elevation to paint from first click.
  • File chooser dialogs now add the appropriate file extension if you don't type it.
  • Layer shading method is closer to how the game displays them (multiply instead of alpha composite, if that makes sense).
  • Can change the visual style of the application (to look more like windows or a bluer java look).

I'd like to add some more tools/actions/brushes, but I don't know what else to add.
If you suggest something, I can probably have it in the next update.

J

Could you let us create emitters with special futures?

ontheworld

You mean like 5/4/5/4/5/4/5/4  amounts emitters?

mopa42

Quote from: J on April 14, 2011, 02:02:36 PM
Could you let us create emitters with special futures?
Do you mean stacked emitters? And seeing and editing a "timeline" like thing for what the cumulative effect of the stacked emitter is?

thepenguin

Quote from: mopa42 on April 18, 2011, 12:58:51 AM
Quote from: J on April 14, 2011, 02:02:36 PM
Could you let us create emitters with special futures?
Do you mean stacked emitters? And seeing and editing a "timeline" like thing for what the cumulative effect of the stacked emitter is?

YES! YES! YES! that will make this something worth looking into
We have become the creeper...

J

Or an emitter that starts when it's hit by creeper

Grauniad

It is a map editor, not a mechanism to change the game mechanics.
A goodnight to all and to all a good night - Goodnight Moon

UpperKEES

Quote from: mopa42 on April 18, 2011, 12:58:51 AM
Do you mean stacked emitters? And seeing and editing a "timeline" like thing for what the cumulative effect of the stacked emitter is?

This would be totally awesome. I always had to use MS Excel to calculate all emitter increases and delay times. Please keep in mind that stacked emitters are emitting from bottom to top when emitting in the same frame, so only the last one has an effect when intervals coincide. This effect can also be used to stop an emitter.
My CW1 maps: downloads - overview
My CW2 maps: downloads - overview

mopa42

#25
Ok, I've got a preliminary release that lets you edit emitters.

Here's what's new:

  • Displays the emitters in a map
  • Can handle multiple emitters
  • Add new emitters using a brush system similar to terrain
  • Select emitters to move around and edit details
  • A timeline view of the selected emitters

In order to make that happen, I've come up with an algorithm that I hope simulates how the game behaves accurately enough.
Here's a snippet of the actual code:

creeperDepth = new float[frameCount];
float lastValue = 0;
for (int frame = 0; frame < frameCount; frame++) {

   // apply each emitter in turn (the last one in the list - the one on top - overrides others)
   float thisValue = 0;
   boolean anyFired = false;
   for (int i = 0; i < N; i++) {
       if (frame >= starts[i] && (frame - starts[i]) % intervals[i] == 0)  {
           thisValue = intensities[i];
           anyFired = true;
       }
   }

   // determine any special behavior when no emitters are active this frame
   switch (mode) {
       case DROP:
       default:
           if (!anyFired) thisValue = simParam; // simParam is value to drop to
           break;
       case HOLD:
           if (!anyFired) thisValue = lastValue;
           break;
       case DECREASE:
           if (!anyFired) thisValue = Math.max(0, lastValue - simParam); // simParam is decrease rate per frame
           break;
   }

   // record the depth
   creeperDepth[frame] = thisValue;
   lastValue = thisValue;
}


In each frame, I apply each emitter in order (which will be from bottom to top, low Z to high Z). This means that only the topmost emitter applies when they overlap.
I've given a couple of options for the simulation. They specify what happens when no emitters emit in a given frame. In the actual game, the creeper will spread out following the whole creeper flow model with the terrain and everything. There's no way I'd be able to duplicate that in-editor. Instead, you can choose between having the emitter level drop immediately to zero (or another number), hold at its old value until changed by another emitter, or decrease at a constant rate per frame (which sort-of simulates creeper flow). These options should give some flexibility to have the simulation give you a useful model for what actually happens.

There is one detail which I haven't included. In the game, creeper is only updated every 7 frames. I'm not exactly sure how to model that, or if modeling it would be useful.
Other know bugs:

  • Moving or deleting hundreds of emitters at once is really slow
  • There's no easy way to reorder emitters up and down - fixed in 0.6
  • You can't undo/redo emitter changes like you can terrain changes


I'd like some feedback on this tentative release.

  • If you've already got a map that you've tuned with stacked emitters, does the program display the timeline accurately? Does the map remain the same when you open it in my program then save it again?
  • Is the timeline understandable? Useful? Does it need to be more configurable or do something differently?
  • Are any of the new user interface elements hard to use or confusing?

Edit - spelling, known bugs
Edit - updated bugs/features for now 0.6, added screenshot

Michionlion

i just tried that out:  Awesome!!!!  now i can do what upper, and fish and other people did with absolutely no knowledge of how to code.  thanks
"Remember kids, the only difference between science and messing around is writing it down."
                                                                                                                         - Adam Savage

My website
My CW1, and CW2 maps!

mopa42

One more update (maybe the last). I've added a really slick new feature: random terrain generation!
It is similar to Chronom maps in that both generate terrain starting from a seed value, but it uses a different algorithm. I used the diamond-square algorithm, Chronom uses Perlin noise.
There are three fun sliders to play with and a bunch of presets for different behavior.
The cool thing is you can set how similar the generated terrain is to the start terrain, so you can either generate all-new terrain or just add some randomness to the edges of your existing terrain.
I think you'll really like it. I had lots of fun playing with it.



Other new stuff:

  • The option to link columns when editing emitters in the table (changing the interval of one will change the interval of all).
  • Show Z-value (height in stack) of emitters in the table.
  • Drag emitters in the list to reorder them (the Z-value and index update automatically).
  • Make a fancy custom brush by copying the shape of the selection in the editor.

We're now at version 0.6.
Download it as TerrainEdit-Latest.zip on my first post.

thepenguin

#28
very nice, :)
We have become the creeper...

Michionlion

"Remember kids, the only difference between science and messing around is writing it down."
                                                                                                                         - Adam Savage

My website
My CW1, and CW2 maps!