- Home /
how to make a customised head in unity
i have created a head model in 3d max i want to be able to give an interface of entering the diameter of the head and making the head according to that. I am aware that I can do it with mesh morphing but can i get any sample script or any help on how i can do that.
Answer by aldonaletto · Aug 25, 2013 at 10:41 PM
You could download the Procedural Examples project from Unity: it creates and modifies meshes at runtime, and may help you.
EDITED: I suggested the Procedural Examples because they have scripts that deform meshes - like the script CrumpleMesh.js, for instance. In your case, maybe a mesh scaling function could do the job:
function ScaleMesh(scaleX: float, scaleY: float, scaleZ: float){
var mesh: Mesh = GetComponent(MeshFilter).mesh;
var verts: Vector3[] = mesh.vertices; // get a copy of the vertices
for (var i=0; i<vertices.Length; i++){
// scale each vertex
verts[i] = Vector3.Scale(verts[i], Vector3(scaleX, scaleY, scaleZ));
}
mesh.vertices = verts; // assign the scaled vertices to mesh.vertices
mesh.RecalculateNormals(); // fix mesh normals
mesh.RecalculateBounds(); // adjust mesh bounds
}
Place this function in a script attached to some object, then call it passing the scale in each axis in scaleX, scaleY and scaleZ (1 means no change, of course). The result is the same as setting Scale in the Inspector - but changing the field Scale affects the object children as well, specially when the parent is rotated (children get skewed when the scale is non-uniform), while scaling the mesh doesn't have any effect in the children.
aldonaletto those are just unity files can u tell me about any tutorials or videos on how to use these which will help me in making my custom head.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Make 2d Animation Scene 0 Answers
How can i animate my Object? (bones available) 1 Answer
Animation clips problem 0 Answers
Quick animation question 1 Answer