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 Se7eNJinx · Aug 26, 2014 at 10:36 PM · terrainarrayverticesgenerationperlin noise

Make a high poly count plane with code

Okay, so, I've been searching for this question all day and have yet to get anywhere. With a bunch of aids I've been able to make a low poly plane with code, that has 4 verts and 2 tris, But I want it to be more than that.

I have everything set to an array that can be adjusted on the start of the game, that makes several points in a 2D grid, and I'm trying to make it so that it makes a vertex and a connecting triangle across all the points.. But it just seems to make a stretched out plane of 4 verts and 2 tris... What step am I missing, and is it a simple fix that I just can't find?

Here's the code thus far:

 var Landsize : int;
 var size : float;
 var Land : GameObject;
 var scale : float = 1.0;
 var power : float = 3.0;
 var Adj : float;
 var Grid : Vector3[,];
 var NewPos : Vector3;
 private var Sample : Vector2 = new Vector2(0f,0f);
 function Start()
 {
     var Width : float = Landsize;
     var Height : float = Landsize;
     Grid = new Vector3[Landsize,Landsize];
     Sample = new Vector2(Random.Range(0.0f,size),Random.Range(0.0f,size));
     var m : Mesh = new Mesh();
     m.name = "Scripted_Plane_New_Mesh";
        for(var yCount=0;yCount<Landsize;yCount++)
     {
         Width -= Landsize;
         Height += Adj;
         for(var xCount=0;xCount<Landsize;xCount++)
         {
             Width += Adj;
             NewPos += Vector3(Width,0.01,Height);
             Grid[yCount,xCount] = NewPos;    
         }
 
     }
     for(var Point : Vector3 in Grid)
     {
         m.vertices = [Vector3(-Point.x, 0.01, -Point.z), Vector3(Point.x, 0.01, -Point.z), Vector3(Point.x, 0.01, Point.z), Vector3(-Point.x, 0.01, Point.z)];
          m.uv = [Vector2 (0, 0), Vector2 (0, 1), Vector2(1, 1), Vector2 (1, 0)];
           m.triangles = [0, 1, 2, 0, 2, 3];
            m.RecalculateNormals();
        }
     var obj : GameObject = new GameObject("New_Plane_Fom_Script", MeshRenderer, MeshFilter, MeshCollider);
     obj.GetComponent(MeshFilter).mesh = m;
     obj.transform.position = Vector3.zero;
     obj.transform.tag = "Land";
     Land = obj;
     MoveIt();
 }

"MoveIt();" takes all the vertices from the object that was just spawned from the code and moves it along a Perlin texture, which that part thus far works just fine, but there needs to be a -lot- more vertices for it to make a difference.

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 robertbu · Aug 26, 2014 at 10:40 PM 0
Share

You may want to fix your code as a learning exercise, but if you just want to the plane, you can use the CreatePlane editor script from the Unity Wiki.

You can either just make a plane at edit time and attach you Perlin noise code, or you can exa$$anonymous$$e/borrow the guts to help you with your code.

Note that there is a 64$$anonymous$$ limit to the number of vertices in a mesh, so the CreatePlane editor script has width/length limits. You can build something that is 254 x 254 with the script.

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

2 People are following this question.

avatar image avatar image

Related Questions

Terrain help 0 Answers

Perlin Noise for 3d Voxel Terrain 1 Answer

Can anyone explain this code? 1 Answer

2D Efficient Realtime Terrain Generation 0 Answers

3d Perlin Noise? 3 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