Source code for my Procedural Cavern Generation tutorial series. Watch here: https://www.youtube.com/playlist?list=PLFt_AvWsXl0eZgMK_DT5_biRkWXftAOf9
Note that the Unity Project available here may contain features not included in the series.
License: MIT License
Source code for my Procedural Cavern Generation tutorial series. Watch here: https://www.youtube.com/playlist?list=PLFt_AvWsXl0eZgMK_DT5_biRkWXftAOf9
Note that the Unity Project available here may contain features not included in the series.
https://gist.github.com/soraphis/eca47b2fcce35fb891a2e79ceb25bcc7
I'd do a minor change so you can replace this switch-case monster.
the logic behind this:
for each corner who can be active, we fill the corner and its adjacent nodes into a list. (also in clockwise order)
(so for each corner we would add 3 nodes)
if the first node we want to add is equal the last node in the list, we have adjacent control nodes which we want to add, so we don't need to add the node in between -> remove it from the list.
after processing all 4 cornerns, we need to make the same check for the first and the last node in the list. if they are the same, remove them.
Hi Sebastian,
Is the code under any license? It would be cool to use it for other projects.
Thanks in advance.
RandomFillMap() function uses Time.time (time since start of game) as seed. It should use system time instead.
Is it me or some maps don't connect all rooms? An example:
###############################################
##################...##########################
#################.....#########################
#################......########################
###############..##....########################
##############...###...########################
#############....######....####################
############.......####.....########..#########
####..######........####....#######.....#######
###....######.......####....#######......#..###
##.....#########...######..########..........##
##.....#########....################.........##
###.....#########..##################........##
##.......#############################.......##
##........#############################.....###
###........#############################...####
###.........#############################...###
###...........####################..#####....##
###............##################....#####..###
###............##################....##########
####..####....####################..###########
###############################################
After connection, the two rooms in the right are disconnected from the rest:
###############################################
##################...##########################
#################.....#########################
#################......########################
###############..##....########################
##############...###...########################
#############....######....####################
############.......####.....########..#########
####..###...........####....#######.....#######
###......####.......####....#######......#..###
##.....#########...######..########..........##
##.....#########....################.........##
###.....#########..##################........##
##.......#############################.......##
##........###########################.#.....###
###........#########################.###...####
###.........########################.####...###
###...........####################..#####....##
###............##################....#####..###
###............##################....##########
####..####....####################..###########
###############################################
Hello, I am having an issue when it comes to setting a material to the Walls mesh. When i set a a tiled texture the top of the walls get the texture while the walls themselves only get a color but no texture. Could you explain to me how to fix this?
The CreateWallMesh()
for the 3d version seems to always end up with some missing triangles in the mesh for any part of the auto generated mesh that looks like an island, see the middle two isolated group of vertices in the attached image. The missing triangles are always the ones on the southeast edges.
I dont get what your doing in this episode, but i'll do an "episode 4" update of issue #4
source code can be found here: https://gist.github.com/soraphis/a752a52a181f5612422765451202d6c9#file-meshgenerator_chapter4-cs-L100
it bothers me really that you store everything twice, instead of using an switch-case for 0, 1, 2 and default in the indexer.
but this struct is not needed entirely, go on reading
why do you switch the triangle order at the beginning for the swith-cases 1, 2 and 4?
the triangle ABC has the same orientation as BCA and CAB.
you can always add each Control Node to this, because and outline will never contain this.
thinking this further, leaves us with the following:
(method: TriangulateSquare)
so we need a way to find those node pairs, which are connected with an outline.
so we need to check the control nodes which are inactive.
so for each inactive control node, check the previos node if its in the list -> it will become pair[0]
and check the next node if its in the list -> it will become pair[1]
with this way we can find every vertex the outline is made out of. we need to add them in an efficient way: dictionary<int, int>
so we have an mapping from_vertex_index to to_vertex_index
this is all we need. just add the CreateWallMesh method, (mostly) like you did (just iterating a bit different cause we have a dict<int, int> instead of double nested lists and loops and checking in hashsets and so on.
100 lines of code less, no need for a Triangle struct. way less loops and whatever. this should be a huge performance increase
edit: just tested the performance
150 x 150 map, 49% fill chance
my script is in average 5 milliseconds faster, which are around 10%
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.