Search Unity

Procedural mesh stupid question but Im blocked

Discussion in 'Scripting' started by juglarx, Jan 15, 2019.

  1. juglarx

    juglarx

    Joined:
    Dec 27, 2014
    Posts:
    60
    Hi all i have this
    mesh.vertices = vertices;
    mesh.triangles = triangles;

    and would a wanna achieved is draw quads based on the info stored for debug purpose i use

    Debug.DrawLine(p0, p5, Color.green);
    Debug.DrawLine(p5, p4, Color.green);
    Debug.DrawLine(p4, p0, Color.green);
    Debug.DrawLine(p0, p1, Color.green);
    Debug.DrawLine(p1, p5, Color.green);
    Debug.DrawLine(p5, p0, Color.green);


    but i can not get the right order to p0,p1.... and when i draw a got a mess anyone can help me out here. ? how can i use the mesh info to draw thow triangles representing a quad
    cheers
     
  2. Thibault-Potier

    Thibault-Potier

    Joined:
    Apr 10, 2015
    Posts:
    206
    Not sure to understand what you are trying to do.

    You want to build a mesh right ? Do you have all your vertices in correct position ?

    Does your Debug.drawlines display the shape of your mesh ? Can we see it? How many vertices have you? Do you want to build a method to generate a mesh or do you just need to build this specific mesh and use it as a 3D model ?

    So at the end: what are you trying to achieve ? What do you already have ?
     
  3. juglarx

    juglarx

    Joined:
    Dec 27, 2014
    Posts:
    60
    Thanks for the replay @Thibault-Potier yes i building a mesh (an sphere with some deformations) i have de mesh perfect render but when i try to use de debug.drawline i cannot figure out how to do it... mainly i want to draw the wad formed by the 2 trianges.The data on mesh.vertices and mesh.triangles are correct.
     
  4. Thibault-Potier

    Thibault-Potier

    Joined:
    Apr 10, 2015
    Posts:
    206
  5. juglarx

    juglarx

    Joined:
    Dec 27, 2014
    Posts:
    60
    Here is the code on how i generate the mesh

    Code (CSharp):
    1.                  
    2.   triangles[triIndex] = i;
    3.                     triangles[triIndex + 1] = i + resolution + 1;
    4.                     triangles[triIndex + 2] = i + resolution;
    5.  
    6.                     triangles[triIndex + 3] = i;
    7.                     triangles[triIndex + 4] = i + 1;
    8.                     triangles[triIndex + 5] = i + resolution + 1;
    9.  
    10.                
    11.                     triIndex += 6;  
    12.  
    and ai would like to do is something like

    Debug.DrawLine(vertices[triangles], vertices[triangles], Color.green);
    ..... and so on but i can figure out how to traverse the vertices[] and triangle array
     
  6. But why do you want to draw the mesh yourself? Why don't you just put into a MeshRenderer and show it on a GO?
     
  7. juglarx

    juglarx

    Joined:
    Dec 27, 2014
    Posts:
    60
    I render Ok, what i intend to do is draw a the faces based on 2 tris, for debug porpouse.
     
  8. Riptag

    Riptag

    Joined:
    Jan 17, 2019
    Posts:
    1
    To that I say why climb Mount Everest? The answer...because its there.

    A picture is worth a thousand words...However, from what you've described here I think the Mesh is obscuring the lines you are drawing with the DrawLine function. Turning DepthTest off for those lines should allow them to be visible. If not...then we'll need a picture.
     
  9. Nope, it's like 3D printing the Mount Everest and expecting realistic results.
    Debug.DrawLine wasn't made for this and it will be super slow and annoying. I'm telling you. The best course of action is to feed it into a mesh, display it with a wireframe-shader.