- Home /
Is direct MeshRenderer vertex mutation (or dynamic Mesh building) possible?
Hi,
I'm building a visualizer in Unity and I've hit a little bit of an issue.
My idea is to draw a line that corresponds to the spectrum, and keep a history of the lines to draw into a sort of "grid" behind it, building a mesh out of the lines that I have previously made. Something like this (I know it's not a music visualizer, but it illustrates my point well):
Just like this, I'd like to be able to have an array of "lines" and build them into a connected sequence.
I'm able to get a single line on-screen by using the LineRenderer
on my main camera, but I'm not entirely sure how to go about either a) Making multiple LineRenderer
s without making a huge mess out of the project b) Using MeshRenderer
to create a Mesh on the fly.
Any more information on choice b
would be the best, I would imagine. Is it possible to dynamically create meshes in this fashion (building from a list of vertices)?
Thanks!
You might want to fix your image link, it's pointing to .pn
ins$$anonymous$$d of .png
.
That seems to be a recent issue on UnityAnswers. The actual link does read .png
at the end. I just edited the question and just resaved it without modification and now it seems to be fixed ^^.
Anyways, thanks for the hint :)
Answer by aldonaletto · Jun 13, 2012 at 11:15 PM
You can generate or modify meshes at runtime - take a look at this topic in the docs. There are also some examples in this project from Unity.
NOTE: You can get sound samples or the audio spectrum from any AudioSource or the AudioListener with GetOutputData or GetSpectrumData - take a look at this question.
[3]: http://unity3d.com/support/resources/example-projects/procedural-examples.html
[5]: http://unity3d.com/support/resources/example-projects/procedural-examples.html
Answer by Bunny83 · Jun 13, 2012 at 11:09 PM
Have you tried looking into the documentation to find a class that might be useful?
The Mesh class is propably what you're after. It has many examples how to use it. Note that there are additional examples on the different properties. For example if you want to create a skinned mesh, look at the bindposes.
Your answer
Follow this Question
Related Questions
Mesh line renderer - line segments camera align 1 Answer
Rendering mesh edges in-game just as they appear in editor mode 1 Answer
Wireframe Rendering? 4 Answers
Render wireframe on cut section of polygons 2 Answers
Weird Line Between Meshes 1 Answer