Author Topic: Changelog - picture heavy  (Read 12082 times)

0 Members and 1 Guest are viewing this topic.

Offline Andy ONeill

  • Moderator
  • Equites
  • *****
  • Posts: 230
Re: Changelog - picture heavy
« Reply #105 on: May 15, 2018, 07:00:50 AM »
All modules
New Menu item template

Review and add/fix Shortcut/"hot" keys

Map Editor

Visibility toggle and opacity slider for
  •   Background
      Elevation
      Terrain



In the screen shot both the elevation map and terrain opacity are dialed down a little.
You can see the shortcut keys underlined because I've pressed the alt key.

Experienced Windows users will be used to seeing underlines like these showing shortcut or "hot" keys.
This is standard windows behaviour.
Pressing Alt, holding it and pressing another key matching one of the shortcuts invokes it.
Hence Alt+L then Alt+B would toggle the visiblity of any Background you have loaded.
You can also press Alt, L, B.
Again, this is standard windows behaviour for a menu.
You can use Notepad or office apps in this way.
Recent versions of Office give you a little black square with a white letter on it when you press alt to make these shortcuts clearer.
I may implement that later.

You can't see where the mouse is on that screen shot but it's over Elevation Map which makes it's sub menu "pop out" showing the opacity slider.

Rationalising geometry resources.
Geometries are used to define all the vectors used in the iconography.



Offline Andy ONeill

  • Moderator
  • Equites
  • *****
  • Posts: 230
Re: Changelog - picture heavy
« Reply #106 on: May 16, 2018, 05:20:51 AM »
Map Editor

Added groundscale.
You set this in an overlay which is toggled from the layers menu.



The two sort of rifle sights can be dragged around over two points you know the distance between.
You enter that distance in meters and click the save button.
The meters per pixel and overall size of the map are then calculated.



When you save the design of a map, the position of those two points and the amount you entered are saved.
Re-load such a map and toggle the overlay and you'll see the sights in the saved position.

When you use the google elevation data there is a known distance between your two map co-ordinates.
This is used to calculate the scale.
If you calculate the bottom co-ordinates or load the elevation data then this new data will be used for groundscale.
The positions of the sights will then be calculated.
This will over-write any data you already entered.
Meaning if you wanted to use real world elevation data but at a different scale then you would first load the elevation data and then later change the scale.
Don't reload the elevation data or re-calculate the corners (if you forget then don't save your changes).


Offline Andy ONeill

  • Moderator
  • Equites
  • *****
  • Posts: 230
Re: Changelog - picture heavy
« Reply #107 on: May 16, 2018, 01:04:56 PM »
Map Editor

Working towards allowing the user to "shape" elevation using drawing-app-like tooling.
This is not intended to be the primary way for anyone to input elevation but rather to "fix up" imported elevation data, for simplistic use in a "quick" scenario or as a back stop for someone who really doesn't want to use an image editor.

The original way of drawing the hypsometric elevation image takes a couple of seconds to run. This is OK for a one-off load but would require the whole image redrawing again in order to show any change.
It cannot be made more efficient without using a different approach.

I've added a new method which is a bit more efficient and will allow writing to parts of the image.
This is rather lower level stuff and hence tricky.
If necessary there's the potential to use pointers and "unsafe code" to make it faster again.
You might be thinking "Well just make it faster then!".
There would be a trade off though.
Such techniques come with an inherent higher risk of nastier bugs.
These might be necessary to get acceptable speed but a risk is a risk and best avoided.

 

Offline bayonetbrant

  • Chief Arrogance Mitigator
  • Musketeer
  • *****
  • Posts: 36968
  • Loitering With Intent
Re: Changelog - picture heavy
« Reply #108 on: May 16, 2018, 03:11:57 PM »
OK, so the important question - WHEN DO WE GET TO PLAY WITH IT?!?

;D
The key to surviving this site is to not say something which ends up as someone's tag line - Steelgrave

"their citizens (all of them counted as such) glorified their mythology of 'rights'...and lost track of their duties. No nation, so constituted, can endure." Robert Heinlein, Starship Troopers

Offline Andy ONeill

  • Moderator
  • Equites
  • *****
  • Posts: 230
Re: Changelog - picture heavy
« Reply #109 on: May 17, 2018, 02:07:21 AM »
My guess is December.
Still quite a bit of work to do.

I've started a separate thread.

Offline bayonetbrant

  • Chief Arrogance Mitigator
  • Musketeer
  • *****
  • Posts: 36968
  • Loitering With Intent
Re: Changelog - picture heavy
« Reply #110 on: May 17, 2018, 04:09:14 AM »
The key to surviving this site is to not say something which ends up as someone's tag line - Steelgrave

"their citizens (all of them counted as such) glorified their mythology of 'rights'...and lost track of their duties. No nation, so constituted, can endure." Robert Heinlein, Starship Troopers

Offline Andy ONeill

  • Moderator
  • Equites
  • *****
  • Posts: 230
Re: Changelog - picture heavy
« Reply #111 on: May 19, 2018, 10:15:41 AM »
Map Editor

I've added a quick n dirty prototype method to view and change the size of the area you paint with in the map editor.
Choose Drawing options and hover over one.
You will see a tooltip with the current size and a representation of that.
There are two rectangles.
The upper one is at 0.5 pressure which is what you get from a mouse.
The bottom one is at 1 pressure which you get if you press hard with a stylus or use the widening option on river.
Scroll the mouse wheel up or down in increase or decrease the size by 1 px.
This currently "works" for all of the options but is only meaningful for line.

Researching options to improve contour drawn elevations - so they give a gradual slope rather than a step.

All
Minor improvement to bevelled frame.


Offline Andy ONeill

  • Moderator
  • Equites
  • *****
  • Posts: 230
Re: Changelog - picture heavy
« Reply #112 on: May 22, 2018, 04:14:52 AM »
Map Editor

Fixed Bug failed to reset isbusy flag/indicator on re-opening saved map

Prototype greyscale calculation.

This uses the data from contours.
You need to set low and high so it "knows" the expected range of black through to white.
Set all the parameters, click the calculate button and you get a grey layered effect initially.


Checking the blurred box adds a gaussian blur effect which will then result in a slope rather than cliff when converted to elevation values

Note that the contour line will be towards the edge of the gradient rather than the "top" and hence the expected elevation will be somewhat inside it.
Often the exact elevation at a point isn't really going to matter so much so that few metres won't have any noticeable effect.
If this will be an issue for a map you're drawing, you can either draw your contours slightly further out or give them a higher value.

Hiding the terrain ( which is just contour lines in this case ):


I then have some code which grabs the pixels and translates the grey scale into metres.
Then redoes the hypsometric elevation picture


This is still very much a prototype and needs more work.
But.
The results look pretty good. Certainly way better than cliff edges.

Note:
This is never going to be as sophisticated as you can do using the likes of photoshop. On the other hand, probably good enough for most purposes with an almost zero learning curve.
And... this is just one option. 
You'll still be able to import an image created externally.
Or at least you will once I write that part.

Offline Andy ONeill

  • Moderator
  • Equites
  • *****
  • Posts: 230
Re: Changelog - picture heavy
« Reply #113 on: May 23, 2018, 04:30:56 AM »
Map Editor

Remove "old" code which set elevation based purely on contour height when saving a map.
Save new generated elevations
Respect default height
Limit input of (GreyScale elevation) values to numbers

Bug fixing and refactoring greyscale code.

Greyscale image import.
You now select between using Contours or Picture to generate a greyscale based set of elevations.
You can do both but whichever values you save last will be used.

Although a greyscale picture of the right proportion is advisable, this should handle any image you have.
That includes coloured ones.  These will be translated to greyscale based on tone.
If the picture is the wrong sort of shape it will be stretched.




Note that no particular validation is done on what you enter in this view.
If you set a low higher than the high then bad things are going to happen.

The interval is not used for anything yet.
The plan is to speed up allocating a value to contour height.
I may instead move this to the contours option settings.

Offline Andy ONeill

  • Moderator
  • Equites
  • *****
  • Posts: 230
Re: Changelog - picture heavy
« Reply #114 on: May 24, 2018, 03:21:19 AM »
Hypsometric Elevation Image

Optimising algorithm which creates the bitmap.
Exactly how this works is pretty technical stuff involving building a huge array of bytes with 4 per pixel holding blue, green, red and alpha values.

Rather than working out each colour to use for an elevation dynamically I've built a collection of 255 colours.
I then work out which of those 255 "bands" any elevation would be in and use that colour.
The downside of this is that I can't now easily make this user configurable.
OTOH the processing savings are significant.

This may read as pretty dry stuff but it's huge.
Overall, the changes cut building one example picture down from a rather stately 2.68 seconds to 4 milliseconds.
That makes rebuilding the entire image as someone "shapes" a hill or valley practical and should just be a brief flicker rather than noticeable wait.


Offline Andy ONeill

  • Moderator
  • Equites
  • *****
  • Posts: 230
Re: Changelog - picture heavy
« Reply #115 on: May 26, 2018, 04:11:37 AM »
Scenario Editor
Use new optimised hypsometric routine

Map Editor
Improving background file picker selection filter
Changed font used for drawing options to reduce number of different fonts on screen
Ephinol font as default for the left panel (tabcontrol) 


Rationalised elevation storage ( it was stored in both designer and map data ).

Started Shapers.
These are intended for a bit of "fixing up" rather than drawing an entire map.
That's the plan at the moment anyhow.
Having said that.
Due to the optimisation work, I can redraw the entire map very quickly.
That has removed one of the obstacles to somewhat more ambitious shaping.

The tooling needs more styling work but the idea is you pick one of the shapers from a list.
The various attributes of that shaper can then be set in the area above the list.
These will vary from one shaper to another.
There will (obviously) be more than one once I write them.

What I've done is the first iteration of flatten.
This allows you to set the same elevation for an elliptical area.
The two sliders allow you to adjust the size vertically and horizontally.
If they both have the same value then the ellipse is a circle.

In these pictures I'll remove the lion's mound from the waterloo battlefield.
https://en.wikipedia.org/wiki/Lion%27s_Mound



You then drag the ellipse over the area you want to set.
Right click somewhere on the map to "pick up" the elevation from there
Or
Over type in the set elevation textbox.



Either right click the ellipse, press return or click the apply button.
The elevation is applied to all the points under the ellipse and the map redrawn.



In the final picture, I've then dragged the ellipse back off the map.
The mound is no more.
You can't see the redrawing happen immediately because the ellipse is on top of the area changed.
The processing and redrawing the map is so fast it appears to be pretty much instant.

I then changed the ellipse so it's transparent with a white outline.

You can then see the bit of terrain you're about to change.
Counter - intuitively it seemed to me to be a bit harder to work out exactly where the edges of what I was about to change were.
Having said that, you can easily drag the marker round a bit and right click to do a bit more.
This was part of the idea of the right click to apply.

I could potentially allow the user to pick fill and outline.





Offline Andy ONeill

  • Moderator
  • Equites
  • *****
  • Posts: 230
Re: Changelog - picture heavy
« Reply #116 on: May 28, 2018, 08:11:08 AM »
Map Editor

Added small brass slider templates


Started work on Hill shaper

Offline Andy ONeill

  • Moderator
  • Equites
  • *****
  • Posts: 230
Re: Changelog - picture heavy
« Reply #117 on: May 29, 2018, 07:54:44 AM »
Map Editor

Hill shaper, first iteration.

You define an ellipse and drag it round like flatten but hills are assumed to be bigger.
I did this with an otherwise totally empty map.

Enter an elevation for the peak of the hill


Clicking apply gives:


I'm smoothing the values from high to low using a formula called smootherstep.
You can read more about that:
https://en.wikipedia.org/wiki/Smoothstep
The idea is to give the top and edges a curve rather than straight line trend.
Like a real hill.

All Shapers ( other than flatten ) will be additive.
The calculated values for the hill are added to whatever elevation each qualifying "cell" already has.
Hit apply twice and you'd get double the set height.

You can enter a negative number to scoop out a hollow.


I also need to allow the user to rotate the hill, the current approach only gives you vertical or horizontal ellipses.
Or a circle.

Refactoring flatten code to make it more generic and re-usable
Fixed a couple of bugs in flatten

Offline Andy ONeill

  • Moderator
  • Equites
  • *****
  • Posts: 230
Re: Changelog - picture heavy
« Reply #118 on: May 30, 2018, 12:41:09 PM »
Map Editor

Allow rotation of hill shaper.
This turned out to be much harder than I expected.
The problem is that the grid of elevations I need to work with is integer based for x and y co-ordinates.
However, when you rotate a point it gives you a non integer result.
When you round to an integer this leaves gaps
Plan B turned out to be an extremely expensive process which I then had to multi thread to reduce the time it takes.



Note the effect of adding an overlapping hill.

There are a couple of issues including speed ( ~4 seconds ).
More to do.


Offline Andy ONeill

  • Moderator
  • Equites
  • *****
  • Posts: 230
Re: Changelog - picture heavy
« Reply #119 on: May 31, 2018, 03:34:24 AM »
Hill shaper.

Avoid rotation interfering with dragging.

Speed optimisation ( via threading and reducing lists used ).
Now roughly 2 seconds on my machine for the hill you see above.

Bigger hills take longer because there are more calculations.
« Last Edit: June 01, 2018, 02:35:57 AM by Andy ONeill »