/// <summary> /// </summary> /// <param name="configuration"></param> public override void ApplyConfiguration(IConfigurableConfiguration configuration) { #if NEODROID_DEBUG if (this.Debugging) { DebugPrinting.ApplyPrint(this.Debugging, configuration, this.Identifier); } #endif if (configuration.ConfigurableName == this._texture_str) { if (this._texture) { this._texture.anisoLevel = (int)configuration.ConfigurableValue; } } }
/// <summary> /// </summary> /// <param name="configuration"></param> public override void ApplyConfiguration(IConfigurableConfiguration configuration) { #if NEODROID_DEBUG DebugPrinting.ApplyPrint(this.Debugging, configuration, this.Identifier); #endif if (configuration.ConfigurableName == this._mesh_str) { if (this._displace_mesh) { if (this._deforming_mesh) { var time_x = Time.time * this._speed + 0.1365143f; var time_y = Time.time * this._speed + 1.21688f; var time_z = Time.time * this._speed + 2.5564f; for (var i = 0; i < this._displaced_vertices.Length; i++) { var orig = this._original_vertices[i]; //orig.y = orig.y * (1+(float)Math.Cos(Time.deltaTime))*(configuration.ConfigurableValue); //orig.x = orig.x * (1+(float)Math.Sin(Time.deltaTime))*(configuration.ConfigurableValue); orig.x += this._noise.Noise(time_x + orig.x, time_x + orig.y, time_x + orig.z) * configuration.ConfigurableValue; orig.y += this._noise.Noise(time_y + orig.x, time_y + orig.y, time_y + orig.z) * configuration.ConfigurableValue; orig.z += this._noise.Noise(time_z + orig.x, time_z + orig.y, time_z + orig.z) * configuration.ConfigurableValue; this._displaced_vertices[i] = orig; } this._deforming_mesh.vertices = this._displaced_vertices; this._deforming_mesh.RecalculateNormals(); } } else if (this._meshes.Length > 0) { var idx = (int)(configuration.ConfigurableValue * this._meshes.Length); this._mesh_filter.mesh = this._meshes[idx]; } } }
/// <summary> /// </summary> /// <param name="configuration"></param> public override void ApplyConfiguration(IConfigurableConfiguration configuration) { #if NEODROID_DEBUG if (this.Debugging) { DebugPrinting.ApplyPrint(this.Debugging, configuration, this.Identifier); } #endif var pos = this.transform.position; var rot = this.transform.rotation; if (configuration.ConfigurableName == this._x) { pos.x = configuration.ConfigurableValue; } else if (configuration.ConfigurableName == this._y) { pos.y = configuration.ConfigurableValue; } else if (configuration.ConfigurableName == this._z) { pos.z = configuration.ConfigurableValue; } else if (configuration.ConfigurableName == this._rx) { rot.x = configuration.ConfigurableValue; } else if (configuration.ConfigurableName == this._ry) { rot.y = configuration.ConfigurableValue; } else if (configuration.ConfigurableName == this._rz) { rot.z = configuration.ConfigurableValue; } else if (configuration.ConfigurableName == this._rw) { rot.w = configuration.ConfigurableValue; } this.transform.position = pos; this.transform.rotation = rot; }
/// <summary> /// </summary> /// <param name="configuration"></param> public override void ApplyConfiguration(IConfigurableConfiguration configuration) { #if NEODROID_DEBUG if (this.Debugging) { DebugPrinting.ApplyPrint(this.Debugging, configuration, this.Identifier); } #endif if (configuration.ConfigurableName == this._shadow_strength) { this._light.shadowStrength = configuration.ConfigurableValue; } else if (configuration.ConfigurableName == this._color_r) { var c = this._light.color; c.r = configuration.ConfigurableValue; this._light.color = c; } else if (configuration.ConfigurableName == this._color_g) { var c = this._light.color; c.g = configuration.ConfigurableValue; this._light.color = c; } else if (configuration.ConfigurableName == this._color_b) { var c = this._light.color; c.b = configuration.ConfigurableValue; this._light.color = c; } else if (configuration.ConfigurableName == this._intensity) { this._light.intensity = configuration.ConfigurableValue; } else if (configuration.ConfigurableName == this._indirect_multiplier) { this._light.bounceIntensity = configuration.ConfigurableValue; } }
/// <summary> /// </summary> /// <param name="configuration"></param> public override void ApplyConfiguration(IConfigurableConfiguration configuration) { #if NEODROID_DEBUG if (this.Debugging) { DebugPrinting.ApplyPrint(this.Debugging, configuration, this.Identifier); } #endif var c = RenderSettings.ambientLight; if (configuration.ConfigurableName == this._color_r) { c.r = configuration.ConfigurableValue; } else if (configuration.ConfigurableName == this._color_g) { c.g = configuration.ConfigurableValue; } else if (configuration.ConfigurableName == this._color_b) { c.b = configuration.ConfigurableValue; } else if (configuration.ConfigurableName == this._intensity) { //c.a = configuration.ConfigurableValue; RenderSettings.ambientIntensity = configuration.ConfigurableValue; RenderSettings.reflectionIntensity = Mathf.Clamp01(configuration.ConfigurableValue); //RenderSettings.skybox.SetFloat("_Exposure", configuration.ConfigurableValue); } else if (configuration.ConfigurableName == this._reflection_intensity) { //c.a = configuration.ConfigurableValue; // RenderSettings.reflectionIntensity = configuration.ConfigurableValue; //RenderSettings.skybox.SetFloat("_Exposure", configuration.ConfigurableValue); } RenderSettings.ambientLight = c; DynamicGI.UpdateEnvironment(); }
/// <summary> /// </summary> /// <param name="simulator_configuration"></param> public override void ApplyConfiguration(IConfigurableConfiguration simulator_configuration) { #if NEODROID_DEBUG if (this.Debugging) { Debug.Log("Applying " + simulator_configuration + " To " + this.Identifier); } #endif if (simulator_configuration.ConfigurableName == this._quality_level) { QualitySettings.SetQualityLevel((int)simulator_configuration.ConfigurableValue, true); } else if (simulator_configuration.ConfigurableName == this._target_frame_rate) { Application.targetFrameRate = (int)simulator_configuration.ConfigurableValue; } else if (simulator_configuration.ConfigurableName == this._width) { Screen.SetResolution((int)simulator_configuration.ConfigurableValue, Screen.height, false); } else if (simulator_configuration.ConfigurableName == this._height) { Screen.SetResolution(Screen.width, (int)simulator_configuration.ConfigurableValue, false); } else if (simulator_configuration.ConfigurableName == this._fullscreen) { Screen.SetResolution( Screen.width, Screen.height, (int)simulator_configuration.ConfigurableValue != 0); } else if (simulator_configuration.ConfigurableName == this._time_scale) { Time.timeScale = simulator_configuration.ConfigurableValue; } }
/// <summary> /// </summary> /// <param name="configuration"></param> public override void ApplyConfiguration(IConfigurableConfiguration configuration) { #if NEODROID_DEBUG if (this.Debugging) { DebugPrinting.ApplyPrint(this.Debugging, configuration, this.Identifier); } #endif var local_scale = this.transform.localScale; if (configuration.ConfigurableName == this._x) { local_scale.x = configuration.ConfigurableValue; } else if (configuration.ConfigurableName == this._y) { local_scale.y = configuration.ConfigurableValue; } else if (configuration.ConfigurableName == this._z) { local_scale.z = configuration.ConfigurableValue; } this.transform.localScale = local_scale; }
public override void ApplyConfiguration(IConfigurableConfiguration obj) { if (obj.ConfigurableName == this._pos_x) { } else if (obj.ConfigurableName == this._pos_y) { } else if (obj.ConfigurableName == this._pos_z) { } else if (obj.ConfigurableName == this._rot_x) { } else if (obj.ConfigurableName == this._rot_y) { } else if (obj.ConfigurableName == this._rot_z) { } else if (obj.ConfigurableName == this._rot_w) { } }
/// <inheritdoc /> /// <summary> /// </summary> /// <param name="configuration"></param> public override void ApplyConfiguration(IConfigurableConfiguration configuration) { var pos = this.transform.position; var dir = this.transform.forward; var rot = this.transform.up; if (this._use_environments_space) { pos = this.ParentEnvironment.TransformPosition(pos); dir = this.ParentEnvironment.TransformDirection(dir); rot = this.ParentEnvironment.TransformDirection(rot); } var v = configuration.ConfigurableValue; if (this.PositionSpace._Decimal_Granularity >= 0) { v = (int)Math.Round(v, this.PositionSpace._Decimal_Granularity); } if (this.PositionSpace._Min_Values[0].CompareTo(this.PositionSpace._Max_Values[0]) != 0) { //TODO NOT IMPLEMENTED CORRECTLY VelocitySpace should not be index but should check all pairwise values, PositionSpace._Min_Values == PositionSpace._Max_Values, and use other space aswell! if (v < this.PositionSpace._Min_Values[0] || v > this.PositionSpace._Max_Values[0]) { Debug.Log( string.Format( "Configurable does not accept input{2}, outside allowed range {0} to {1}", this.PositionSpace._Min_Values[0], this.PositionSpace._Max_Values[0], v)); return; // Do nothing } } #if NEODROID_DEBUG if (this.Debugging) { Debug.Log("Applying " + v + " To " + this.Identifier); } #endif if (this.RelativeToExistingValue) { if (configuration.ConfigurableName == this._x) { pos.Set(v - pos.x, pos.y, pos.z); } else if (configuration.ConfigurableName == this._y) { pos.Set(pos.x, v - pos.y, pos.z); } else if (configuration.ConfigurableName == this._z) { pos.Set(pos.x, pos.y, v - pos.z); } else if (configuration.ConfigurableName == this._dir_x) { dir.Set(v - dir.x, dir.y, dir.z); } else if (configuration.ConfigurableName == this._dir_y) { dir.Set(dir.x, v - dir.y, dir.z); } else if (configuration.ConfigurableName == this._dir_z) { dir.Set(dir.x, dir.y, v - dir.z); } else if (configuration.ConfigurableName == this._rot_x) { rot.Set(v - rot.x, rot.y, rot.z); } else if (configuration.ConfigurableName == this._rot_y) { rot.Set(rot.x, v - rot.y, rot.z); } else if (configuration.ConfigurableName == this._rot_z) { rot.Set(rot.x, rot.y, v - rot.z); } } else { if (configuration.ConfigurableName == this._x) { pos.Set(v, pos.y, pos.z); } else if (configuration.ConfigurableName == this._y) { pos.Set(pos.x, v, pos.z); } else if (configuration.ConfigurableName == this._z) { pos.Set(pos.x, pos.y, v); } else if (configuration.ConfigurableName == this._dir_x) { dir.Set(v, dir.y, dir.z); } else if (configuration.ConfigurableName == this._dir_y) { dir.Set(dir.x, v, dir.z); } else if (configuration.ConfigurableName == this._dir_z) { dir.Set(dir.x, dir.y, v); } else if (configuration.ConfigurableName == this._rot_x) { rot.Set(v, rot.y, rot.z); } else if (configuration.ConfigurableName == this._rot_y) { rot.Set(rot.x, v, rot.z); } else if (configuration.ConfigurableName == this._rot_z) { rot.Set(rot.x, rot.y, v); } } var inv_pos = pos; var inv_dir = dir; var inv_rot = rot; if (this._use_environments_space) { inv_pos = this.ParentEnvironment.InverseTransformPosition(pos); inv_dir = this.ParentEnvironment.InverseTransformDirection(dir); inv_rot = this.ParentEnvironment.InverseTransformDirection(rot); } this.transform.position = inv_pos; this.transform.rotation = Quaternion.identity; this.transform.rotation = Quaternion.LookRotation(inv_dir, inv_rot); }
/// <summary> /// </summary> /// <param name="configuration"></param> public override void ApplyConfiguration(IConfigurableConfiguration configuration) { #if NEODROID_DEBUG if (this.Debugging) { DebugPrinting.ApplyPrint(this.Debugging, configuration, this.Identifier); } #endif if (!this._use_shared) { foreach (var mat in this._renderer.materials) { var c = mat.color; if (configuration.ConfigurableName.Equals(this._r, StringComparison.Ordinal)) { c.r = configuration.ConfigurableValue; } else if (string.Equals(configuration.ConfigurableName, this._g, StringComparison.Ordinal)) { c.g = configuration.ConfigurableValue; } else if (string.Equals(configuration.ConfigurableName, this._b, StringComparison.Ordinal)) { c.b = configuration.ConfigurableValue; } else if (string.Equals(configuration.ConfigurableName, this._a, StringComparison.Ordinal)) { c.a = configuration.ConfigurableValue; } else if (string.Equals(configuration.ConfigurableName, this._smoothness, StringComparison.Ordinal)) { mat.SetFloat(_glossiness, configuration.ConfigurableValue); } else if (string.Equals(configuration.ConfigurableName, this._reflection, StringComparison.Ordinal)) { mat.SetFloat(_glossy_reflections, configuration.ConfigurableValue); } else if (string.Equals(configuration.ConfigurableName, this._offset_x, StringComparison.Ordinal)) { var a = mat.GetTextureOffset(_main_tex); a.x = configuration.ConfigurableValue; mat.SetTextureOffset(_main_tex, a); } else if (string.Equals(configuration.ConfigurableName, this._offset_y, StringComparison.Ordinal)) { var a = mat.GetTextureOffset(_main_tex); a.y = configuration.ConfigurableValue; mat.SetTextureOffset(_main_tex, a); } else if (string.Equals(configuration.ConfigurableName, this._tiling_x, StringComparison.Ordinal)) { var a = mat.GetTextureScale(_main_tex); a.x = configuration.ConfigurableValue; mat.SetTextureScale(_main_tex, a); } else if (string.Equals(configuration.ConfigurableName, this._tiling_y, StringComparison.Ordinal)) { var a = mat.GetTextureScale(_main_tex); a.y = configuration.ConfigurableValue; mat.SetTextureScale(_main_tex, a); } mat.color = c; } } else { foreach (var mat in this._renderer.sharedMaterials) { var c = mat.color; if (string.Equals(configuration.ConfigurableName, this._r, StringComparison.Ordinal)) { c.r = configuration.ConfigurableValue; } else if (string.Equals(configuration.ConfigurableName, this._g, StringComparison.Ordinal)) { c.g = configuration.ConfigurableValue; } else if (string.Equals(configuration.ConfigurableName, this._b, StringComparison.Ordinal)) { c.b = configuration.ConfigurableValue; } else if (string.Equals(configuration.ConfigurableName, this._a, StringComparison.Ordinal)) { c.a = configuration.ConfigurableValue; } else if (string.Equals(configuration.ConfigurableName, this._smoothness, StringComparison.Ordinal)) { mat.SetFloat(_glossiness, configuration.ConfigurableValue); } else if (string.Equals(configuration.ConfigurableName, this._reflection, StringComparison.Ordinal)) { mat.SetFloat(_glossy_reflections, configuration.ConfigurableValue); } else if (string.Equals(configuration.ConfigurableName, this._offset_x, StringComparison.Ordinal)) { var a = mat.GetTextureOffset(_main_tex); a.x = configuration.ConfigurableValue; mat.SetTextureOffset(_main_tex, a); } else if (string.Equals(configuration.ConfigurableName, this._offset_y, StringComparison.Ordinal)) { var a = mat.GetTextureOffset(_main_tex); a.y = configuration.ConfigurableValue; mat.SetTextureOffset(_main_tex, a); } else if (string.Equals(configuration.ConfigurableName, this._tiling_x, StringComparison.Ordinal)) { var a = mat.GetTextureScale(_main_tex); a.x = configuration.ConfigurableValue; mat.SetTextureScale(_main_tex, a); } else if (string.Equals(configuration.ConfigurableName, this._tiling_y, StringComparison.Ordinal)) { var a = mat.GetTextureScale(_main_tex); a.y = configuration.ConfigurableValue; mat.SetTextureScale(_main_tex, a); } mat.color = c; } } }
public override void ApplyConfiguration(IConfigurableConfiguration simulator_configuration) { if (simulator_configuration.ConfigurableValue < this.SingleSpace._Min_Value || simulator_configuration.ConfigurableValue > this.SingleSpace._Max_Value) { Debug.Log( $"It does not accept input, outside allowed range {this.SingleSpace._Min_Value} to {this.SingleSpace._Max_Value}"); return; // Do nothing } #if NEODROID_DEBUG if (this.Debugging) { Debug.Log("Applying " + simulator_configuration + " To " + this.Identifier); } #endif var pos = this.transform.position; var dir = this.transform.forward; var rot = this.transform.up; if (this._use_environments_space) { pos = this.ParentEnvironment.TransformPosition(pos); dir = this.ParentEnvironment.TransformDirection(dir); rot = this.ParentEnvironment.TransformDirection(rot); } switch (this._axis_of_configuration) { case Axis.X_: if (this.RelativeToExistingValue) { pos.Set(simulator_configuration.ConfigurableValue - pos.x, pos.y, pos.z); } else { pos.Set(simulator_configuration.ConfigurableValue, pos.y, pos.z); } break; case Axis.Y_: if (this.RelativeToExistingValue) { pos.Set(pos.x, simulator_configuration.ConfigurableValue - pos.y, pos.z); } else { pos.Set(pos.x, simulator_configuration.ConfigurableValue, pos.z); } break; case Axis.Z_: if (this.RelativeToExistingValue) { pos.Set(pos.x, pos.y, simulator_configuration.ConfigurableValue - pos.z); } else { pos.Set(pos.x, pos.y, simulator_configuration.ConfigurableValue); } break; case Axis.Dir_x_: if (this.RelativeToExistingValue) { dir.Set(simulator_configuration.ConfigurableValue - dir.x, dir.y, dir.z); } else { dir.Set(simulator_configuration.ConfigurableValue, dir.y, dir.z); } break; case Axis.Dir_y_: if (this.RelativeToExistingValue) { dir.Set(dir.x, simulator_configuration.ConfigurableValue - dir.y, dir.z); } else { dir.Set(dir.x, simulator_configuration.ConfigurableValue, dir.z); } break; case Axis.Dir_z_: if (this.RelativeToExistingValue) { dir.Set(dir.x, dir.y, simulator_configuration.ConfigurableValue - dir.z); } else { dir.Set(dir.x, dir.y, simulator_configuration.ConfigurableValue); } break; case Axis.Rot_x_: if (this.RelativeToExistingValue) { rot.Set(simulator_configuration.ConfigurableValue - rot.x, rot.y, rot.z); } else { rot.Set(simulator_configuration.ConfigurableValue, rot.y, rot.z); } break; case Axis.Rot_y_: if (this.RelativeToExistingValue) { rot.Set(rot.x, simulator_configuration.ConfigurableValue - rot.y, rot.z); } else { rot.Set(rot.x, simulator_configuration.ConfigurableValue, rot.z); } break; case Axis.Rot_z_: if (this.RelativeToExistingValue) { rot.Set(rot.x, rot.y, simulator_configuration.ConfigurableValue - rot.z); } else { rot.Set(rot.x, rot.y, simulator_configuration.ConfigurableValue); } break; default: throw new ArgumentOutOfRangeException(); } var inv_pos = pos; var inv_dir = dir; var inv_rot = rot; if (this._use_environments_space) { inv_pos = this.ParentEnvironment.InverseTransformPosition(inv_pos); inv_dir = this.ParentEnvironment.InverseTransformDirection(inv_dir); inv_rot = this.ParentEnvironment.InverseTransformDirection(inv_rot); } this.transform.position = inv_pos; this.transform.rotation = Quaternion.identity; this.transform.rotation = Quaternion.LookRotation(inv_dir, inv_rot); }
/// <summary> /// /// </summary> /// <param name="simulator_configuration"></param> public override void ApplyConfiguration(IConfigurableConfiguration simulator_configuration) { //TODO: Denormalize configuration if space is marked as normalised var rot = this.transform.rotation; if (this.ParentEnvironment && this._use_environments_space) { rot = this.ParentEnvironment.TransformRotation(this.transform.rotation); } var v = simulator_configuration.ConfigurableValue; if (this.QuadSpace.DecimalGranularity >= 0) { v = (int)Math.Round(v, this.QuadSpace.DecimalGranularity); } #if NEODROID_DEBUG if (this.Debugging) { Debug.Log($"Applying {v} to {simulator_configuration.ConfigurableName} configurable"); } #endif if (this.RelativeToExistingValue) { if (simulator_configuration.ConfigurableName == this._x) { if (this.QuadSpace.Min.x.CompareTo(this.QuadSpace.Max.x) != 0) { if (v < this.QuadSpace.Min.x || v > this.QuadSpace.Max.x) { Debug.Log($"ConfigurableX does not accept input {v}, outside allowed range " + $"{this.QuadSpace.Min.x} to {this.QuadSpace.Max.x}"); return; // Do nothing } } rot.Set(rot.x - v, rot.y, rot.z, rot.w); } else if (simulator_configuration.ConfigurableName == this._y) { if (this.QuadSpace.Min.y.CompareTo(this.QuadSpace.Max.y) != 0) { if (v < this.QuadSpace.Min.y || v > this.QuadSpace.Max.y) { Debug.Log($"ConfigurableY does not accept input {v}, outside allowed range " + $"{this.QuadSpace.Min.y} to {this.QuadSpace.Max.y}"); return; // Do nothing } } rot.Set(rot.x, rot.y - v, rot.z, rot.w); } else if (simulator_configuration.ConfigurableName == this._z) { if (this.QuadSpace.Min.z.CompareTo(this.QuadSpace.Max.z) != 0) { if (v < this.QuadSpace.Min.z || v > this.QuadSpace.Max.z) { Debug.Log($"ConfigurableZ does not accept input {v}, outside allowed range " + $"{this.QuadSpace.Min.z} to {this.QuadSpace.Max.z}"); return; // Do nothing } } rot.Set(rot.x, rot.y, rot.z - v, rot.w); } else if (simulator_configuration.ConfigurableName == this._w) { if (this.QuadSpace.Min.w.CompareTo(this.QuadSpace.Max.w) != 0) { if (v < this.QuadSpace.Min.w || v > this.QuadSpace.Max.w) { Debug.Log($"ConfigurableW does not accept input {v}, outside allowed range " + $"{this.QuadSpace.Min.w} to {this.QuadSpace.Max.w}"); return; // Do nothing } } rot.Set(rot.x, rot.y, rot.z, rot.w - v); } } else { if (simulator_configuration.ConfigurableName == this._x) { if (this.QuadSpace.Min.x.CompareTo(this.QuadSpace.Max.x) != 0) { if (v < this.QuadSpace.Min.x || v > this.QuadSpace.Max.x) { Debug.Log($"ConfigurableX does not accept input {v}, outside allowed range " + $"{this.QuadSpace.Min.x} to {this.QuadSpace.Max.x}"); return; // Do nothing } } rot.Set(v, rot.y, rot.z, rot.w); //rot.x = v; } else if (simulator_configuration.ConfigurableName == this._y) { if (this.QuadSpace.Min.y.CompareTo(this.QuadSpace.Max.y) != 0) { if (v < this.QuadSpace.Min.y || v > this.QuadSpace.Max.y) { Debug.Log($"ConfigurableY does not accept input {v}, outside allowed range " + $"{this.QuadSpace.Min.y} to {this.QuadSpace.Max.y}"); return; // Do nothing } } rot.Set(rot.x, v, rot.z, rot.w); //rot.y = v; } else if (simulator_configuration.ConfigurableName == this._z) { if (this.QuadSpace.Min.z.CompareTo(this.QuadSpace.Max.z) != 0) { if (v < this.QuadSpace.Min.z || v > this.QuadSpace.Max.z) { Debug.Log($"ConfigurableZ does not accept input {v}, outside allowed range " + $"{this.QuadSpace.Min.z} to {this.QuadSpace.Max.z}"); return; // Do nothing } } rot.Set(rot.x, rot.y, v, rot.w); //rot.z = v; } else if (simulator_configuration.ConfigurableName == this._w) { if (this.QuadSpace.Min.w.CompareTo(this.QuadSpace.Max.w) != 0) { if (v < this.QuadSpace.Min.w || v > this.QuadSpace.Max.w) { Debug.Log($"ConfigurableW does not accept input {v}, outside allowed range " + $"{this.QuadSpace.Min.w} to {this.QuadSpace.Max.w}"); return; // Do nothing } } rot.Set(rot.x, rot.y, rot.z, v); //rot.w = v; } } if (this.ParentEnvironment && this._use_environments_space) { rot = this.ParentEnvironment.InverseTransformRotation(rot); } this.transform.rotation = rot; }
/// <summary> /// /// </summary> /// <param name="simulator_configuration"></param> public override void ApplyConfiguration(IConfigurableConfiguration simulator_configuration) //TODO: IMPLEMENT LOCAL SPACE { Vector3 pos; if (this.coordinate_space == CoordinateSpace.Local_) { pos = this.transform.localPosition; } else { pos = this.transform.position; } if (this.coordinate_space == CoordinateSpace.Environment_) { pos = this.ParentEnvironment.TransformPoint(this.transform.position); } float v; if (simulator_configuration.ConfigurableName == this._x) { v = this._pos_space._space.Xspace.Project(simulator_configuration.ConfigurableValue); } else if (simulator_configuration.ConfigurableName == this._y) { v = this._pos_space._space.Yspace.Project(simulator_configuration.ConfigurableValue); } else { v = this._pos_space._space.Zspace.Project(simulator_configuration.ConfigurableValue); } #if NEODROID_DEBUG if (this.Debugging) { Debug.Log($"Applying {v} to {simulator_configuration.ConfigurableName} configurable"); } #endif if (this.RelativeToExistingValue) { if (simulator_configuration.ConfigurableName == this._x) { pos.Set(v + pos.x, pos.y, pos.z); } else if (simulator_configuration.ConfigurableName == this._y) { pos.Set(pos.x, v + pos.y, pos.z); } else if (simulator_configuration.ConfigurableName == this._z) { pos.Set(pos.x, pos.y, v + pos.z); } } else { if (simulator_configuration.ConfigurableName == this._x) { pos.Set(v, pos.y, pos.z); } else if (simulator_configuration.ConfigurableName == this._y) { pos.Set(pos.x, v, pos.z); } else if (simulator_configuration.ConfigurableName == this._z) { pos.Set(pos.x, pos.y, v); } } var inv_pos = pos; if (this.coordinate_space == CoordinateSpace.Environment_) { inv_pos = this.ParentEnvironment.InverseTransformPoint(inv_pos); } #if NEODROID_DEBUG if (this.Debugging) { Debug.Log($"Setting pos of {this} to {inv_pos}, from {pos} and r {simulator_configuration.ConfigurableValue}"); } #endif if (this.coordinate_space == CoordinateSpace.Local_) { this.transform.localPosition = inv_pos; } else { this.transform.position = inv_pos; } }
/// <summary> /// /// </summary> /// <param name="simulator_configuration"></param> public override void ApplyConfiguration(IConfigurableConfiguration simulator_configuration) { Quaternion rot; if (this.coordinate_space == CoordinateSpace.Local_) { rot = this.transform.localRotation; } else { rot = this.transform.rotation; } if (this.coordinate_space == CoordinateSpace.Environment_) { rot = this.ParentEnvironment.TransformRotation(this.transform.rotation); } var v = simulator_configuration.ConfigurableValue; if (this.TripleSpace.DecimalGranularity >= 0) { v = (int)Math.Round(v, this.TripleSpace.DecimalGranularity); } #if NEODROID_DEBUG if (this.Debugging) { Debug.Log($"Applying {v} to {simulator_configuration.ConfigurableName} configurable"); } #endif var rote = rot.eulerAngles; if (this.RelativeToExistingValue) { if (simulator_configuration.ConfigurableName == this._x) { if (this.TripleSpace.Min[0].CompareTo(this.TripleSpace.Max[0]) != 0) { #if NEODROID_DEBUG if (v < this.TripleSpace.Min[0] || v > this.TripleSpace.Max[0]) { Debug.Log($"Configurable does not accept input {v}, outside allowed range {this.TripleSpace.Min[0]} to {this.TripleSpace.Max[0]}"); return; // Do nothing } #endif } rot.eulerAngles = new Vector3(v + rote.x, rote.y, rote.z); } else if (simulator_configuration.ConfigurableName == this._y) { rot.eulerAngles = new Vector3(rote.x, v + rote.y, rote.z); } else if (simulator_configuration.ConfigurableName == this._z) { rot.eulerAngles = new Vector3(rote.x, rote.y, v + rote.z); } } else { if (simulator_configuration.ConfigurableName == this._x) { rot.eulerAngles = new Vector3(v, rote.y, rote.z); } else if (simulator_configuration.ConfigurableName == this._y) { rot.eulerAngles = new Vector3(rote.x, v, rote.z); } else if (simulator_configuration.ConfigurableName == this._z) { rot.eulerAngles = new Vector3(rote.x, rote.y, v); } } if (this.coordinate_space == CoordinateSpace.Environment_) { rot = this.ParentEnvironment.InverseTransformRotation(rot); } if (this.coordinate_space == CoordinateSpace.Local_) { this.transform.localRotation = rot; } else { this.transform.rotation = rot; } }
/// <summary> /// /// </summary> /// <param name="simulator_configuration"></param> /// <exception cref="ArgumentOutOfRangeException"></exception> public override void ApplyConfiguration(IConfigurableConfiguration simulator_configuration) { float cv = this.SingleSpace.Reproject(simulator_configuration.ConfigurableValue); #if NEODROID_DEBUG if (this.Debugging) { Debug.Log("Applying " + simulator_configuration + " To " + this.Identifier); } #endif var transform1 = this.transform; Vector3 pos; if (this.coordinate_space == CoordinateSpace.Local_) { pos = transform1.localPosition; } else { pos = transform1.position; } var dir = transform1.forward; var rot = transform1.up; if (this.coordinate_space == CoordinateSpace.Environment_) { if (this.ParentEnvironment != null) { this.ParentEnvironment.TransformPoint(ref pos); this.ParentEnvironment.TransformDirection(ref dir); this.ParentEnvironment.TransformDirection(ref rot); } else { Debug.LogWarning("ParentEnvironment not found!"); } } switch (this._axis_of_configuration) { case Axis.X_: if (this.RelativeToExistingValue) { pos.Set(cv + pos.x, pos.y, pos.z); } else { pos.Set(cv, pos.y, pos.z); } break; case Axis.Y_: if (this.RelativeToExistingValue) { pos.Set(pos.x, cv + pos.y, pos.z); } else { pos.Set(pos.x, cv, pos.z); } break; case Axis.Z_: if (this.RelativeToExistingValue) { pos.Set(pos.x, pos.y, cv + pos.z); } else { pos.Set(pos.x, pos.y, cv); } break; case Axis.Dir_x_: if (this.RelativeToExistingValue) { dir.Set(cv + dir.x, dir.y, dir.z); } else { dir.Set(cv, dir.y, dir.z); } break; case Axis.Dir_y_: if (this.RelativeToExistingValue) { dir.Set(dir.x, cv + dir.y, dir.z); } else { dir.Set(dir.x, cv, dir.z); } break; case Axis.Dir_z_: if (this.RelativeToExistingValue) { dir.Set(dir.x, dir.y, cv + dir.z); } else { dir.Set(dir.x, dir.y, cv); } break; case Axis.Rot_x_: if (this.RelativeToExistingValue) { rot.Set(cv + rot.x, rot.y, rot.z); } else { rot.Set(cv, rot.y, rot.z); } break; case Axis.Rot_y_: if (this.RelativeToExistingValue) { rot.Set(rot.x, cv + rot.y, rot.z); } else { rot.Set(rot.x, cv, rot.z); } break; case Axis.Rot_z_: if (this.RelativeToExistingValue) { rot.Set(rot.x, rot.y, cv + rot.z); } else { rot.Set(rot.x, rot.y, cv); } break; default: throw new ArgumentOutOfRangeException(); } var inv_pos = pos; var inv_dir = dir; var inv_rot = rot; if (this.coordinate_space == CoordinateSpace.Environment_) { if (this.ParentEnvironment != null) { this.ParentEnvironment.InverseTransformPoint(ref inv_pos); this.ParentEnvironment.InverseTransformDirection(ref inv_dir); this.ParentEnvironment.InverseTransformDirection(ref inv_rot); } else { Debug.LogWarning("ParentEnvironment not found!"); } } if (this.coordinate_space == CoordinateSpace.Local_) { transform1.localPosition = inv_pos; } else { this.transform.position = inv_pos; } this.transform.rotation = Quaternion.identity; this.transform.rotation = Quaternion.LookRotation(inv_dir, inv_rot); }
public abstract void ApplyConfiguration(IConfigurableConfiguration configuration);
/// <summary> /// </summary> /// <param name="simulator_configuration"></param> public override void ApplyConfiguration(IConfigurableConfiguration simulator_configuration) { var vel = this._rigidbody.velocity; var ang = this._rigidbody.velocity; var v = simulator_configuration.ConfigurableValue; if (this.VelocitySpace.DecimalGranularity >= 0) { v = (int)Math.Round(v, this.VelocitySpace.DecimalGranularity); } if (this.VelocitySpace.Min[0].CompareTo(this.VelocitySpace.Max[0]) != 0) { //TODO NOT IMPLEMENTED CORRECTLY VelocitySpace should not be index but should check all pairwise values, VelocitySpace.MinValues == VelocitySpace.MaxValues if (v < this.VelocitySpace.Min[0] || v > this.VelocitySpace.Max[0]) { Debug.Log(string.Format("Configurable does not accept input{2}, outside allowed range {0} to {1}", this.VelocitySpace.Min[0], this.VelocitySpace.Max[0], v)); return; // Do nothing } } #if NEODROID_DEBUG if (this.Debugging) { Debug.Log("Applying " + v + " To " + this.Identifier); } #endif if (this.RelativeToExistingValue) { if (simulator_configuration.ConfigurableName == this._vel_x) { vel.Set(v - vel.x, vel.y, vel.z); } else if (simulator_configuration.ConfigurableName == this._vel_y) { vel.Set(vel.x, v - vel.y, vel.z); } else if (simulator_configuration.ConfigurableName == this._vel_z) { vel.Set(vel.x, vel.y, v - vel.z); } else if (simulator_configuration.ConfigurableName == this._ang_x) { ang.Set(v - ang.x, ang.y, ang.z); } else if (simulator_configuration.ConfigurableName == this._ang_y) { ang.Set(ang.x, v - ang.y, ang.z); } else if (simulator_configuration.ConfigurableName == this._ang_z) { ang.Set(ang.x, ang.y, v - ang.z); } } else { if (simulator_configuration.ConfigurableName == this._vel_x) { vel.Set(v, vel.y, vel.z); } else if (simulator_configuration.ConfigurableName == this._vel_y) { vel.Set(vel.x, v, vel.z); } else if (simulator_configuration.ConfigurableName == this._vel_z) { vel.Set(vel.x, vel.y, v); } else if (simulator_configuration.ConfigurableName == this._ang_x) { ang.Set(v, ang.y, ang.z); } else if (simulator_configuration.ConfigurableName == this._ang_y) { ang.Set(ang.x, v, ang.z); } else if (simulator_configuration.ConfigurableName == this._ang_z) { ang.Set(ang.x, ang.y, v); } } this._rigidbody.velocity = vel; this._rigidbody.angularVelocity = ang; }
public override void ApplyConfiguration(IConfigurableConfiguration simulator_configuration) { var pos = this.transform.position; if (this._use_environments_space) { pos = this.ParentEnvironment.TransformPosition(this.transform.position); } var v = simulator_configuration.ConfigurableValue; if (this.TripleSpace._Decimal_Granularity >= 0) { v = (int)Math.Round(v, this.TripleSpace._Decimal_Granularity); } if (this.TripleSpace._Min_Values[0].CompareTo(this.TripleSpace._Max_Values[0]) != 0) { //TODO NOT IMPLEMENTED CORRECTLY VelocitySpace should not be index but should check all pairwise values, TripleSpace._Min_Values == TripleSpace._Max_Values if (v < this.TripleSpace._Min_Values[0] || v > this.TripleSpace._Max_Values[0]) { Debug.Log( $"Configurable does not accept input{v}, outside allowed range {this.TripleSpace._Min_Values[0]} to {this.TripleSpace._Max_Values[0]}"); return; // Do nothing } } #if NEODROID_DEBUG if (this.Debugging) { Debug.Log($"Applying {v} to {simulator_configuration.ConfigurableName} configurable"); } #endif if (this.RelativeToExistingValue) { if (simulator_configuration.ConfigurableName == this._x) { pos.Set(v - pos.x, pos.y, pos.z); } else if (simulator_configuration.ConfigurableName == this._y) { pos.Set(pos.x, v - pos.y, pos.z); } else if (simulator_configuration.ConfigurableName == this._z) { pos.Set(pos.x, pos.y, v - pos.z); } } else { if (simulator_configuration.ConfigurableName == this._x) { pos.Set(v, pos.y, pos.z); } else if (simulator_configuration.ConfigurableName == this._y) { pos.Set(pos.x, v, pos.z); } else if (simulator_configuration.ConfigurableName == this._z) { pos.Set(pos.x, pos.y, v); } } var inv_pos = pos; if (this._use_environments_space) { inv_pos = this.ParentEnvironment.InverseTransformPosition(inv_pos); } this.transform.position = inv_pos; }
public override void ApplyConfiguration(IConfigurableConfiguration configuration) { return; }
/// <summary> /// </summary> /// <param name="configuration"></param> public override void ApplyConfiguration(IConfigurableConfiguration configuration) { #if NEODROID_DEBUG if (this.Debugging) { DebugPrinting.ApplyPrint(this.Debugging, configuration, this.Identifier); } #endif if (this.use_shared) { foreach (var mat in this._renderer.sharedMaterials) { var c = mat.color; switch (configuration.ConfigurableName[configuration.ConfigurableName.Length - 1]) { case _r: c.r = configuration.ConfigurableValue; break; case _g: c.g = configuration.ConfigurableValue; break; case _b: c.b = configuration.ConfigurableValue; break; case _a: c.a = configuration.ConfigurableValue; break; } mat.color = c; } } else { foreach (var mat in this._renderer.materials) { var c = mat.color; switch (configuration.ConfigurableName[configuration.ConfigurableName.Length - 1]) { case _r: c.r = configuration.ConfigurableValue; break; case _g: c.g = configuration.ConfigurableValue; break; case _b: c.b = configuration.ConfigurableValue; break; case _a: c.a = configuration.ConfigurableValue; break; } mat.color = c; } } }