9 namespace droid.Runtime.Prototyping.Configurables {
13 [AddComponentMenu(ConfigurableComponentMenuPath._ComponentMenuPath
15 + ConfigurableComponentMenuPath._Postfix)]
18 [Header(
"Observation", order = 103)]
20 Vector3 _position = Vector3.zero;
22 [SerializeField]
bool _use_environments_space =
false;
41 public Vector3 ObservationValue {
get {
return this._position; } }
46 public Space3 TripleSpace {
get {
return this._triple_space; } }
52 this._x = this.Identifier +
"X_";
53 this._y = this.Identifier +
"Y_";
54 this._z = this.Identifier +
"Z_";
61 this.ParentEnvironment =
62 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this);
63 this.ParentEnvironment =
64 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._x);
65 this.ParentEnvironment =
66 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._y);
67 this.ParentEnvironment =
68 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._z);
75 if (this.ParentEnvironment == null) {
79 this.ParentEnvironment.UnRegister(
this);
80 this.ParentEnvironment.UnRegister(
this, this._x);
81 this.ParentEnvironment.UnRegister(
this, this._y);
82 this.ParentEnvironment.UnRegister(
this, this._z);
85 public override ISpace ConfigurableValueSpace {
get; }
91 if (this._use_environments_space) {
92 this._position = this.ParentEnvironment.TransformPoint(this.transform.position);
94 this._position = this.transform.position;
103 var pos = this.transform.position;
104 if (this._use_environments_space) {
105 pos = this.ParentEnvironment.TransformPoint(this.transform.position);
109 if (this.TripleSpace.DecimalGranularity >= 0) {
110 v = (int)Math.Round(v,
this.TripleSpace.DecimalGranularity);
113 if (this.TripleSpace._Min_Values[0].CompareTo(
this.TripleSpace._Max_Values[0]) != 0) {
115 if (v < this.TripleSpace._Min_Values[0] || v >
this.TripleSpace._Max_Values[0]) {
116 Debug.Log($
"Configurable does not accept input{v}, outside allowed range {this.TripleSpace._Min_Values[0]} to {this.TripleSpace._Max_Values[0]}");
122 if (this.Debugging) {
123 Debug.Log($
"Applying {v} to {simulator_configuration.ConfigurableName} configurable");
127 if (this.RelativeToExistingValue) {
129 pos.Set(v - pos.x, pos.y, pos.z);
131 pos.Set(pos.x, v - pos.y, pos.z);
133 pos.Set(pos.x, pos.y, v - pos.z);
137 pos.Set(v, pos.y, pos.z);
139 pos.Set(pos.x, v, pos.z);
141 pos.Set(pos.x, pos.y, v);
146 if (this._use_environments_space) {
147 inv_pos = this.ParentEnvironment.InverseTransformPoint(inv_pos);
150 this.transform.position = inv_pos;
154 var sample = this.TripleSpace.Sample();
155 var r =
Random.Range(0, 3);
167 throw new IndexOutOfRangeException();
override void UpdateCurrentConfiguration()
override Configuration [] SampleConfigurations()
override void UnRegisterComponent()
override void ApplyConfiguration(IConfigurableConfiguration simulator_configuration)
override void RegisterComponent()