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)
- [Question] robust geometric predicates, polygon triangulation
- Warning comparison of integer expressions of different signedness
- Modularize Manifold HOT 25
- Build without exceptions HOT 3
- Remove Thrust HOT 19
- How to figure out required size of mem in the C-API? HOT 1
- Crash in Project() HOT 4
- gcc14 build failure HOT 7
- Triangulation issue: Zebra HOT 3
- BSD compiler error HOT 1
- Another Zebra Triangulation issue HOT 6
- Port for vcpkg HOT 2
- use size_t whenever possible
- Auto generated python stubs inconsistent with cpp API HOT 12
- Rust bindings HOT 22
- Build error with Emscripten 3.1.61 HOT 1
- Debug MSVC build error HOT 7
- NumTri returns uint32_t, while array uses size_t (like uint64_t or int64_t) HOT 3
- Warning as errors HOT 4
- operator""_z returns unsigned and is in the global scope
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.