9 namespace droid.Runtime.Prototyping.Configurables {
13 [AddComponentMenu(ConfigurableComponentMenuPath._ComponentMenuPath
15 + ConfigurableComponentMenuPath._Postfix)]
18 [Header(
"Observation", order = 103)]
20 Quaternion _euler_rotation = Quaternion.identity;
22 [SerializeField]
bool _use_environments_space =
false;
43 _Min_Values = Vector3.zero,
44 _Max_Values =
new Vector3(360f, 360f, 360f)
47 public Space3 TripleSpace {
get {
return this._euler_space; } }
53 this._x = this.Identifier +
"X_";
54 this._y = this.Identifier +
"Y_";
55 this._z = this.Identifier +
"Z_";
56 this._w = this.Identifier +
"W_";
63 this.ParentEnvironment =
64 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this);
65 this.ParentEnvironment =
66 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._x);
67 this.ParentEnvironment =
68 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._y);
69 this.ParentEnvironment =
70 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._z);
71 this.ParentEnvironment =
72 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._w);
79 if (this.ParentEnvironment == null) {
83 this.ParentEnvironment.UnRegister(
this);
84 this.ParentEnvironment.UnRegister(
this, this._x);
85 this.ParentEnvironment.UnRegister(
this, this._y);
86 this.ParentEnvironment.UnRegister(
this, this._z);
87 this.ParentEnvironment.UnRegister(
this, this._w);
90 public override ISpace ConfigurableValueSpace {
get; }
96 if (this._use_environments_space && this.ParentEnvironment != null) {
97 this._euler_rotation = this.ParentEnvironment.TransformRotation(this.transform.rotation);
99 this._euler_rotation = this.transform.rotation;
104 var rot = this.transform.rotation;
105 if (this._use_environments_space) {
106 rot = this.ParentEnvironment.TransformRotation(this.transform.rotation);
110 if (this.TripleSpace.DecimalGranularity >= 0) {
111 v = (int)Math.Round(v,
this.TripleSpace.DecimalGranularity);
114 if (this.TripleSpace._Min_Values[0].CompareTo(
this.TripleSpace._Max_Values[0]) != 0) {
117 if (v < this.TripleSpace._Min_Values[0] || v >
this.TripleSpace._Max_Values[0]) {
118 Debug.Log($
"Configurable does not accept input {v}, outside allowed range {this.TripleSpace._Min_Values[0]} to {this.TripleSpace._Max_Values[0]}");
125 if (this.Debugging) {
126 Debug.Log($
"Applying {v} to {simulator_configuration.ConfigurableName} configurable");
129 var rote = rot.eulerAngles;
131 if (this.RelativeToExistingValue) {
133 rot.eulerAngles =
new Vector3(v - rote.x, rote.y, rote.z);
135 rot.eulerAngles =
new Vector3(rote.x, v - rote.y, rote.z);
137 rot.eulerAngles =
new Vector3(rote.x, rote.y, v - rote.z);
141 rot.eulerAngles =
new Vector3(v, rote.y, rote.z);
143 rot.eulerAngles =
new Vector3(rote.x, v, rote.z);
145 rot.eulerAngles =
new Vector3(rote.x, rote.y, v);
149 if (this._use_environments_space) {
150 rot = this.ParentEnvironment.InverseTransformRotation(rot);
153 this.transform.rotation = rot;
161 var sample = this.TripleSpace.Sample();
override void RegisterComponent()
override Configuration [] SampleConfigurations()
override void ApplyConfiguration(IConfigurableConfiguration simulator_configuration)
override void UnRegisterComponent()
override void UpdateCurrentConfiguration()