- Home /
2D/3D Mesh deformer in runtime with a given points
Hello,
I want to deform a mesh in runtime for a music visualizer.
As an example see the image below. I want to animate these waves at the sound of the music. Retrive sound information is easy, but i have a few problems with deform a mesh in runtime.
I tried this code for triangulate a mesh for a given points (http://wiki.unity3d.com/index.php?title=Triangulator). But it takes too long time (70ms for 1000 points).
A boned mecanim animations do not suits for me.
There are any other way to create this?
Thanks :)
just for the record, it's possible you should just use one of the may "deform" packages on the asset store. Additionally, have you tried just using Vectrosity?
Answer by Fattie · Jan 15, 2016 at 08:28 PM
Could your problem be this simple, looking here,
http://docs.unity3d.com/ScriptReference/Mesh.html
it is absolutely essential that you carefully follow the procedure in (2), not the procedure in (1) or (3).
here's a critical discussion on how the .vertices work in Unity, and why you'll need to keep your "own" vertices in practice.
http://answers.unity3d.com/answers/417487/view.html
Actually it just occurs to me the actual example given on the Unity "Mesh" page above, is literally "moving it like a sine wave" heh! What one might do is carefully know your "north side of the ribbon" and "south side of the ribbon" vertices. You'll be doing "one thing" with one set and "another thing" with the other set .. I'm sure you see what I mean.
Thank you for the construtive answer.
"Just BTW regarding "triangulation". I can't see any reason, at all, you'd use that concept in what you're doing?" To "create" a mesh from nothing from a given ouside points, you have to calculate its triangles.. (simple 3D mesh problem).
I will accept this answer because you show-me the way. I was calculating the new mesh every single time, but as you said, i should transform the mesh (change the calculated verts). That's the way. So, thank you!
Now the rest, change between thin and thick or like a sine wave, that's basic given this principle of the algorithm.
Right, thank God I believe the problem was that simple!
Yes indeed, if you Clear
or the like it uses a huge amount of processing each time.
BY THE WAY,
"never forget that whenever you type .vertices, it makes A WHOLE COPY ... it's just Special, it's not like other properties."
It's just one of those weird quirks about Unity!
http://answers.unity3d.com/questions/352513/ways-of-modificating-mesh-triangles.html
here's one featuring some great drawings! :)
http://answers.unity3d.com/questions/315059/how-to-improve-performance-while-generating-extrud.html
here's a handy note on vertice handling in unity
http://answers.unity3d.com/questions/263302/vertices-array-in-mesh-vertices.html
(Just regarding triangulation. I understand what you mean: I can see you were trying to do this problem "really well". (By creating the shape with some algorithm, etc.) What it is, whenever someone around here wants to make a "strip" of color or the like "vibrate" or move, the common ("easy") approach everyone does is just move the verts up and down (indeed, exactly as in that sine example from the page), so I assumed you'd take that easy way out!)
Your answer
Follow this Question
Related Questions
Create runtime 3D mesh and Fill area like Paper.io 2 1 Answer
2D vs 3D mesh deformation. 0 Answers
Mesh remains deformed in Editor 1 Answer
UnifyWiki BasicQuad 1 Answer
Optimize mesh for runtime performance 0 Answers