Create simple mes plane from script?

[SOLVED]

Code Error in vertices index. Some vertices equal to zero.


1516084--86389--$4mmh.jpg

Maybe can get some ideas from these,
http://wiki.unity3d.com/index.php/CreatePlane
Three.js PlaneGeometry.js to Unity C# « Unity Coding – Unity3D (see the comments section for working example)

Ok, thanks, I’ll look, and comment that this has gone.

Second test:

In the script http://wiki.unity3d.com/index.php/CreatePlane, I dont’t see differences between:

            index = 0;
            for (int y = 0; y < lengthSegments; y++)
            {
                for (int x = 0; x < widthSegments; x++)
                {
                    triangles[index]   = (y     * hCount2) + x;
                    triangles[index+1] = ((y+1) * hCount2) + x;
                    triangles[index+2] = (y     * hCount2) + x + 1;
 
                    triangles[index+3] = ((y+1) * hCount2) + x;
                    triangles[index+4] = ((y+1) * hCount2) + x + 1;
                    triangles[index+5] = (y     * hCount2) + x + 1;
                    index += 6;
                }
            }

And,

      for(i=0;i<divisionY;i++){            

            for(w=0;w<divisionX;w++){                

                q=(w+i*divisionX)*6;
                triangles[q+1] = (i+1)*(divisionX+1)+w;
                triangles[q] = i*(divisionX+1)+w;
                triangles[q+2] = triangles[q]+1;
                Debug.Log((i*(divisionX)*2+w*2).ToString()+" : "+triangles[q].ToString()+triangles[q+1].ToString()+triangles[q+2].ToString());
                triangles[q+3] = triangles[q+1];
                triangles[q+4] = triangles[q+3]+1;
                triangles[q+5] = triangles[q+2];
                Debug.Log((i*(divisionX)*2+w*2+1).ToString()+" : "+triangles[q+3].ToString()+triangles[q+4].ToString()+triangles[q+5].ToString());  

            }            

        }

Two codes use same vertice order in triangle.

In the second script, http://unitycoder.com/blog/2013/03/13/three-js-planegeometry-js-to-unity-c/, use Mesh.SetIndice to create triangles array.

I have used Mesh.SetIndice and Mesh.SetTriangle to create triangle array, but still not working.

Image Screen:
1516183--86398--$lbmz.jpg

I don’t know, why not render vertices 5 and 2.

Finally, the bug was in vertice index, where some vertices were equals to zero.

           // CODE ERROR
                // vertices[i*divisionX+w] = new Vector3(w*width,i*height,0f);

                vertices[i*(divisionX+1)+w] = new Vector3(w*width,i*height,0f);