i am working on a project where i have some code that generates a ribbon-type object, on this ribbon I want to render various textures … when i just want one long continuous texture (that is stretched) everything is ok, but when i want to use a texture with some text one it is unreadable.
This is what I’m trying to achieve: (See a short Quicktime of it in motion here)
http://www.okdeluxe.co.uk/_files/unity_ribbon/text_ribbon.mov
I am new to generating meshes from code so I may be doing something funny (or not doing enough). See Unity screenshot below.
Here’s a snippet of the Unity code I am using to generate the mesh with:
// clear mesh to start with
mesh.Clear();
// vertices
var mVertices = new Array();
mVertices.Push(leftArr[0]);
mVertices.Push(rightArr[0]);
for(i=1; i<numSegs; i++){
mVertices.Push(leftArr[i]);
mVertices.Push(rightArr[i]);
mVertices.Push(leftArr[i]);
mVertices.Push(rightArr[i]);
}
mVertices.Push(leftArr[numSegs]);
mVertices.Push(rightArr[numSegs]);
//draw the mesh
mesh.vertices = mVertices.ToBuiltin(Vector3);
// UVs
var mUV = new Array();
for(i=0; i<numSegs; i++){
mUV.Push(Vector2 (0, 1));
mUV.Push(Vector2 (1, 1));
mUV.Push(Vector2 (0, 0));
mUV.Push(Vector2 (1, 0));
}
mesh.uv = mUV.ToBuiltin(Vector2);
// normals
var mNormals = new Array();
for(i=0; i<numSegs; i++){
mNormals.Push(Vector3(0, 1, 0));
mNormals.Push(Vector3(0, 1, 0));
mNormals.Push(Vector3(0, 1, 0));
mNormals.Push(Vector3(0, 1, 0));
}
mesh.normals = mNormals.ToBuiltin(Vector3);
// triangles
var mTriangles = new Array();
for(i=0; i<numSegs*4; i+=4){
mTriangles.Push(i); mTriangles.Push(i+1); mTriangles.Push(i+2);
mTriangles.Push(i+3); mTriangles.Push(i+2); mTriangles.Push(i+1);
mTriangles.Push(i+2); mTriangles.Push(i+1); mTriangles.Push(i);
mTriangles.Push(i+1); mTriangles.Push(i+2); mTriangles.Push(i+3);
}
mesh.triangles = mTriangles;
I’m stuck! Any pointers/ideas/help would be greatly appreciated
Thanks,
Mikkel
