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
2
Question by Case23 · Jul 09, 2010 at 07:53 AM · meshgraphicsvertices

Making a reference to specific vertices so i can manipulate them after used Mesh.CombineMesh

Im using Mesh.CombineMeshes with cube meshes to create a single Mesh for performance reasons.

When i assining the single meshes to the CombineInstance, is it possible to create a reference to the Mesh, so i can changing there values to recalculate or deleting single parts out of it?

CombineInstance[] combine = new CombineInstance[GameObjectArray.lenght];       
for (int i = 0; i < GameObjectArray.lenght; i++)
{
    MeshFilter mF = GameObjectArray[i].GetComponent<MeshFilter>();
    combine[meshCount].mesh = mF.mesh;
    combine[meshCount].transform = GameObjectArray[i].transform.localToWorldMatrix;
    // can i somewhere here create a reference in any way to change single parts of the mesh afterwards
    GameObject.Destroy(GameObjectArray[i]);
}
Mesh mesh = mesh.CombineMeshes(combine);
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

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by jonas-echterhoff · Jul 09, 2010 at 01:14 PM

What would probably work is to count the vertices in each source mesh and add them to get the start index of vertices in the destination mesh.

like this:

CombineInstance[] combine = new CombineInstance[GameObjectArray.lenght]; 
int[] vertexIndices = new int[ameObjectArray.lenght];
int vertexIndex = 0;      
for (int i = 0; i < GameObjectArray.lenght; i++)
{
    MeshFilter mF = GameObjectArray[i].GetComponent<MeshFilter>();
    combine[meshCount].mesh = mF.mesh;
    combine[meshCount].transform = GameObjectArray[i].transform.localToWorldMatrix;
    vertexIndices = vertexIndex;
    vertexIndex += mf.mesh.vertices.Length;
    GameObject.Destroy(GameObjectArray[i]);
}
Mesh mesh = mesh.CombineMeshes(combine);

Then for each source mesh, you can edit the vertices at vertexIndices[i] in the destination Mesh.

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 Case23 · Jul 09, 2010 at 02:04 PM 1
Share

Thanks for the answer! I will try this as soon as possible and tell you about my results. :)

avatar image Case23 · Jul 10, 2010 at 08:04 AM 1
Share

Testet it, and works lika a charm. :)

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

No one has followed this question yet.

Related Questions

Orientate Planes created on vertices towards mehs they're spawned on 1 Answer

Mesh Colours transparent 0 Answers

Why does the default Unity sphere have duplicate vertices? 1 Answer

Modify mesh on load 1 Answer

How do I make a series of primitive planes and roll them into a tube? 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