Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 jak6jak · Feb 09, 2015 at 03:08 AM · c#terrainprocedural mesh

How to split up a procedural mesh so you don't reach the vertex limit

I am creating a procedural mesh and to make it bigger I need to split it up into separate meshes so I don't get the vertex limit error. I thought I could just call the following method as much as I needed and it would create a new separate mesh each time but unfortunately it just overwrites the previously assigned vertices and does not create a new mesh.

 void UpdateMesh()
     {
         mesh.Clear();
         mesh.vertices = newVertices.ToArray();
         mesh.triangles = newTriangles.ToArray();
         mesh.uv = newUV.ToArray();
         mesh.Optimize();
         mesh.RecalculateNormals();
 
         MeshCollider meshc = gameObject.AddComponent(typeof(MeshCollider)) as MeshCollider;
         meshc.sharedMesh = mesh;
 
         newVertices.Clear();
         newUV.Clear();
         newTriangles.Clear();
 
         faceCount = 0;
     }


would I just need to create a new instance of newVerticies and newTriangles? I have tried doing that like this but it gives me the same results (I have also tried making new instances of newVerticies and newTriangles etc. in the updateMesh method but nothing showed).

  private void generateTestIsland()
     {
         for (int x = 0; x < grid.rows; x++)
         {
             for (int y = 0; y < grid.columns; y++)
             {
                 grid.FindTile(x, y).elevation += 3;
 
                 if (x % 50 == 0 && y % 50 == 0 && x != 0 && y != 0)
                 {
                     newVertices = new List<Vector3>();
                     newTriangles = new List<int>();
                     newUV = new List<Vector2>();
                     UpdateMesh();
                 }
             }
 
         }
 
     }

 
Comment
Add comment · Show 1
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
avatar image incorrect · Feb 09, 2015 at 03:24 AM 0
Share

No matter how many arrays of vertices and triangles you create, everything depends on what you put in a mesh.

You have to understand what you are doing ins$$anonymous$$d of copy-pasting and expecting things to work.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by jpthek9 · Feb 09, 2015 at 08:08 AM

 int VCount = 0;
 int MaxV = 64000; //The maximum vertices in 1 mesh
 List<Mesh> Meshes = new List<Mesh>();
 Mesh currentMesh = new Mesh();
 Meshes.Add(currentMesh);
 for (int i; i < mesh.verticies.Count; i++)
 {
 if (VCount < MaxV)
 {
 currentMesh.verticies.Add (mesh[i]);
 }
 else{
 currentMesh = new Mesh();
 Meshes.Add (currentMesh);
 currentMesh.Add (mesh[i]);
 VCount = 0;
 }
 }

I'm not entirely sure if this will work but it shows the concept. Generate a new mesh every time that mesh has its fill of vertices.

Comment
Add comment · Show 2 · Share
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
avatar image incorrect · Feb 09, 2015 at 10:53 AM 0
Share

You've made a list of meshes. And?..

avatar image jpthek9 · Feb 09, 2015 at 06:18 PM 0
Share

Everything's in the code.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Scaling and rotaion of terrain trees 1 Answer

SetAlphaMaps Opacity Gradient 0 Answers

How would you go about 'painting' images onto terrain 0 Answers


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