Using MeshTopology.Points with Mesh

How do you actually use MeshTopology.points (where you have a vert list of millions of points) with Mesh? Is it possible to assign MeshTopology to distinct gameobjects and not just have it be in buffer noly?

1 Answer

1

You have to construct the mesh yourself. When you call SetIndices, MeshTopology is an optional parameter.

function SetIndices (indices : int, topology : MeshTopology, submesh : int) : void
http://docs.unity3d.com/Documentation/ScriptReference/Mesh.SetIndices.html

You could write a quick script that read the mesh indices from a mesh filter, created a new mesh, created new indicies based on the old ones, and reassigned the mesh.

EDIT:

Both those are relatively straightforward. For creation - see below… You can get the bounds to add a simple collider. More than that, well, you can write a voxel raytracing solution…

void Start(){

		int vertexCount = 1000;
		Vector3[] vertices = new Vector3[vertexCount];

		int[] indices = new int[vertexCount];

		for(int i=0; i<vertexCount; i++){
			vertices *= new Vector3(Random.value, Random.value, Random.value);*

_ indices = i;_
* }*

* Mesh m = new Mesh();*
* m.vertices = vertices;*
* m.SetIndices(indices, MeshTopology.Points, 0);*
* m.RecalculateBounds();*

* MeshFilter mf = GetComponent();*
* mf.mesh = m;*
* Debug.Log(m.bounds);*
* }*

Input: point cloud, so no luxury of premade indices in advance. http://unitycoder.com/blog/2012/09/01/xyz-point-cloud-data-viewer-dx11/ Output: it'd be nice if you could lop on collider components and such, but this point cloud seems to only live in a DX11 render buffer

–

Thanks for the fix MiniFish! To save everyone else the headache I developed trying to figure out why your stuff didn't immediately work for me, remember that after applying the above changes, remember to also adjust the packsize variable. So you should also have int packSize = (samples.Length / width) + 1;

–