boristhebrave / mc-dc Goto Github PK
View Code? Open in Web Editor NEWDemonstration code for Marching Cubes and Dual Contouring
Demonstration code for Marching Cubes and Dual Contouring
Just reading through your article series, enjoying it very much. You describe in the article about marching cubes 3D that there are 3 extra cases in additional to the original ones. How do you decide though if you use the extra case or the original one? I've checked your code, but it doesn't seem to do any kind of case distinction to facilitate this. So your code ignores those extra 3 cases?
Hi @BorisTheBrave , thanks for you amazing mc-dc tutorial. I'm new to marching cubes and really enjoyed your tutorial and code. I have a question, how can i modify the resolution of mc/dc? (i.e., change the grids resolution from 333 to 161616) I tried to change XMIN/XMAX etc but the number of vertices always the same. Thanks!
Hi Boris. First of all thanks for your tutorial. Thanks to you I was able to start my own implementation of the marching cubes algorithm in the Godot Engine.
However I don't know how to deal with this case:
It works ok if I don't use inverse cases:
But if I invert the values of the vertices I get the ambiguos cases:
Is there a way to fix this or should I just give up and move on to dual contouring?
Thanks for your wonderful work and demostration, which helps me a lot!
Yet there are some bugs in the file marching_cube_2d.py
which may makes misunderstanding probably.
The correct file will be shown below :
if case is 0 or case is 15:
#
return []
if case is 1 or case is 14:
#
return [Edge(Node2D(x+0+adapt(x0y0, x1y0), y), Node2D(x+0, y+adapt(x0y0, x0y1))).swap(case is 14)]
if case is 2 or case is 13:
#
return [Edge(Node2D(x + 0, y + adapt(x0y0, x0y1)), Node2D(x + adapt(x0y1, x1y1), y + 1)).swap(case is 13)]
if case is 4 or case is 11:
# Single corner
return [Edge(Node2D(x + 1, y + adapt(x1y0, x1y1)), Node2D(x + adapt(x0y0, x1y0), y + 0)).swap(case is 11)]
if case is 8 or case is 7:
# Single corner
return [Edge(Node2D(x+adapt(x0y1, x1y1), y+1), Node2D(x+1, y+adapt(x1y0, x1y1))).swap(case is 7)]
if case is 3 or case is 12:
# Vertical split
return [Edge(Node2D(x+adapt(x0y0, x1y0), y+0), Node2D(x+adapt(x0y1, x1y1), y+1)).swap(case is 12)]
if case is 5 or case is 10:
# Horizontal split
return [Edge(Node2D(x+0, y+adapt(x0y0, x0y1)), Node2D(x+1, y+adapt(x1y0, x1y1))).swap(case is 5)]
if case is 9:
# Two opposite corners, copy cases 1 and 8
return [Edge(Node2D(x + 0 + adapt(x0y0, x1y0), y), Node2D(x + 0, y + adapt(x0y0, x0y1))),
Edge(Node2D(x + adapt(x0y1, x1y1), y + 1), Node2D(x + 1, y + adapt(x1y0, x1y1)))]
if case is 6:
# Two opposite corners, copy cases 2 and 4
return [Edge(Node2D(x+1, y+adapt(x1y0, x1y1)), Node2D(x+adapt(x0y0, x1y0), y+0)),
Edge(Node2D(x+0, y+adapt(x0y0, x0y1)), Node2D(x+adapt(x0y1, x1y1), y+1))]
Hey there, I was trying to figure this out in another language, and I can't figure out what
Quad(Float, Float, Float, Float).swap(Bool)
is supposed to be doing.
reference:
Line 86 in a165b32
I get that there is a Quad object, which I believe is x, y, w, h. But I'm not sure what the swap(bool)
function does. Is this flipping the face or something? Sorry I can't find documentation for utils3d anyplace so I don't really know where to go.
Sorry for bothering with the question. I hope it is okay to ask here since your blog has comments disabled.
First of all thanks a lot for all the effort you put into your very elaborate and comprehensive tutorial. So my question regarding the dual contouring article is the following:
How would i know the gradients to adapt the vertex of a cell without external information? In your sample this is known information because it is known by inferting the x and y of a cell and the distance from the center - but how would this work in a rendering scenario where i am unaware of the volume i am trying to render?
I have looked at the implementation of lin20 but the code is not really optimized for comprehension, like your code , and i cannot yet comprehend how i would infer normals to adapt the vertex position in a scenario where i do not have information as to what exactly i am rendering.
Is there something i am missing or is that a case where i would just not adapt my vertex position at all (since getting normals would require external information)?
Line 76 in a165b32
hi @BorisTheBrave , I think it maybe better to open a new issue to make it clearer. thanks for your quick help and modification! We'are able to change the resolution by CELL_SIZE now. The new code seems all good but when I test with the [circle function, circle normal], there are some artifacts in the result .
If I use [circle function, normal_from(circle function)], the result is better but still a flip face.
This is when i use CELL_SIZE 0.5, there are three artifaces areas.
Could you please help with this? Is it because the circal normal is not correct?
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.