- Home /
Dynamic face mesh from Kinect- applying a texture
Have a tricky issue applying a face texture to a dynamic mesh generated from a Kinect sensor. In the following 'myGameObjectReference' is passed in manually and avModelVertices, avModelUV, and avModelTriangles are all previously defined and contain correct data.
The .png files that I am dynamically loading from my Resources folder are having some effect as can be seen from the attached images. But you can see in the 2nd example that the entire image is not being mapped correctly as a texture to the face mesh.
Confused as to what is happening here. What seems to be happening is that the color values from the loaded png are averaged and then applied to the entire mesh. But Why? Can any texture experts help?
Mesh mesh = new Mesh();
mesh.name = "FaceMesh";
myGameObjectReference.GetComponent<MeshFilter>().mesh = mesh;
MeshRenderer rend = myGameObjectReference.GetComponent<MeshRenderer>();
rend.material.mainTexture = Resources.Load("faceTexture1") as Texture;
mesh.vertices = avModelVertices;
mesh.uv = avModelUV;
mesh.triangles = avModelTriangles;
mesh.RecalculateNormals();
texture1-result.jpg
(103.5 kB)
texture2-result.jpg
(144.0 kB)
Comment