• 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 TheCommunist · Jul 02, 2015 at 08:01 PM · procedural mesh

What changed with SetTriangleStrip to SetTriangles with the Unity 5 update?

I am updating a project that is running on Unity 3.5.7f6 to 5.1.0f3. The one aspect of this project I cannot seem to figure out is with the mesh I create in code for the game dirt. This project heavily relies on dirt simulation, that is why the mesh is created and managed via C#.

The issue I am having with the ground at this moment is the mesh creation. When porting this project over to Unity 5, I was given the error that SetTriangleStrip was obsolete and I got the error Type UnityEngine.Mesh' does not contain a definition for SetTriangleStrip. So I changed it to SetTriangles and the compile error was gone. But something had broken my mesh. Below I have pictures to show what the ground mesh should look like as well as a broken version.

alt text

This is what the ground should look like. A simple triangular plane.

alt text

This second image is what I get when I update the project to Unity 5 and change SetTriangleStrip to SetTriangles.

If I create and add a 2 sided material, I get a similar result to the 2nd image, except that there are 2 triangles that form diamond shapes. There are still large empty holes where other missing triangles should be.

Does SetTriangles work very differently from SetTriangleStrip? I have looked for more in depth documentation and have not found anything very useful. One guess I have is that SetTriangles has changed the winding order of the verticies I am passing in. Here is a small snippet of code so you can see what I mean.

   private GameObject CreatePatch()
   {
     GameObject patch = new GameObject();
     patch.AddComponent<MeshRenderer>();
     patch.AddComponent<MeshFilter>();
 
     patch.GetComponent<MeshRenderer>().sharedMaterial = DirtMaterial;
 
     patch.transform.parent = Parent.transform;
 
     Mesh mesh = new Mesh();
 
     mesh.vertices = GeneratePatchVertices();
     mesh.uv = GeneratePatchUVs();
     mesh.normals = GeneratePatchNormals();
     mesh.tangents = GeneratePatchTangents();
     mesh.SetTriangles(GeneratePatchTriangleStrip(), 0);
 
     DynamicMesh dynamicMesh = patch.AddComponent<DynamicMesh>();
     dynamicMesh.Mesh = mesh;
 
     patch.GetComponent<MeshFilter>().sharedMesh = mesh;
 
     return patch;
   }


Any help would be very appreciated.

workingdirt.png (464.8 kB)
brokendirt1sided.png (402.9 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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Dave-Carlile · Jul 02, 2015 at 08:04 PM

A triangle strip is a special way to provide vertices to avoid repeating them. If you're using SetTriangles instead of SetTriangleStrip you'll need to reorganize the vertices generated by your GeneratePatchTriangleStrip function.

This other answer may help you out.

Comment
Add comment · 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
0

Answer by $$anonymous$$ · Oct 25, 2017 at 10:03 AM

Use SeTriangles instead of SetTriangleStrip and GetTriangle instead of GetTriangleStrip

Comment
Add comment · 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

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

3D array problem 0 Answers

Procedurally Generated Mesh Texture problem 1 Answer

Procedural mesh generation - problem with normals. 2 Answers

Dynamic mesh is black except up-close 1 Answer

Vertex Colours flickering blue 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges