This repository has been archived by the owner on Aug 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPQSMod_VertexSimplexHeightAbsolute.cs
80 lines (69 loc) · 2.03 KB
/
PQSMod_VertexSimplexHeightAbsolute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
* libpqsmods - A standalone implementation of KSP's PQSMods
* Copyright (c) Thomas P. 2016
* Licensed under the terms of the MIT license
*/
using System;
using ProceduralQuadSphere.KSP;
namespace ProceduralQuadSphere
{
/// <summary>
/// A mod that modifies height on a planet based on the output of a simplex. Absolute version.
/// </summary>
/// <seealso cref="PQSMod" />
public class PQSMod_VertexSimplexHeightAbsolute : PQSMod
{
/// <summary>
/// The seed for the simplex
/// </summary>
public Int32 seed;
/// <summary>
/// The deformity for the terrain
/// </summary>
public Double deformity;
/// <summary>
/// The octaves for the simplex
/// </summary>
public Double octaves;
/// <summary>
/// The persistence for the simplex
/// </summary>
public Double persistence;
/// <summary>
/// The frequency for the simplex
/// </summary>
public Double frequency;
/// <summary>
/// The final simplex
/// </summary>
private Simplex simplex;
/// <summary>
/// Initializes the base mod
/// </summary>
public override void OnSetup()
{
simplex = new Simplex(seed, octaves, persistence, frequency);
}
/// <summary>
/// Called when the parent sphere builds it's height
/// </summary>
public override void OnVertexBuildHeight(VertexBuildData data)
{
data.vertHeight += (simplex.noise(data.directionFromCenter) + 1) * 0.5 * deformity;
}
/// <summary>
/// Gets the maximum height of the mod.
/// </summary>
public override Double GetVertexMaxHeight()
{
return deformity;
}
/// <summary>
/// Gets the minimum height of the mod.
/// </summary>
public override Double GetVertexMinHeight()
{
return -deformity;
}
}
}