- Home /
Question by
kihu · Jan 03, 2014 at 05:09 PM ·
mesh manipulation
Transform mesh while combining
I want to combine mesh from Transform 'A' to Transform 'B'. To achieve this, I use this code:
MeshFilter[] meshFilters = A.GetComponentsInChildren<MeshFilter>();
CombineInstance[] combine = new CombineInstance[meshFilters.Length];
for(int i = 0; i < meshFilters.Length; i++){
combine[i].mesh = meshFilters[i].mesh;
combine[i].transform = meshFilters[i].transform.localToWorldMatrix * B.worldToLocalMatrix;
}
B.GetComponent<MeshFilter>().mesh.CombineMeshes(combine);
'A' has children on multiple levels. After I run the code, nothing appears in Transform 'B'. I guess it has something to do with wrong transformation matrix handling. How do I make it work?
Comment
Your answer
Follow this Question
Related Questions
Modular/Procedural Visibility of Meshes 1 Answer
How Can I make 3D Roads? 1 Answer
Moving an hole in a plane 0 Answers
How to make discontinuous UVs? 1 Answer
Flattening a mesh by deforming it 0 Answers