- Home /
Return a single face from a cube primitive for manipulation
I want to create a cube primitive and scale and re position a single face of the cube while the opposite side stays stationary.
Im sure i can figure out a way to directly manipulate the vertices of the cube, but I was hoping it would be easier to just perform a local scale and position on the entire face instead of worrying about re-positioning each vertex manually.
Answer by Mortennobel · Jul 13, 2011 at 04:02 PM
I would think that the most easy way would be to modify the vertices.
Take a look at my blog post about creating procedural mesh in Unity - that should get you started:
http://blog.nobel-joergensen.com/2010/12/25/procedural-generated-mesh-in-unity/
Looks like a nice example. Also, for reference, see the $$anonymous$$esh docs here.
Ok so I have an array that holds the vertices I want to manipulate, intelliSense isnt showing anything that allow me to perform a local scale on just those vertices. Any ideas?
There isn't a convenient command for this kind of thing (that I know of) unfortunately. If you use Vector3.Scale relative to the centroid of the face, that might work.
What I mean is:
convert the world coordinates (that's what you get when you try to get the verts, right? I haven't had much experience with mesh stuff yet..) to local-relative-to-centroid vectors
scale each of those vectors
apply.