Notifications
Clear all
[Closed] get mesh faces by materialID
Mar 27, 2018 2:27 pm
I have a mesh using multimaterial and would like to get all faces that are using for example submaterial 1, 2, etc… In best case would like to get all that faces in an array.
2 Replies
Mar 27, 2018 2:27 pm
/**************** all used ids *************/
fn getMeshMaterialIDs node =
(
ids = #{}
for f=1 to node.numfaces do append ids (getfacematid node f)
ids
)
/****** in export order *****************/
fn getMeshMaterialIDs node =
(
ids = #()
for f=1 to node.numfaces where finditem ids (id = getfacematid node f) == 0 do append ids id
ids
)
/******* group faces by id *************/
fn getMeshFaceMaterialIDs node =
(
ids = #()
for f=1 to node.numfaces do
(
id = getfacematid node f
if ids[id] == undefined do ids[id] = #{}
append ids[id] f
)
ids
)
/********* all faces by id *****************/
fn getFacesByID node id =
(
faces = #{}
for f=1 to node.numfaces where (getfacematid node f == id) do append faces f
faces
)
1 Reply
Thanks, even I was hoping to find an easier solution, at lest now I know there is no such easy solution.
But which of that 4 solutions feats best if I want to sort faces by materialID, so I have at the end something like this:
faces=#()
…
so faces[1] contain all faces with ID 1, faces[2] contain all faces with ID 2, etc…