Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
QuaternionTransformConfigurable.cs
Go to the documentation of this file.
2 using UnityEngine;
3 
4 namespace droid.Runtime.Prototyping.Configurables {
5  [AddComponentMenu(ConfigurableComponentMenuPath._ComponentMenuPath
6  + "QuaternionTransform"
7  + ConfigurableComponentMenuPath._Postfix)]
10  [Header("Specific", order = 102)]
11  [SerializeField]
12  Vector3 _position;
13 
14  [SerializeField] Quaternion _rotation;
15 
16  [SerializeField] string _pos_x = "pos_x";
17  [SerializeField] string _pos_y = "pos_y";
18  [SerializeField] string _pos_z = "pos_z";
19 
20  [SerializeField] string _rot_w = "row_w";
21  [SerializeField] string _rot_x = "rot_x";
22  [SerializeField] string _rot_y = "rot_y";
23  [SerializeField] string _rot_z = "rot_z";
24 
28  public override string PrototypingTypeName { get { return "QuaternionTransformConfigurable"; } }
29 
32  public Quaternion Rotation { get { return this._rotation; } }
33 
36  public Vector3 Position { get { return this._position; } }
37 
41  protected override void PreSetup() {
42  this._pos_x = this.Identifier + "pos_x";
43  this._pos_y = this.Identifier + "pos_y";
44  this._pos_z = this.Identifier + "pos_z";
45 
46  this._rot_x = this.Identifier + "rot_x";
47  this._rot_y = this.Identifier + "rot_y";
48  this._rot_z = this.Identifier + "rot_z";
49  this._rot_w = this.Identifier + "row_w";
50  }
51 
52  void Reset() {
53  var transform1 = this.transform;
54  transform1.position = this._position;
55  transform1.rotation = this._rotation;
56  }
57 
58  public override ISpace ConfigurableValueSpace { get; }
59 
60  public override void ApplyConfiguration(IConfigurableConfiguration obj) {
61  if (obj.ConfigurableName == this._pos_x) {
62  this._position.x = obj.ConfigurableValue;
63  } else if (obj.ConfigurableName == this._pos_y) {
64  this._position.y = obj.ConfigurableValue;
65  } else if (obj.ConfigurableName == this._pos_z) {
66  this._position.z = obj.ConfigurableValue;
67  } else if (obj.ConfigurableName == this._rot_x) {
68  this._rotation.x = obj.ConfigurableValue;
69  } else if (obj.ConfigurableName == this._rot_y) {
70  this._rotation.y = obj.ConfigurableValue;
71  } else if (obj.ConfigurableName == this._rot_z) {
72  this._rotation.z = obj.ConfigurableValue;
73  } else if (obj.ConfigurableName == this._rot_w) {
74  this._rotation.w = obj.ConfigurableValue;
75  }
76 
77  this.Reset();
78  }
79  }
80 }