3using System.Runtime.Serialization;
9 public class pb_Transform : System.IEquatable<pb_Transform>, ISerializable
14 private bool dirty =
true;
16 [SerializeField]
private Vector3 _position;
17 [SerializeField]
private Quaternion _rotation;
18 [SerializeField]
private Vector3 _scale;
19 [SerializeField]
private Vector3 _offset;
20 [SerializeField]
private Vector3 _rotoffset;
21 [SerializeField]
private Vector3 _leftoffset;
22 [SerializeField]
private Vector3 _leftrotoffset;
23 [SerializeField]
private bool _static;
24 [SerializeField]
private bool _restArea;
25 [SerializeField]
private bool _twoHand;
26 [SerializeField]
private bool _tool;
27 [SerializeField]
private bool _enabled;
29 private Matrix4x4 matrix;
31 public Vector3
position {
get {
return _position; }
set { dirty =
true; _position = value; } }
32 public Quaternion
rotation {
get {
return _rotation; }
set { dirty =
true; _rotation = value; } }
33 public Vector3
scale {
get {
return _scale; }
set { dirty =
true; _scale = value; } }
34 public Vector3
offset {
get {
return _offset; }
set { dirty =
true; _offset = value; } }
35 public Vector3
leftoffset {
get {
return _leftoffset; }
set { dirty =
true; _leftoffset = value; } }
36 public Vector3
rotoffset {
get {
return _rotoffset; }
set { dirty =
true; _rotoffset = value; } }
37 public Vector3
leftrotoffset {
get {
return _leftrotoffset; }
set { dirty =
true; _leftrotoffset = value; } }
38 public bool isRestArea {
get {
return _restArea; }
set { dirty =
true; _restArea = value; } }
40 public bool isStatic {
get {
return _static; }
set { dirty =
true; _static = value; } }
41 public bool isTool {
get {
return _tool; }
set { dirty =
true; _tool = value; } }
42 public bool isEnabled {
get {
return _enabled; }
set { dirty =
true; _enabled = value; } }
50 this.
scale = Vector3.one;
51 this.
offset = Vector3.zero;
55 this.matrix = Matrix4x4.identity;
69 this.
offset = Vector3.zero;
82 this.
rotation = transform.localRotation;
83 this.
scale = transform.localScale;
84 this.
offset = Vector3.zero;
91 this.
isEnabled = transform.gameObject.activeSelf;
102 this.
offset = Vector3.zero;
117 info.AddValue(
"position", (Vector3)_position, typeof(Vector3));
118 info.AddValue(
"rotation", (Quaternion)_rotation, typeof(Quaternion));
119 info.AddValue(
"scale", (Vector3)_scale, typeof(Vector3));
120 info.AddValue(
"offset", (Vector3)_offset, typeof(Vector3));
121 info.AddValue(
"rotoffset", (Vector3)_rotoffset, typeof(Vector3));
122 info.AddValue(
"leftoffset", (Vector3)_leftoffset, typeof(Vector3));
123 info.AddValue(
"leftrotoffset", (Vector3)_leftrotoffset, typeof(Vector3));
124 info.AddValue(
"isStatic", (
bool)_static, typeof(
bool));
125 info.AddValue(
"isRestArea", (
bool)_restArea, typeof(
bool));
126 info.AddValue(
"isTwoHandGrab", (
bool)_twoHand, typeof(
bool));
127 info.AddValue(
"isTool", (
bool)_tool, typeof(
bool));
128 info.AddValue(
"isEnabled", (
bool)_enabled, typeof(
bool));
133 this._position = (Vector3) info.GetValue(
"position", typeof(Vector3));
134 this._rotation = (Quaternion) info.GetValue(
"rotation", typeof(Quaternion));
135 this._scale = (Vector3) info.GetValue(
"scale", typeof(Vector3));
138 this._static = info.GetBoolean(
"isStatic");
146 this._tool = info.GetBoolean(
"isTool");
154 this._enabled = info.GetBoolean(
"isEnabled");
158 this._enabled =
true;
162 this._restArea = info.GetBoolean(
"isRestArea");
166 this._restArea =
false;
170 this._twoHand = info.GetBoolean(
"isTwoHandGrab");
174 this._twoHand =
false;
178 this._offset = (Vector3) info.GetValue(
"offset", typeof(Vector3));
182 this._offset = Vector3.zero;
186 this._rotoffset = (Vector3) info.GetValue(
"rotoffset", typeof(Vector3));
190 this._rotoffset = Vector3.zero;
194 this._leftoffset = (Vector3) info.GetValue(
"leftoffset", typeof(Vector3));
198 this._leftoffset = Vector3.zero;
202 this._leftrotoffset = (Vector3) info.GetValue(
"leftrotoffset", typeof(Vector3));
206 this._leftrotoffset = Vector3.zero;
215 this.
scale = trs.localScale;
216 this.
isEnabled = trs.gameObject.activeSelf;
220 bool Approx(Vector3 lhs, Vector3 rhs)
222 return Mathf.Abs(lhs.x - rhs.x) < Mathf.Epsilon &&
223 Mathf.Abs(lhs.y - rhs.y) < Mathf.Epsilon &&
224 Mathf.Abs(lhs.z - rhs.z) < Mathf.Epsilon;
227 bool Approx(Quaternion lhs, Quaternion rhs)
229 return Mathf.Abs(lhs.x - rhs.x) < Mathf.Epsilon &&
230 Mathf.Abs(lhs.y - rhs.y) < Mathf.Epsilon &&
231 Mathf.Abs(lhs.z - rhs.z) < Mathf.Epsilon &&
232 Mathf.Abs(lhs.w - rhs.w) < Mathf.Epsilon;
242 public override bool Equals(System.Object rhs)
298 t.
scale =
new Vector3( lhs.localScale.x * rhs.
scale.x,
299 lhs.localScale.y * rhs.
scale.y,
300 lhs.localScale.z * rhs.
scale.z);
307 return System.Object.ReferenceEquals(lhs, rhs) || lhs.
Equals(rhs);
312 return !(lhs == rhs);