Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by gonzalitosk8 · May 21, 2019 at 04:23 PM · errorprocedural meshtriangulation

procedural mesh error in triangulation

Hello! I am generating a procedural system, in question everything is fine, but I find a mathematical error in the triangulation, and I can not find the solution, maybe someone with a better eye and understanding can help me ... according to the triangulation int list, it should be like this: 0,1,3 - 3,2,0 | 2,3,5 - 5,2,2 | 4.5.1 - 1.0.4. but the error is in the last row, I do not understand why it remains (4,5,7 - 7,6,4.). I attach an image.

![alt text][1]

I do not understand why it happens to 7, when it should be 1, and to 6 when it should be 0. somebody help me? public GameObject node;

     public Material mat;
     [HideInInspector]
     public GameObject pointDown;
     [HideInInspector]
     public GameObject pointUp;
     [HideInInspector]
     public GameObject pointUpPos;
 
     public GameObject[] pointsDown;
 
     public Vector3[] vertex;
 
     [Range(1,20)]
     public float Height=3;
 
     public int point;
     public int[] triangles;
 
     private int p1;
     private int p2;
     private int p3;
     private int b;
     private int p0;
 
     private float LastComparator;
 
     Ray ray;
     RaycastHit hit;
     public Mesh mesh;
     public MeshFilter mf;
     public MeshRenderer meshrend;
     vertexEditor vertexEdit;
     private int x;
     public int n;
     public float textureScale;
     public bool Create=false;
     public int change;
 
     void Start () {
 
         Height = 3;
         mat = Resources.Load ("fence", typeof (Material)) as Material;
         mat.mainTextureScale = new Vector2(1,1);
         mesh = new Mesh ();
         meshrend = this.gameObject.AddComponent<MeshRenderer> ();
         meshrend.material = mat;
         mf = this.gameObject.AddComponent<MeshFilter> ();
         textureScale=1;
     }
 
     public void GenMesh(){
 
         b = -4;
         p1 = b + 2;
         p2 = p1 + 1;
         p3 = p2 + 2;
         p0 = -1;
 
         for (n = 0; n < triangles.Length; n+=change) {
 
             b = x - 2;
             p1 += 2;
             p2 += 2;
             p3 += 2;
 
             triangles [n] = p1;
             triangles [n + 1] = p2;
             triangles [n + 2] = p3;
 
             triangles [n + 3] = p3;
             triangles [n + 4] = p3 - 1;
             triangles [n + 5] = p1;
 
             triangles [n + 6] = p3-1;
             triangles [n + 7] = p3;
             triangles [n + 8] = 1;
 
             triangles [n + 9] = 1;
             triangles [n + 10] = p0 +1;
             triangles [n + 11] = p3-1;
             mesh.triangles = triangles;
         }
     }
 
 
     void Update () {
 
 
         mesh.Clear ();
         mesh.vertices = vertex;
         mf.mesh = mesh;
         point = pointsDown.Length;
 
         pointsDown = GameObject.FindGameObjectsWithTag ("vertex");
         vertex = new Vector3[pointsDown.Length];
 
 
         for (x = 0; x < pointsDown.Length; x++) {
         
             vertex[x] = new Vector3(pointsDown[x].transform.position.x,pointsDown[x].transform.position.y,pointsDown[x].transform.position.z);
         }
 
         if (point > 0) {
             change = 3;
             triangles = new int[pointsDown.Length/2*3];
         }
 
         if (point > 4) {
             triangles = new int[pointsDown.Length *3];
             change = 6;
             GenMesh ();
         }
 
         // uvmap area.
         Vector2[] uvs = new Vector2[vertex.Length];
 
         for (int i = 0; i < vertex.Length; i++)
               {
             
             Vector3 uvpos = new Vector3(vertex[i].x, ((vertex[i].x) + (vertex[i].z)), vertex[i].z);
             Vector3 direction = uvpos / uvpos.magnitude;
 
                uvs[i] = new Vector2(((vertex[i].x * direction.x) + (vertex[i].z * direction.z)) / 1, vertex[i].y / 1);
 
               }
 
         mesh.uv = uvs;
 
     }
 }
forma.jpg (222.1 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

140 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

uv map problems 0 Answers

Triangulating a 2D polygon with only hull vertices. 1 Answer

Triangulation for my procedural 2D Polygon Collider is different than that of my Mesh, does anyone know why? 0 Answers

Automatically generating the triangle list for a mesh 0 Answers

"function DoRoll (Point, Axis, Angle, Duration)" Does Not Work on Android. Any reasons? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges