How can I identify the location of mesh triangles at run time? (Procedural Generation)
Having a hard time finding the location of triangle coordinates of a mesh. So far I have found the world coordinates of vertices. To give a little context, I am trying to generate a mesh at run time and then accurately place objects on the vertices and triangles. The script below is what i have to find the vertices. Can anybody point me in the right direction for triangles? I think since the triangle has 3 separate points it wont let me choose just one. Any thoughts? Appreciate the help.
using System.Collections; using System.Collections.Generic; using UnityEngine; public class CustomMesh : MonoBehaviour { // Use this for initialization void Start () { } void FixedUpdate () { Matrix4x4 localToWorld = transform.localToWorldMatrix; MeshFilter mf = GetComponent<MeshFilter>(); for (int i = 0; i < mf.mesh.vertices.Length; ++i) { Vector3 world_v = localToWorld.MultiplyPoint3x4(mf.mesh.vertices[i]); } print(transform.localToWorldMatrix); } }
Your answer
Follow this Question
Related Questions
Mesh generation triangles issue 0 Answers
Some triangles are black on a mesh generated by script 1 Answer
Shared or Non-shared Vertices for mesh generation? 0 Answers
Procedural Mesh Problems 0 Answers
How is a Mesh Built? 1 Answer