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 kuhny1 · May 09, 2018 at 09:04 AM · mesharrayrandomprogrammingprocedural

Generate a mesh from randomly positioned points

Hi, Im trying to make a mesh from a list of seemingly randomly positioned points that are moving. So the idea is to make a single 3d model to model data from a simulation and particles work but i can only go so far with that before frame rate starts dropping drastically. Obviously, a single model is a bit easier to render. I know how meshes work and i can edit their points and re-write the mesh accordingly but it looks like a mangled mess because im telling it to pick a random point in the list of randomly placed points as a vertex. That being said, i am keeping track of the original vertex order in the array 'verts' so i think that could help when drawing it back.

Is there any way of figuring out what order to draw them and then also disregarding points that would be inside the mesh, because there are some there. Here is my current code if it helps at all. i am assuming i would need to compare the position of one point to all the other points and then use that somehow, to at least ignore the internal points but i dont even know where to begin with that. if not i guess i can deal with particles until i can think of something else.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class sphereMeshChange : MonoBehaviour {
 
     public Mesh mesh;
     public Vector3[] verts;
     public Vector3[] editVerts;
     public Vector3[] origVertices;
     
     public int[] triangles;
     public int[] origTriangles;
     public float timeToWait;
     public float curTime;
     public int numOfVertsToEdit;
     int time;
     public int delay;
     public GameObject cube;
     public GameObject[] points;
     // Use this for initialization
     void Start () {
         mesh = GetComponent<MeshFilter>().mesh;
         verts = mesh.vertices;
         triangles = mesh.triangles;
         origTriangles = mesh.triangles;
         origVertices = mesh.vertices;
         points = new GameObject[100];
         
         editVerts = new Vector3[515];
 
         time = delay;
 
         verts = mesh.vertices;
 
         
 
 
     }
     
     // Update is called once per frame
     void Update () {
 
         
 
         if (GameObject.FindGameObjectWithTag("dataPoint") != null) {
             points = GameObject.FindGameObjectsWithTag("dataPoint");
         }
         
         
             for (int i = 0; i < verts.Length; i++)
             {
             int randInt = Random.Range(0,points.Length);
 
             if (points[randInt] != null) { editVerts[i] = points[randInt].transform.position; }
             }
         
 
 
         vertsOfWorld = editVerts;
 
         createMesh();
 
 
     }
 
     void createMesh()
     {
         
         mesh.vertices = vertsOfWorld;
         mesh.triangles = triangles;
         
 
     }
 
     void restoreMesh()
     {
         print("Restoring");
         
         verts = origVertices;
         triangles = origTriangles;
         createMesh();
 
 
     }
 }

Thanks for any help!

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 Eno-Khaon · May 09, 2018 at 09:21 AM 1
Share

You may want to look into Gift-Wrapping, as well as other Convex Hull Algorithms for ideas on creating a mesh around an arbitrary series of vertices.

This isn't an easy task and has a tendency to work well when implemented perfectly, or else result in especially disastrous meshes.

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

119 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

Related Questions

Multiple Cars not working 1 Answer

Substituting Sinus function with Perlin noise? 1 Answer

Generate FTL style star map 0 Answers

Does a Mesh Vertices/Triangles/etc Have to be Compact 1 Answer

Procedural Mesh Generation - Split Arrays into sections 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