Code Monkey home page Code Monkey logo

procedural-cave-generation's People

Contributors

gregbilodeau avatar seblague avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

procedural-cave-generation's Issues

Tiling Walls

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?

Episode 4

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

Triangle struct

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

TriangulateSquare() orientation changes

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.

optimizations with "checkedVertices".

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)

  • an outline is always between two nodes (not control nodes)
    • these nodes are in the list give to "MeshFromPoints"
    • and per square can always be just 1 outline, except for the diagonals-case.

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%

Episode 3: swicht-case-monster

https://gist.github.com/soraphis/eca47b2fcce35fb891a2e79ceb25bcc7

I'd do a minor change so you can replace this switch-case monster.

  • Square class, put Control Nodes and Nodes into arrays.
    rule: they are filled clockwise. and node[i] is between cnode[i] and cnode[(i+1)%4]
  • replace the TriangluateSquare method with what you see in the link above.

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.

Island meshes missing some triangles in 3d version

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.

capture

License

Hi Sebastian,
Is the code under any license? It would be cool to use it for other projects.
Thanks in advance.

Some maps don't connect rooms properly

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:

###############################################
##################...##########################
#################.....#########################
#################......########################
###############..##....########################
##############...###...########################
#############....######....####################
############.......####.....########..#########
####..###...........####....#######.....#######
###......####.......####....#######......#..###
##.....#########...######..########..........##
##.....#########....################.........##
###.....#########..##################........##
##.......#############################.......##
##........###########################.#.....###
###........#########################.###...####
###.........########################.####...###
###...........####################..#####....##
###............##################....#####..###
###............##################....##########
####..####....####################..###########
###############################################

random seed

RandomFillMap() function uses Time.time (time since start of game) as seed. It should use system time instead.

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.