- Home /

# How to find and use mesh positions in a variable for positions of other objects and generate them

I would like to know what the position of vertices in a mesh (but quadrants are more specific, and would be more helpful). Basically, what I want to do is have a sort of sphere, as created in Sebastian Lague's procedural planets, and find the positions of all quadrants to put a plane of noise onto it. This is his code that I used: using System.Collections; using System.Collections.Generic; using UnityEngine;

public class TerrainFace {

```
Mesh mesh; //The mesh itself
int resolution; //The resolution of the planet
Vector3 localUp;
Vector3 axisA; //Top and bottom of the mesh
Vector3 axisB; // Sizes of the mesh
public TerrainFace(Mesh mesh, int resolution, Vector3 localUp) //Generating the Terrain Faces, Uses variables Mesh, Resolution, Localup
{
this.mesh = mesh; //Sets the meshes globaly
this.resolution = resolution; //
this.localUp = localUp;//
axisA = new Vector3(localUp.y, localUp.z, localUp.x); //Position of the Sphere/Cube's faces
axisB = Vector3.Cross(localUp, axisA); //Makes them Join
}
public void ConstructMesh() //Constructing the mesh
{
Vector3[] vertices = new Vector3[resolution * resolution];//Tells us how many verticies there are
int[] triangles = new int[(resolution - 1) * (resolution - 1) * 6];//Tells us how many triangles there are
int triIndex = 0; //Creates variable triIndex
for (int y = 0; y < resolution; y++) //Tells us how big the y axis is
{
for (int x = 0; x < resolution; x++) //Tells the loop how big the x axis is
{
int i = x + y * resolution;
Vector2 percent = new Vector2(x, y) / (resolution - 1);
Vector3 pointOnUnitCube = localUp + (percent.x - .5f) * 2 * axisA + (percent.y - .5f) * 2 * axisB; //Defines the points where the angles generate
Vector3 pointOnUnitSphere = pointOnUnitCube.normalized; //Makes the cube become a sphere
vertices[i] = pointOnUnitSphere; //Part of making the cube a sphere
if (x != resolution - 1 && y != resolution - 1) //Defines the triangles on the cube/sphere
{
triangles[triIndex] = i;//Point one of the triangle
triangles[triIndex + 1] = i + resolution + 1; //Point 2 of the triangle
triangles[triIndex + 2] = i + resolution; //Point 3 of the triangle
triangles[triIndex + 3] = i;// Point one of the opposite triangle on the square of mesh
triangles[triIndex + 4] = i + 1;//repeated from above
triangles[triIndex + 5] = i + resolution + 1;
triIndex += 6;
}
}
}
mesh.Clear(); //Makes sure the existing mesh is cleared to reduce troubleshooting needed
mesh.vertices = vertices; //Puts the verticies on the mesh
mesh.triangles = triangles; //Puts the triangles into the mesh
mesh.RecalculateNormals(); //smooths out lighting
}
```

} How do I take the mesh out and apply those coordinates, angle, and rotation to a plane? I want to have a plane at each of the quads: https://imgur.com/a/r60FS78.

### Your answer

### 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.