-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Converting geometry3Sharp mesh to other mesh #3
Comments
Does the make_good_cylinder() function do Remeshing internally, or other mesh composition operations? If you construct a DMesh3 from scratch, it will have the same properties as other indexed meshes, ie dense index space. But if you do things like Remeshing, it will leave 'holes' in the index space as it deletes vertices/triangles. To get back to a Dense index space you have to compact the mesh. The fastest way to do that is to use the compacting copy constructor. IE you could write: g3m = new g3.DMesh3(g3m, true); and now g3m will have dense index spaces. |
Thanks it works. I would like to ask about remeshing part. Is it possible to remesh a mesh in such a way that its its edges will be more or less equilateral and output shape would be the same (without smoothing)? I am using your example file with cylinder:
} |
Nice works with open one too. Is this library totally C# ? Or it has dependencies |
it is completely in C# and has no dependencies. |
Hi Petras,
|
Thanks, maybe you know what is a proper way of checking mesh winding order? The posts I searched, usually starts with cross product - normal of face. Then there is a construction of transformation matrix. But what is the proper way of checking the winding if it is clockwise or anti-clockwise? public bool Triangle(Vector3f v0, Vector3f v1, Vector3f v2) .... } This is just normal calculation of mesh face, what it must change if it is clockwise of anti-clockwise. |
Is that question related to the g3 geometric library or is it a general computer graphics question? |
I know... If there is method in g3 to point me to winding would be preferable. |
Probably it boils down to find the edge that both faces share, and then see if the edges |
Are you trying to fix a mesh that has faces with different winding or are you trying to figure out which convention this library uses?
If you then look at this diagram: https://en.wikipedia.org/wiki/Cross_product#/media/File:Right_hand_rule_cross_product.svg |
It is about fixing. Yap, the directionality define by your function of calculating mesh face normal. But for checking whole mesh if mesh face windings are correct, you probably need to start from arbitrary mesh face and loop through neighbour faces and swapping their direction if edge direction does not match . |
the Cross Product does not change if you use RHS or LHS coordinate systems. Switching coordinate systems involves switching the basis vectors, which then changes the interpretation of the result of a cross product. But the formula doesn't change. Most of the library is not specific to a particular coordinate system. For example Unity is LHS but many (perhaps most) other tools are RHS. There are functions in MeshTransform to switch between these two when necessary. A mesh doesn't have "sides" so any set of vertices and triangles can be oriented such that the normals computed from face-edge-cross-products point outwards or inwards. You switch this just by switching the order of the vertices in the face. 'fixing' a mesh with inconsistent per-triangle orientations can be quite difficult. The process you describe - fix one face and then propagate across neighbour edges - works if the mesh is closed and orientable (ie manifold). The standard process is to do something like a raycast from far away, set the orientation/winding of the face the ray hits to be the orientation/winding you want (ie face normal should point towards ray, under whatever handedness-system you want to use), and then do the propagation. If the mesh is not closed, this will produce one of the two possible orientations depending on where the ray hits. If the mesh has disjoint regions this can lead to them being "incorrectly" oriented relative to what a human might have been hoping for. I do intend to eventually implement the fix-and-propagate part of orientation repair in the library, just haven't gotten to it yet. |
Thanks for the explanation. Fixing winding looks like not a straight forward process. I have additional question about remeshing. I am using one of your functions for remeshing, I tried to change angle and other properties, but I corners points of this box are not fixed. How to snap these corner points correctly?
|
Unity's cross product method follows the LHS. I'm sure the math is the same, but the order of the vector parameters is reversed, which could also be the case in this library if you don't look at the code https://docs.unity3d.com/ScriptReference/Vector3.Cross.html).
Well, the direction the face normal are pointing are important for many things, like rendering (back-face culling, refraction) or Boolean operations. I guess the remesher of this library is not affected by this. |
@petrasvestartas This is happening because the Remesher needs to know about the sets of edges you want to preserve. In the sample code the object is a cylinder. Guessing the "sharp" edges is done by the (fAngle > angle) test. However then in the next few lines I am checking if the vertex is above or below the bounding-box center (the nSetID0 and nSetID1 variables). These values are passed into the VertexConstraint constructor. This is a hacky way to "find" the upper and lower creases on the cylinder. Basically, the remesher is treating these as "sets" of related vertices/edges. It is allowed to collapse to other vertices in the set, but not across sets. So for your cube it means all the sharp edges in the upper half / lower half are fair game for collapsing, and what is happening is the corner vertices are being lost. The way to fix this is to tag the corner vertices with their own set ID. However to do that you have to find the corners. One way would be to count the 'sharp' edges coming out of each vertex. If there are more than 2, it is a corner. (this might be improved in the future because clearly the edge constraints should also have these set IDs, and in that case I could handle these "corner" situations automatically...) |
Hello, Is it possible to know which function prevents vertex from moving (make it fixed) |
…aplasian #317 first test version
Hi,
I tried your library and it works:) It is supernice.
I tried to convert your mesh to other type of mesh.
Basically what I am trying to do is to pass all vertices and mesh faces from one mesh type to another.
But I noticed that DMesh3 has vertices with strange indexing. For instance if there are 100 vertices their index id can be something like 2000, 0, 281 and etc, the mesh library I am working with vertex id would go from 0,1,2 to 100 sequentially. Therefore I always have to remap indices.
Is there a better way to do below conversion?
The text was updated successfully, but these errors were encountered: