Comments and answers for "How to find triangles using variables"
http://answers.unity.com/questions/45121/how-to-find-triangles-using-variables.html
The latest comments and answers for the question "How to find triangles using variables"Comment by Uriel_96
http://answers.unity.com/comments/98896/view.html
oh sorry, yeah I was wrong I did this bad, but I finally find a way, but thanks for answer, your answer really works.Sun, 30 Jan 2011 23:07:47 GMTUriel_96Comment by Bunny83
http://answers.unity.com/comments/98830/view.html
I'm really sorry, but i won't continue on this. To describe your script with two words: a total mess. I've stopped searching for syntax errors after the tenth i've found. The whole script also contains a lot of logical errors even without the knowledge what the script should do. To use the Update function as a loop for a single task is just crazy. All your own arrays aren't created or initialized and you mixed up int arrays with ints... I don't see any light at the end of this tunnel. I would recommend to take some programming lessons or simply try to learn the syntax on your own. good luckSun, 30 Jan 2011 11:13:20 GMTBunny83Comment by Uriel_96 on Uriel_96's answer
http://answers.unity.com/comments/98767/view.html
O$$anonymous$$, sorry for not explaining very well. I remove some of the vertices, and the vertices is all correct(the order and position), the bad thing comes in building the triangles, I don't know how to order my triangles, if it helps I will put all my code and a explication.Sat, 29 Jan 2011 21:47:14 GMTUriel_96Comment by Uriel_96 on Uriel_96's answer
http://answers.unity.com/comments/98707/view.html
yeah, the real problem is at the final of the question, please read itSat, 29 Jan 2011 15:25:49 GMTUriel_96Answer by Bunny83
http://answers.unity.com/answers/45129/view.html
<p>I guess you don't understand what a vertexbuffer and a indexbuffer is?<br>
A Mesh in Unity consists of triangles. Every triangle is made up of 3 vertices. I guess you already know that part. Now the important part. Mesh.vertices is the vertexbuffer and Mesh.triangles is the indexbuffer. The indexbuffer is also an array but it contains indices related to the vertexbuffer. Each number (int) in the indexbuffer is a index into the vertexbuffer. Always 3 indices made up a triangle. The indexbuffer just tell you which vertices you need.</p>
<p>A simple example for a plane:</p>
<pre><code>var vertices : Vector3[] = new Vector3[4];
vertices[0] = Vector3(-1,-1,0);
vertices[1] = Vector3(-1, 1,0);
vertices[2] = Vector3( 1, 1,0);
vertices[3] = Vector3( 1,-1,0);
var indices : int[] = new int[6];
// triangle 1
indices[0] = 0; // first vertex
indices[1] = 1; // second vertex
indices[2] = 2; // third vertex
// triangle 2
indices[3] = 2; // third vertex
indices[4] = 3; // forth vertex
indices[5] = 0; // first vertex
mesh.vertices = vertices;
mesh.triangles = indices;
</code></pre>
<p>Look carefully at the example of the indices. The first and the third vertex is shared between both triangled.</p>
<p>If you want remove some triangles you have to remove the 3 corresponding indices that made up the triangle. The resulting indices array will be smaller in the end. That's tricky because you can't change the size of builtin arrays dynamically. If you want to remove vertices somewhere in the middle of the vertices array it gets really difficult because the indices would be pointing to the wrong vertices.</p>
<p>I still don't know exactly what you want to do. I'll hope you understand everything i explained here. Maybe you can specify you question a bit and tell us what you want to archive.</p>
<p>I guess you've tried something similar in this <a href="http://answers.unity3d.com/questions/36084/correct-form-to-use-vertices-uv-and-triangles-create" rel="nofollow">post</a>, right?</p>
<hr>
<p>Ok, i still don't understand what exactly you want to archive :D<br>
Do you want to remove some triangles completely or just move them outwards. If you want to move them outward you just need to shift the vertices like you've done already but it depends on how the mesh is built up. If there are shared vertex points you have to duplicate the vertex points to make them unique. That would require to build up a complete new vertex and index array.</p>
<p>You said how to "find" a triangle. The loop where you increment your "j", it already goes through all triangles. "j" is the current triangle and (j*3), (j*3+1) and (j*3+2) are the 3 points that define this triangle. </p>
<p>If you want to remove a single triangle you have to copy all triangle indices into a new array except those you don't want. You can't change the size of a builtin array. The new arraysize have to be reduced by 3.</p>Sat, 29 Jan 2011 05:00:48 GMTBunny83