Code Monkey home page Code Monkey logo

marching_squares's Introduction

marching_squares

Screenshot 2023-05-29 at 11 22 18

Marching squares implemented in Bevy, with a mesh that updates every frame! Egui is used for an interactive settings menu.

If you would like to try making this yourself...

Rather than trying to read my pile of spaghetti code, I recommend watching this video by The Coding Train. When it comes to implementing Lerping (which is not covered in the video), you can use an inverse lerp function with your two points' values as a and b, and your threshold as the "value" argument. It will return a t value, representing how far along the threshold is between your two values. You can then use this to move mesh points around.

I found this project useful in learning procedural mesh generation in general. The "positions" describe all of the vertices, and the indicies describe which vertices are used to create each triangle. This allows rendering a quad with only 4 vertices instead of 6, for example, as some vertices are reused. When it came to spawning the mesh, I followed this bevy example that spawned a default quad mesh.

If you want to update the mesh, remember to query for a Mesh2dHandle instead of a Handle<Mesh>, this just being an annoying inconsistency between 2D and 3D in Bevy.

marching_squares's People

Contributors

dot32dev avatar dependabot[bot] avatar

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.