Comments (5)
Is this what you're after?
Mesh a_mesh = ImportMesh('something.glb');
Manifold a(a_mesh);
Manifold b = Manifold.Cube();
Mesh b_mesh = b.GetMesh();
const int aID = a.GetMeshIDs()[0];
const int bID = b.GetMeshIDs()[0];
Manifold c = a ^ b;
MeshRelation rel = c.GetMeshRelation();
Mesh c_mesh = c.GetMesh();
std::vector<int> meshID2Original = Manifold::MeshID2Original();
int c_tri = 0; // referring to c_mesh.triVerts[c_tri]
int triVert = 2; // 0, 1, or 2
BaryRef ref = rel.triBary[c_tri];
Mesh& inMesh = meshID2Original[ref.meshID] == aID ? a_mesh : b_mesh;
glm::ivec3 inTri = inMesh.triVerts[ref.tri];
glm::vec3 uvw = rel.UVW(c_tri, triVert);
glm::vec3 inProp = {inMesh.vertProp[inMesh.triVerts[inTri][0]],
inMesh.vertProp[inMesh.triVerts[inTri][1]],
inMesh.vertProp[inMesh.triVerts[inTri][2]]};
float prop = glm::dot(inProp, uvw);
// Or check if(ref.vertBary[triVert] < 0) then this refers to c_mesh.vertPos[ref.vertBary[triVert] + 3].
// Otherwise it's a new vertex that will have different properties for each side of the intersection.
This same system works even after many consecutive boolean operations, since it will point each triangle back to whichever original mesh it came from, not just the most recent inputs.
from manifold.
GetMeshRelation
gives you the mesh id and triangles indices, as well as barycentric coordinates. GetMeshIDs
gets the mesh ids. For any newly-constructed manifold this vector will length 1 (since it's a new meshID). If you can give some specifics of the trouble you're having, I'll be happy to help more.
from manifold.
These test functions might also give you some idea of how it's used: https://github.com/elalish/manifold/blob/master/test/mesh_test.cpp#L36-L79
from manifold.
Can you do an example of getting the triangle from mesh_b when you boolean intersect a and b? Or boolean add if it's too hard.
from manifold.
Thanks. Maybe we can add to the documentation or a test, but I was able to use this.
from manifold.
Related Issues (20)
- Refactor triangulator HOT 2
- triangulator bugs related to #528
- vertProperties behavior HOT 3
- refactor SparseIndices to use HashTable HOT 1
- allow double precision HOT 14
- Python Interface Vertex and Face Types HOT 5
- Volume calculation is not deterministic HOT 12
- Testing booleans of meshes HOT 2
- Emscripten build HOT 10
- Lost faces when creating manifold HOT 22
- Subtraction creates overlapping triangles HOT 6
- extrude twist can cause invalid geometry HOT 5
- XCode 15 Link problem with <memory_resource> HOT 6
- How could I create a manifold object for a simple rectangle? HOT 4
- non-manifold mesh repair HOT 1
- refine to length HOT 6
- Support for OS X 10.13? HOT 4
- Wrong vertex normals and uvs after boolean subtraction HOT 7
- vec out of range with sdf, smooth and refine HOT 3
- No boolean operations found in pypi-installed manifold3d package
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from manifold.