8 namespace droid.Runtime.Prototyping.Configurables.Experimental {
12 [AddComponentMenu(ConfigurableComponentMenuPath._ComponentMenuPath
14 + ConfigurableComponentMenuPath._Postfix)]
15 [RequireComponent(typeof(MeshFilter))]
19 Mesh _deforming_mesh = null;
20 Vector3[] _original_vertices = null, _displaced_vertices = null;
24 [SerializeField] Mesh[] _meshes = null;
25 [SerializeField] MeshFilter _mesh_filter = null;
26 [SerializeField]
bool _displace_mesh =
false;
27 [SerializeField]
Space1 _deformation_space =
new Space1 {_Min_Value = 1f, _Max_Value = 5f};
33 this._mesh_str = this.Identifier +
"Mesh";
34 this._mesh_filter = this.GetComponent<MeshFilter>();
35 if (Application.isPlaying) {
36 this._deforming_mesh = this._mesh_filter.mesh;
37 this._original_vertices = this._deforming_mesh.vertices;
38 this._displaced_vertices =
new Vector3[this._original_vertices.Length];
39 for (var i = 0; i < this._original_vertices.Length; i++) {
40 this._displaced_vertices[i] = this._original_vertices[i];
44 this._noise =
new Perlin();
51 this.ParentEnvironment =
52 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._mesh_str);
59 this.ParentEnvironment?.UnRegister(
this, this._mesh_str);
62 public override ISpace ConfigurableValueSpace {
get; }
69 DebugPrinting.ApplyPrint(this.Debugging, configuration, this.Identifier);
73 if (this._displace_mesh) {
74 if (this._deforming_mesh) {
75 var time_x = Time.time * this._speed + 0.1365143f;
76 var time_y = Time.time * this._speed + 1.21688f;
77 var time_z = Time.time * this._speed + 2.5564f;
79 for (var i = 0; i < this._displaced_vertices.Length; i++) {
80 var orig = this._original_vertices[i];
84 orig.x += this._noise.
Noise(time_x + orig.x, time_x + orig.y, time_x + orig.z)
86 orig.y += this._noise.
Noise(time_y + orig.x, time_y + orig.y, time_y + orig.z)
88 orig.z += this._noise.
Noise(time_z + orig.x, time_z + orig.y, time_z + orig.z)
91 this._displaced_vertices[i] = orig;
94 this._deforming_mesh.vertices = this._displaced_vertices;
96 this._deforming_mesh.RecalculateNormals();
98 }
else if (this._meshes.Length > 0) {
100 this._mesh_filter.mesh = this._meshes[idx];
override void ApplyConfiguration(IConfigurableConfiguration configuration)
override void RegisterComponent()
override void UnRegisterComponent()
override Configuration [] SampleConfigurations()