/// 移動変位を設定します。 public void SetTranslation(Vector3 translation) { if (translation == new Vector3(0, 0, 0)) { RemoveTranslation(); return; } TPOCommand translation_command = FindTranslationCommand(); if (translation_command == null) { translation_command = new TPOCommand(); translation_command.type = TPOCommandType.Move; int idx = 0; TPOCommand scaling_or_rotation_command = LastScalingOrInverseScalingOrRotationCommand(); if (scaling_or_rotation_command != null) { idx = commands.IndexOf(scaling_or_rotation_command) + 1; } commands.Insert(idx, translation_command); } translation_command.x = translation.X; translation_command.y = translation.Y; translation_command.z = translation.Z; }
/// 回転角を設定します。 public void SetAngle(Vector3 angle) { if (angle == new Vector3(0, 0, 0)) { RemoveAngle(); return; } TPOCommand rotation_command = FindRotationCommand(); if (rotation_command == null) { rotation_command = new TPOCommand(); rotation_command.type = TPOCommandType.Rotate; int idx = 0; TPOCommand scaling_command = LastScalingOrInverseScalingCommand(); if (scaling_command != null) { idx = commands.IndexOf(scaling_command) + 1; } commands.Insert(idx, rotation_command); } rotation_command.x = Geometry.DegreeToRadian(angle.X); rotation_command.y = Geometry.DegreeToRadian(angle.Y); rotation_command.z = Geometry.DegreeToRadian(angle.Z); }
/// 縮小操作を削除します。 public void RemoveInverseScaling() { TPOCommand scaling_command = FindInverseScalingCommand(); if (scaling_command != null) { commands.Remove(scaling_command); } }
/// 回転操作を削除します。 public void RemoveAngle() { TPOCommand rotation_command = FindRotationCommand(); if (rotation_command != null) { commands.Remove(rotation_command); } }
/// 移動操作を削除します。 public void RemoveTranslation() { TPOCommand translation_command = FindTranslationCommand(); if (translation_command != null) { commands.Remove(translation_command); } }
/// <summary> /// 変形操作を追加します。 /// </summary> /// <param name="type"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> public void AddCommand(TPOCommandType type, float x, float y, float z) { TPOCommand command = new TPOCommand(); command.type = type; command.x = x; command.y = y; command.z = z; commands.Add(command); }
/// <summary> /// Z軸回転を行います。 /// </summary> /// <param name="angle"></param> public void RotateZ(float angle) { TPOCommand rotation_command = FindRotationCommand(); if (rotation_command != null) { rotation_command.z = angle; } else { AddCommand(TPOCommandType.Rotate, 0, 0, angle); } }
/// 移動変位を得ます。 public Vector3 GetTranslation() { TPOCommand translation_command = FindTranslationCommand(); if (translation_command != null) { return(translation_command.GetVector3()); } else { return(new Vector3(0, 0, 0)); } }
/// 縮小変位を設定します。 public void SetInverseScaling(Vector3 scaling) { TPOCommand scaling_command = FindInverseScalingCommand(); if (scaling_command == null) { scaling_command = new TPOCommand(); scaling_command.type = TPOCommandType.Scale0; commands.Insert(0, scaling_command); } scaling_command.x = scaling.X; scaling_command.y = scaling.Y; scaling_command.z = scaling.Z; }
/// 移動操作を得ます。 public TPOCommand FindTranslationCommand() { TPOCommand translation_command = null; foreach (TPOCommand command in commands) { switch (command.Type) { case TPOCommandType.Move: translation_command = command; break; } } return(translation_command); }
/// 回転操作を得ます。 public TPOCommand FindRotationCommand() { TPOCommand rotation_command = null; foreach (TPOCommand command in commands) { switch (command.Type) { case TPOCommandType.Rotate: rotation_command = command; break; } } return(rotation_command); }
/// 縮小操作を得ます。 private TPOCommand FindInverseScalingCommand() { TPOCommand scaling_command = null; foreach (TPOCommand command in commands) { switch (command.Type) { case TPOCommandType.Scale0: scaling_command = command; break; } } return(scaling_command); }
/// 拡大操作を得ます。 public TPOCommand FindScalingCommand() { TPOCommand scaling_command = null; foreach (TPOCommand command in commands) { switch (command.Type) { case TPOCommandType.Scale: case TPOCommandType.Scale1: scaling_command = command; break; } } return(scaling_command); }
/// 回転角を得ます。 public Vector3 GetAngle() { TPOCommand rotation_command = FindRotationCommand(); if (rotation_command != null) { Vector3 angle; angle.X = Geometry.RadianToDegree(rotation_command.X); angle.Y = Geometry.RadianToDegree(rotation_command.Y); angle.Z = Geometry.RadianToDegree(rotation_command.Z); return(angle); } else { return(new Vector3(0, 0, 0)); } }
/// 拡大操作を削除します。 public void RemoveScaling() { TPOCommand scaling_command = FindScalingCommand(); if (scaling_command != null) { commands.Remove(scaling_command); if (scaling_command.Type == TPOCommandType.Scale1) { foreach (TPONode child in children) { child.RemoveInverseScaling(); } } } }
/// 拡大変位を得ます。 public Vector3 GetScaling(out bool inv_scale_on_children) { inv_scale_on_children = false; TPOCommand scaling_command = FindScalingCommand(); if (scaling_command != null) { if (scaling_command.Type == TPOCommandType.Scale1) { inv_scale_on_children = true; } return(scaling_command.GetVector3()); } else { return(new Vector3(1, 1, 1)); } }
/// 拡大操作または縮小操作または回転操作を得ます。 public TPOCommand LastScalingOrInverseScalingOrRotationCommand() { TPOCommand scaling_or_rotation_command = null; foreach (TPOCommand command in commands) { switch (command.Type) { case TPOCommandType.Scale: case TPOCommandType.Scale1: case TPOCommandType.Scale0: case TPOCommandType.Rotate: scaling_or_rotation_command = command; break; } } return(scaling_or_rotation_command); }
/// 拡大変位を設定します。 public void SetScaling(Vector3 scaling, bool inv_scale_on_children) { if (scaling == new Vector3(1, 1, 1)) { RemoveScaling(); return; } TPOCommand scaling_command = FindScalingCommand(); if (scaling_command == null) { scaling_command = new TPOCommand(); scaling_command.type = TPOCommandType.Scale; commands.Insert(0, scaling_command); } if (inv_scale_on_children) { scaling_command.type = TPOCommandType.Scale1; } else { scaling_command.type = TPOCommandType.Scale; } scaling_command.x = scaling.X; scaling_command.y = scaling.Y; scaling_command.z = scaling.Z; if (inv_scale_on_children) { foreach (TPONode child in children) { child.SetInverseScaling(scaling); } } else { foreach (TPONode child in children) { child.RemoveInverseScaling(); } } }
/// <summary> /// 変形操作を追加します。 /// </summary> /// <param name="command"></param> public void AddCommand(TPOCommand command) { commands.Add(command); }
/// 回転角を設定します。 public void SetAngle(Vector3 angle) { if (angle == new Vector3(0, 0, 0)) { RemoveAngle(); return; } TPOCommand rotation_command = FindRotationCommand(); if (rotation_command == null) { rotation_command = new TPOCommand(); rotation_command.type = TPOCommandType.Rotate; int idx = 0; TPOCommand scaling_command = LastScalingOrInverseScalingCommand(); if (scaling_command != null) idx = commands.IndexOf(scaling_command) + 1; commands.Insert(idx, rotation_command); } rotation_command.x = MathUtil.DegreesToRadians(angle.X); rotation_command.y = MathUtil.DegreesToRadians(angle.Y); rotation_command.z = MathUtil.DegreesToRadians(angle.Z); }
/// 拡大変位を設定します。 public void SetScaling(Vector3 scaling, bool inv_scale_on_children) { if (scaling == new Vector3(1, 1, 1)) { RemoveScaling(); return; } TPOCommand scaling_command = FindScalingCommand(); if (scaling_command == null) { scaling_command = new TPOCommand(); scaling_command.type = TPOCommandType.Scale; commands.Insert(0, scaling_command); } if (inv_scale_on_children) scaling_command.type = TPOCommandType.Scale1; else scaling_command.type = TPOCommandType.Scale; scaling_command.x = scaling.X; scaling_command.y = scaling.Y; scaling_command.z = scaling.Z; if (inv_scale_on_children) { foreach (TPONode child in children) child.SetInverseScaling(scaling); } else { foreach (TPONode child in children) child.RemoveInverseScaling(); } }
/// 移動変位を設定します。 public void SetTranslation(Vector3 translation) { if (translation == new Vector3(0, 0, 0)) { RemoveTranslation(); return; } TPOCommand translation_command = FindTranslationCommand(); if (translation_command == null) { translation_command = new TPOCommand(); translation_command.type = TPOCommandType.Move; int idx = 0; TPOCommand scaling_or_rotation_command = LastScalingOrInverseScalingOrRotationCommand(); if (scaling_or_rotation_command != null) idx = commands.IndexOf(scaling_or_rotation_command) + 1; commands.Insert(idx, translation_command); } translation_command.x = translation.X; translation_command.y = translation.Y; translation_command.z = translation.Z; }