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
1
Question by MylesLambert · Jan 02, 2013 at 12:09 AM · meshgridquad

Create grid of points inside irregular quad.

Hi! I've been working on creating a grid of vertices to fill an irregular quad that can be rotated/ skewed in a lot of different manners. To do this I am passing the script 4 points (these are always flat on the Y axis). Here is what I have so far :

http://answers.unity3d.com/storage/attachments/6280-irregularquad.jpg


(In case you are wonder what the use for this is, the camera is being used to project a quad onto the Y axis. This will then be tessellated to create an endless ocean). The yellow points are the current vertices, I now need to alter their Z axis to form a grid.

The current code I am using for calculating the line is this :

         for (int x = 0; x < vCount; x++) {
             for (int z = 0; z < hCount; z++)  {
                 vertices[index] = new Vector3(
                 ClipCorners[1].x + (((ClipCorners[2].x - ClipCorners[1].x) / (vCount-1)) * x),
                 clipHeight,
                 ClipCorners[1].z + (((ClipCorners[2].z - ClipCorners[1].z) / (vCount-1)) * x)
                 );
                 
             
                 index++;    
             }
             
         };

ClipCorners are the 4 corners of the quad in world space, vCount & hCount are dynamically increased to compensate for stretching of the quad. I know some of you are geometry math nuts so if there is a better way to be doing this please let me know! All that is important is that the grid is a.) in order for triangulation, b.) procedural creation (the pink quad is made stretching an existing model).

Thanks!

[1]: http://answers.unity3d.com/storage/attachments/6280-irregularquad.jpg

irregularquad.jpg (186.8 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by MylesLambert · Jan 02, 2013 at 11:58 PM

I made some progress with this (turns out sleep is the best answer), I just need to sort out some issues - not sure how to fix this slight over extension. Here is my updated code :)

 for (int x = 0; x < vCount; x++) {
             for (int z = 0; z < hCount; z++)  {
                 vertices[index] = ClipCorners[1] + 
                     (((ClipCorners[3] - ClipCorners[1]) / (hCount-1)) * z) 
                         + (((((ClipCorners[0] - ClipCorners[2]) / (hCount-1)) * z) / (vCount-1)) * x);
                 vertices[index]+= (((ClipCorners[2] - ClipCorners[1]) / (vCount-1)) * x);
                 vertices[index].y = clipHeight;
                 
                 index++;    
             }
             
         };

alt text


almost.jpg (75.3 kB)
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.

Follow this Question

Answers Answers and Comments

8 People are following this question.

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

Related Questions

How to find the center of quad polygons in a mesh 1 Answer

3D Terrain or Mesh Grid 1 Answer

Transparent grid shows odd irregularities when displayed. 1 Answer

Build plane on quad of mesh with same vertices 1 Answer

Procedurally generated mesh not Rendering all triangles 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