77 lines
2.0 KiB
C#
77 lines
2.0 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace Artngame.SKYMASTER
|
|
{
|
|
public class RadialOceanSM : MonoBehaviour
|
|
{
|
|
public Material oceanMaterial;
|
|
|
|
public int oceanDetailx = 64;
|
|
|
|
public int oceanDetaily = 64;
|
|
|
|
private GameObject RadialOcean;
|
|
|
|
public float WaveHeightFactor = 2f;
|
|
|
|
private void Start()
|
|
{
|
|
CreateOcean();
|
|
}
|
|
|
|
public void CreateOcean()
|
|
{
|
|
RadialOcean = new GameObject("RadialOcean_SkyMaster");
|
|
float farClipPlane = Camera.main.farClipPlane;
|
|
RadialOcean.transform.localScale = new Vector3(farClipPlane, WaveHeightFactor, farClipPlane);
|
|
int num = oceanDetailx;
|
|
int num2 = oceanDetaily;
|
|
float num3 = num - 1;
|
|
float num4 = num2 - 1;
|
|
Vector3[] array = new Vector3[num * num2];
|
|
Vector3[] array2 = new Vector3[num * num2];
|
|
Vector2[] array3 = new Vector2[array.Length];
|
|
for (int i = 0; i < num; i++)
|
|
{
|
|
for (int j = 0; j < num2; j++)
|
|
{
|
|
float num5 = (float)i / num3;
|
|
float f = MathF.PI * 2f * ((float)j / num4);
|
|
array[i + j * num] = new Vector3(Mathf.Cos(f) * num5, 0f, Mathf.Sin(f) * num5);
|
|
array2[i + j * num] = Vector3.up;
|
|
}
|
|
}
|
|
int[] array4 = new int[6 * num * num2];
|
|
int num6 = 0;
|
|
int num7 = 0;
|
|
for (int k = 0; (float)k < num3; k++)
|
|
{
|
|
for (int l = 0; (float)l < num4; l++)
|
|
{
|
|
float num8 = l * num;
|
|
array4[num6++] = (int)((float)k + num8 + 0f);
|
|
array4[num6++] = (int)((float)k + num8 + (float)num);
|
|
array4[num6++] = (int)((float)k + num8 + 1f);
|
|
array4[num6++] = (int)((float)k + num8 + (float)num);
|
|
array4[num6++] = (int)((float)k + num8 + (float)num + 1f);
|
|
array4[num6++] = (int)((float)k + num8 + 1f);
|
|
array3[num7] = new Vector2(k / num, l / num2);
|
|
num7++;
|
|
}
|
|
}
|
|
Mesh mesh = new Mesh
|
|
{
|
|
vertices = array,
|
|
normals = array2,
|
|
uv = array3,
|
|
triangles = array4
|
|
};
|
|
RadialOcean.AddComponent<MeshFilter>();
|
|
RadialOcean.GetComponent<MeshFilter>().mesh = mesh;
|
|
RadialOcean.AddComponent<MeshRenderer>();
|
|
RadialOcean.GetComponent<Renderer>().material = oceanMaterial;
|
|
}
|
|
}
|
|
}
|