public static Vector3 CalculateLocalPosition(ref SgtBeltAsteroid asteroid, float age) { var a = asteroid.OrbitAngle + asteroid.OrbitSpeed * age; var x = (float)System.Math.Sin(a) * asteroid.OrbitDistance; var y = asteroid.Height; var z = (float)System.Math.Cos(a) * asteroid.OrbitDistance; return(new Vector3(x, y, z)); }
public void CopyFrom(SgtBeltAsteroid other) { Variant = other.Variant; Color = other.Color; Radius = other.Radius; Height = other.Height; Angle = other.Angle; Spin = other.Spin; OrbitAngle = other.OrbitAngle; OrbitSpeed = other.OrbitSpeed; OrbitDistance = other.OrbitDistance; }
protected override void NextQuad(ref SgtBeltAsteroid asteroid, int asteroidIndex) { //var distance01 = Random.value; var distance01 = (Random.value + Random.value) * 0.5f; asteroid.Variant = Random.Range(int.MinValue, int.MaxValue); asteroid.Color = Color.white; asteroid.Radius = Mathf.Lerp(AsteroidRadiusMin, AsteroidRadiusMax, SgtHelper.Sharpness(Random.value, AsteroidRadiusBias)); asteroid.Height = Mathf.Pow(Random.value, ThicknessBias) * Thickness * (Random.value < 0.5f ? -0.5f : 0.5f); asteroid.Angle = Random.Range(0.0f, Mathf.PI * 2.0f); asteroid.Spin = Random.Range(-AsteroidSpin, AsteroidSpin); asteroid.OrbitAngle = Random.Range(0.0f, Mathf.PI * 2.0f); asteroid.OrbitSpeed = Mathf.Lerp(InnerSpeed, OuterSpeed, distance01); asteroid.OrbitDistance = Mathf.Lerp(InnerRadius, OuterRadius, distance01); }
protected abstract void NextQuad(ref SgtBeltAsteroid quad, int starIndex);
protected override void NextQuad(ref SgtBeltAsteroid asteroid, int asteroidIndex) { asteroid.CopyFrom(asteroids[asteroidIndex]); }