Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class CreateBubblePlanet : MonoBehaviour {
- public int vertCount = 20;
- private float radius = 0.4f;
- private float off;
- private float inc = Mathf.PI * (3 - Mathf.Sqrt(5));
- private Vector3[] verticies;
- private float phi;
- private float r;
- private float y;
- // Initialization called by unity
- void Start () {
- radius *= vertCount;
- off = 2/vertCount;
- verticies = new Vector3[vertCount];
- CreateVertices();
- PopulateVertices();
- }
- // Update is called once per frame
- void Update () {
- }
- void CreateVertices()
- {
- for (int i = 0; i < vertCount; i++)
- {
- print(i);
- y = i * off - 1 + (off / 2);
- r = Mathf.Sqrt(1 - y * y);
- phi = i * inc;
- verticies[i] = new Vector3(Mathf.Cos(phi) * radius * r, y * radius, Mathf.Sin(phi)*r*radius);
- }
- }
- void PopulateVertices() {
- }
- }
Add Comment
Please, Sign In to add comment