Automap (indoor & dungeon) implementation

Discuss Daggerfall Unity and Daggerfall Tools for Unity.
Post Reply
User avatar
Nystul
Posts: 1357
Joined: Mon Mar 23, 2015 8:31 am

Automap (indoor & dungeon) implementation

Post by Nystul » Wed Nov 11, 2015 8:57 pm

Hi folks!
I create a seperate thread for this feature since discussion in thread viewtopic.php?f=18&t=150&start=50 is in danger to be too much spammed with automap implementation related questions
I want to give a short overview of what I have been able to achieve and what is still ahead of the road...

First see the screenshot below:

Image

things accomplished:
  • automap background screen and geometry rendering above it (just the default scene geometry for the moment)
  • control/navigation buttons implemented (tried to match behavior of vanilla daggerfall)
  • 2D/3D view implemented
  • integrated compass hud
  • mouse wheel zooming
  • dragging around geometry by drag and drop with left mouse button
  • change camera tilt by mouse wheel up/down above grid button (didn't find a better control for it)
  • set rotation pivot point to player position by right-clicking the grid button (this is useful since navigation buttons shift this pivot point like it is implemented in vanilla daggerfall)
open tasks:
  • rotation by drag and drop with right mouse button
  • the mini-overview of the rdb-blocks of the current dungeon with the player and start marker
  • discovering of an initial unknown dungeon
  • render a new instance of the geometry without npc and monster sprites, markers, etc., change material of meshes to custom material with custom shader to support stuff like:
    • level slicing/hiding geometry (hiding geometry levels about current player's level - vanilla daggerfall did this)
    • corridor hiding (vanilla daggerfall had this with left and right click on geometry - not sure if I will implement this in a similar way - I think transparency as mentioned below will do the trick as well)
    • transparency used for geometry in front of the player occluding the player position/corridor
    • alpha-blending used for geometry behind the "plane" in the distance of the player to the camera to make it easier to differ between near geometry and geometry further away
    • color vs. grayscale rendering of geometry (I plan to render geometry in grayscale that has been discovered in a previous dungeon run and color the geometry revisited (or newly discovered) in the current dungeon run - of course it would be nice to further save this data about what has been discovered in which dungeon to savegames as well)
    • optional custom art-like shading (to make the map look more like it had been drawn by hand) in the future
so what do you think about it? any further ideas how to improve the automap?

User avatar
LypyL
Posts: 514
Joined: Sun Mar 22, 2015 3:48 am

Re: Automap (indoor & dungeon) implementation

Post by LypyL » Wed Nov 11, 2015 9:14 pm

I love it! You made impressive progress.

How about the ability to place some markers (and maybe a way to find them, like a button that will cycle through the placed markers).

User avatar
Interkarma
Posts: 4712
Joined: Sun Mar 22, 2015 1:51 am

Re: Automap (indoor & dungeon) implementation

Post by Interkarma » Wed Nov 11, 2015 9:39 pm

This is awesome! I'm loving where this is going. :D

It's hard to tell from the screenshot, what resolution is the render running at?

User avatar
Nystul
Posts: 1357
Joined: Mon Mar 23, 2015 8:31 am

Re: Automap (indoor & dungeon) implementation

Post by Nystul » Wed Nov 11, 2015 9:55 pm

930x568 in unity editor. there are placement issues with the panel used for geometry rendering and compass. Both seem to shift dependent on the resolution - will have to find out the reason for this. Especially the geometry panel is way out of place when I check "maximize on play".

User avatar
Interkarma
Posts: 4712
Joined: Sun Mar 22, 2015 1:51 am

Re: Automap (indoor & dungeon) implementation

Post by Interkarma » Wed Nov 11, 2015 10:17 pm

Do you parent the render and compass controls to ParentPanel or to NativePanel? That will have a big impact on how elements are arranged.

I'm about to head to work, but I'm happy to code up some quick examples later to show how to keep everything in place. If you're happy to share your work so far (I can setup another branch for testing) we can collaborate a little.

I know the UI stuff is kind of raw, and special-purpose, and has a steep learning curve. :lol: I can probably help with some tricks to short-cut that learning curve a little.

User avatar
Nystul
Posts: 1357
Joined: Mon Mar 23, 2015 8:31 am

Re: Automap (indoor & dungeon) implementation

Post by Nystul » Wed Nov 11, 2015 11:10 pm

of course I would be happy to share and collaborate ;)
though this must have to wait till tomorrow - quite late here right now and I am already in error-mode due to tiredness

currently parent panel

BansheeXYZ
Posts: 472
Joined: Fri Oct 23, 2015 8:19 pm

Re: Automap (indoor & dungeon) implementation

Post by BansheeXYZ » Thu Nov 12, 2015 2:47 am

I don't think manual markers would be all that useful. The map should automatically flash the exit block, for one thing. Another thing that would be extremely useful is a make route and clear route button. Clicking a block on the automap would trace a route from the current player position to the destination block. You could then draw a line near the floor for the player to follow. This would make the games ridiculously large dungeons easier to navigate because you wouldn't have to constantly survey the map just to backtrack.

Alternatively, you could create some kind of "fast travel" button for dungeons that would enable the player to more-or-less warp to an already explored block in exchange for an hours passage of time.

User avatar
Interkarma
Posts: 4712
Joined: Sun Mar 22, 2015 1:51 am

Re: Automap (indoor & dungeon) implementation

Post by Interkarma » Thu Nov 12, 2015 8:53 am

Nystul wrote:of course I would be happy to share and collaborate ;)
though this must have to wait till tomorrow - quite late here right now and I am already in error-mode due to tiredness

currently parent panel
Cool! :)

Using ParenPanel would be part of the positioning issue. ParentPanel always stretches to fill the whole screen and it does not respect aspect ratio. Think of ParentPanel as a canvas that always stretches to the whole screen (maybe I should rename to ScreenPanel).

NativePanel however will always try to keep the same aspect ratio regardless of screen resolution, as it uses Scaling.ScaleToFit relative to parent screen panel. And even though NativePanel is mainly designed to house native 320x200 UI elements, you can also use it for high resolution elements that still align themselves properly. Here's a summary of technique.
  • Compass is easy, as it's a native UI component. Just stick it in NativePanel at the right Position and it will take care of itself.
  • For render area, create a dummy Panel as a child to NativePanel with the dimensions you need to fill in that area. Nothing will actually go in this panel, we'll just use it for sampling correct rectangle inside of native UI area..
  • Then create another Panel as a child to ParentPanel with Scaling.None set. This will be our high-res panel to receive render.
  • Every Update() set render panel Size and Position in screen space by sampling dummy panel Rectangle.
I hope that makes sense. I'm happy to write up an example control for you as well to show the technique. :)

User avatar
Nystul
Posts: 1357
Joined: Mon Mar 23, 2015 8:31 am

Re: Automap (indoor & dungeon) implementation

Post by Nystul » Thu Nov 12, 2015 9:18 am

Interkarma wrote: Cool! :)

Using ParenPanel would be part of the positioning issue. ParentPanel always stretches to fill the whole screen and it does not respect aspect ratio. Think of ParentPanel as a canvas that always stretches to the whole screen (maybe I should rename to ScreenPanel).

NativePanel however will always try to keep the same aspect ratio regardless of screen resolution, as it uses Scaling.ScaleToFit relative to parent screen panel. And even though NativePanel is mainly designed to house native 320x200 UI elements, you can also use it for high resolution elements that still align themselves properly. Here's a summary of technique.
  • Compass is easy, as it's a native UI component. Just stick it in NativePanel at the right Position and it will take care of itself.
  • For render area, create a dummy Panel as a child to NativePanel with the dimensions you need to fill in that area. Nothing will actually go in this panel, we'll just use it for sampling correct rectangle inside of native UI area..
  • Then create another Panel as a child to ParentPanel with Scaling.None set. This will be our high-res panel to receive render.
  • Every Update() set render panel Size and Position in screen space by sampling dummy panel Rectangle.
I hope that makes sense. I'm happy to write up an example control for you as well to show the technique. :)
ah thanks! this will definitely help! As soon as I have it working to a certain point I will let you know and share a link to the git branch

update:
render panel with the dummy panel is kind of working now

compass positioning is a bit tricky - looks like it is always positioned on the bottom right because HUDCompass.DrawCompass() always does:

Code: Select all

compassBoxRect.x = Screen.width - (compassBoxTexture.width * Scale.x);
compassBoxRect.y = Screen.height - (compassBoxTexture.height * Scale.y);
will take a closer look at it...

meanwhile, there is a branch called "automap-playground" in my github repo (https://github.com/Nystul-the-Magician/ ... -unity.git) which is intended for collaborating.

User avatar
Interkarma
Posts: 4712
Joined: Sun Mar 22, 2015 1:51 am

Re: Automap (indoor & dungeon) implementation

Post by Interkarma » Thu Nov 12, 2015 8:27 pm

Nystul wrote: compass positioning is a bit tricky - looks like it is always positioned on the bottom right because HUDCompass.DrawCompass() always does:

Code: Select all

compassBoxRect.x = Screen.width - (compassBoxTexture.width * Scale.x);
compassBoxRect.y = Screen.height - (compassBoxTexture.height * Scale.y);
My bad, I will fix that. Compass was written before the GUI system, so it still has a couple of single-purpose assumptions in there.

Edit: Fix is on git now. The compass can now accept any arbitrary alignment. Just let me know if any more problems with this script.
Nystul wrote: meanwhile, there is a branch called "automap-playground" in my github repo (https://github.com/Nystul-the-Magician/ ... -unity.git) which is intended for collaborating.
Awesome will check it out! :)

Post Reply