diff --git a/Libs/BveTypes/BveTypes.csproj b/Libs/BveTypes/BveTypes.csproj index 321b6121..90fa6ca1 100644 --- a/Libs/BveTypes/BveTypes.csproj +++ b/Libs/BveTypes/BveTypes.csproj @@ -76,6 +76,7 @@ + @@ -103,7 +104,9 @@ + + diff --git a/Libs/BveTypes/ClassWrappers/Public/AirSpring.cs b/Libs/BveTypes/ClassWrappers/Public/AirSpring.cs new file mode 100644 index 00000000..539aa723 --- /dev/null +++ b/Libs/BveTypes/ClassWrappers/Public/AirSpring.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using FastMember; +using TypeWrapping; + +namespace BveTypes.ClassWrappers +{ + /// + /// 空気ばねのモデルを表します。 + /// + public class AirSpring : Spring + { + [InitializeClassWrapper] + private static void Initialize(BveTypeSet bveTypes) + { + ClassMemberSet members = bveTypes.GetClassInfoOf(); + } + + /// + /// オリジナル オブジェクトから クラスの新しいインスタンスを初期化します。 + /// + /// ラップするオリジナル オブジェクト。 + protected AirSpring(object src) : base(src) + { + } + + /// + /// オリジナル オブジェクトからラッパーのインスタンスを生成します。 + /// + /// ラップするオリジナル オブジェクト。 + /// オリジナル オブジェクトをラップした クラスのインスタンス。 + [CreateClassWrapperFromSource] + public static new AirSpring FromSource(object src) => src is null ? null : new AirSpring(src); + } +} diff --git a/Libs/BveTypes/ClassWrappers/Public/SixDof.cs b/Libs/BveTypes/ClassWrappers/Public/SixDof.cs new file mode 100644 index 00000000..247407f8 --- /dev/null +++ b/Libs/BveTypes/ClassWrappers/Public/SixDof.cs @@ -0,0 +1,139 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using FastMember; +using TypeWrapping; + +namespace BveTypes.ClassWrappers +{ + /// + /// 6DoF (3 次元における剛体の運動の自由度) を表します。 + /// + /// + /// このクラスのオリジナル型は構造体であることに注意してください。 + /// + public class SixDof : ClassWrapperBase + { + private static Type OriginalType; + + [InitializeClassWrapper] + private static void Initialize(BveTypeSet bveTypes) + { + ClassMemberSet members = bveTypes.GetClassInfoOf(); + + OriginalType = members.OriginalType; + + XField = members.GetSourceFieldOf(nameof(X)); + YField = members.GetSourceFieldOf(nameof(Y)); + ZField = members.GetSourceFieldOf(nameof(Z)); + RotationXField = members.GetSourceFieldOf(nameof(RotationX)); + RotationYField = members.GetSourceFieldOf(nameof(RotationY)); + RotationZField = members.GetSourceFieldOf(nameof(RotationZ)); + + AddMethod = members.GetSourceMethodOf(nameof(Add)); + MultiplyMethod = members.GetSourceMethodOf(nameof(Multiply)); + } + + /// + /// オリジナル オブジェクトから クラスの新しいインスタンスを初期化します。 + /// + /// ラップするオリジナル オブジェクト。 + protected SixDof(object src) : base(src) + { + } + + /// + /// オリジナル オブジェクトからラッパーのインスタンスを生成します。 + /// + /// ラップするオリジナル オブジェクト。 + /// オリジナル オブジェクトをラップした クラスのインスタンス。 + [CreateClassWrapperFromSource] + public static SixDof FromSource(object src) => src is null ? null : new SixDof(src); + + public static SixDof operator +(SixDof x, SixDof y) => Add(x, y); + public static SixDof operator *(double x, SixDof y) => Multiply(x, y); + + /// + /// 座標、回転を指定して クラスの新しいインスタンスを初期化します。 + /// + /// X 座標。 + /// Y 座標。 + /// Z 座標。 + /// X 軸まわりの回転 (ピッチ)。 + /// Y 軸まわりの回転 (ヨー)。 + /// Z 軸まわりの回転 (ロール)。 + public SixDof(double x, double y, double z, double rotationX, double rotationY, double rotationZ) + : this(Activator.CreateInstance(OriginalType, x, y, z, rotationX, rotationY, rotationZ)) + { + } + + private static FastField XField; + /// + /// X 座標を取得・設定します。 + /// + public double X + { + get => XField.GetValue(Src); + set => XField.SetValue(Src, value); + } + + private static FastField YField; + /// + /// Y 座標を取得・設定します。 + /// + public double Y + { + get => YField.GetValue(Src); + set => YField.SetValue(Src, value); + } + + private static FastField ZField; + /// + /// Z 座標を取得・設定します。 + /// + public double Z + { + get => ZField.GetValue(Src); + set => ZField.SetValue(Src, value); + } + + private static FastField RotationXField; + /// + /// X 軸まわりの回転 (ピッチ) を取得・設定します。 + /// + public double RotationX + { + get => RotationXField.GetValue(Src); + set => RotationXField.SetValue(Src, value); + } + + private static FastField RotationYField; + /// + /// Y 軸まわりの回転 (ヨー) を取得・設定します。 + /// + public double RotationY + { + get => RotationYField.GetValue(Src); + set => RotationYField.SetValue(Src, value); + } + + private static FastField RotationZField; + /// + /// Z 軸まわりの回転 (ロール) を取得・設定します。 + /// + public double RotationZ + { + get => RotationZField.GetValue(Src); + set => RotationZField.SetValue(Src, value); + } + + private static FastMethod AddMethod; + private static SixDof Add(SixDof x, SixDof y) => SixDof.FromSource(AddMethod.Invoke(null, new object[] { x.Src, y.Src })); + + private static FastMethod MultiplyMethod; + private static SixDof Multiply(double x, SixDof y) => SixDof.FromSource(MultiplyMethod.Invoke(null, new object[] { x, y.Src })); + } +} diff --git a/Libs/BveTypes/ClassWrappers/Public/Spring.cs b/Libs/BveTypes/ClassWrappers/Public/Spring.cs new file mode 100644 index 00000000..005b558f --- /dev/null +++ b/Libs/BveTypes/ClassWrappers/Public/Spring.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using FastMember; +using TypeWrapping; + +namespace BveTypes.ClassWrappers +{ + /// + /// ばねのモデルを表します。 + /// + public class Spring : ClassWrapperBase + { + [InitializeClassWrapper] + private static void Initialize(BveTypeSet bveTypes) + { + ClassMemberSet members = bveTypes.GetClassInfoOf(); + + UpperPositionGetMethod = members.GetSourcePropertyGetterOf(nameof(UpperPosition)); + UpperPositionSetMethod = members.GetSourcePropertySetterOf(nameof(UpperPosition)); + + UpperSpeedGetMethod = members.GetSourcePropertyGetterOf(nameof(UpperSpeed)); + UpperSpeedSetMethod = members.GetSourcePropertySetterOf(nameof(UpperSpeed)); + } + + /// + /// オリジナル オブジェクトから クラスの新しいインスタンスを初期化します。 + /// + /// ラップするオリジナル オブジェクト。 + protected Spring(object src) : base(src) + { + } + + /// + /// オリジナル オブジェクトからラッパーのインスタンスを生成します。 + /// + /// ラップするオリジナル オブジェクト。 + /// オリジナル オブジェクトをラップした クラスのインスタンス。 + [CreateClassWrapperFromSource] + public static Spring FromSource(object src) => src is null ? null : new Spring(src); + + private static FastMethod UpperPositionGetMethod; + private static FastMethod UpperPositionSetMethod; + /// + /// ばね上端の位置 [m] を取得・設定します。 + /// + public double UpperPosition + { + get => UpperPositionGetMethod.Invoke(Src, null); + set => UpperPositionSetMethod.Invoke(Src, new object[] { value }); + } + + private static FastMethod UpperSpeedGetMethod; + private static FastMethod UpperSpeedSetMethod; + /// + /// ばね上端の速度 [m/s] を取得・設定します。 + /// + public double UpperSpeed + { + get => UpperSpeedGetMethod.Invoke(Src, null); + set => UpperSpeedSetMethod.Invoke(Src, new object[] { value }); + } + } +} diff --git a/Libs/BveTypes/ClassWrappers/Public/VehicleVibrationManager.cs b/Libs/BveTypes/ClassWrappers/Public/VehicleVibrationManager.cs index 7e0e5ba9..5af84f74 100644 --- a/Libs/BveTypes/ClassWrappers/Public/VehicleVibrationManager.cs +++ b/Libs/BveTypes/ClassWrappers/Public/VehicleVibrationManager.cs @@ -7,6 +7,8 @@ using FastMember; using TypeWrapping; +using BveTypes.ClassWrappers.Extensions; + namespace BveTypes.ClassWrappers { /// @@ -19,7 +21,22 @@ private static void Initialize(BveTypeSet bveTypes) { ClassMemberSet members = bveTypes.GetClassInfoOf(); + CarBodyTransformGetMethod = members.GetSourcePropertyGetterOf(nameof(CarBodyTransform)); + + CarBodyDisplacementGetMethod = members.GetSourcePropertyGetterOf(nameof(CarBodyDisplacement)); + PositionerGetMethod = members.GetSourcePropertyGetterOf(nameof(Positioner)); + + SpringHeightGetMethod = members.GetSourcePropertyGetterOf(nameof(SpringHeight)); + SpringHeightSetMethod = members.GetSourcePropertySetterOf(nameof(SpringHeight)); + + ViewPointGetMethod = members.GetSourcePropertyGetterOf(nameof(ViewPoint)); + ViewPointSetMethod = members.GetSourcePropertySetterOf(nameof(ViewPoint)); + + VerticalSpringsField = members.GetSourceFieldOf(nameof(VerticalSprings)); + + TickMethod = members.GetSourceMethodOf(nameof(Tick)); + UpdateCarBodyTransformMethod = members.GetSourceMethodOf(nameof(UpdateCarBodyTransform)); } /// @@ -38,10 +55,69 @@ protected VehicleVibrationManager(object src) : base(src) [CreateClassWrapperFromSource] public static VehicleVibrationManager FromSource(object src) => src is null ? null : new VehicleVibrationManager(src); + private static FastMethod CarBodyTransformGetMethod; + /// + /// 車体中心から運転士を取得します。 + /// + public Transform CarBodyTransform => Transform.FromSource(CarBodyTransformGetMethod.Invoke(Src, null)); + + private static FastMethod CarBodyDisplacementGetMethod; + /// + /// 車体中心から運転士を取得します。 + /// + public SixDof CarBodyDisplacement => SixDof.FromSource(CarBodyDisplacementGetMethod.Invoke(Src, null)); + private static FastMethod PositionerGetMethod; /// /// 自列車をマップ上に配置するための機能を提供する を取得します。 /// public VehiclePositioner Positioner => VehiclePositioner.FromSource(PositionerGetMethod.Invoke(Src, null)); + + private static FastMethod SpringHeightGetMethod; + private static FastMethod SpringHeightSetMethod; + /// + /// を取得・設定します。 + /// + public double SpringHeight + { + get => SpringHeightGetMethod.Invoke(Src, null); + set => SpringHeightSetMethod.Invoke(Src, new object[] { value }); + } + + private static FastMethod ViewPointGetMethod; + private static FastMethod ViewPointSetMethod; + /// + /// を取得・設定します。 + /// + public SixDof ViewPoint + { + get => SixDof.FromSource(ViewPointGetMethod.Invoke(Src, null)); + set => ViewPointSetMethod.Invoke(Src, new object[] { value.Src }); + } + + private static FastField VerticalSpringsField; + /// + /// 空気ばねの縦 (Y) 方向モデルを取得・設定します。 + /// + /// + /// 右前、左前、右後、左後の順番で格納されています。 + /// + public WrappedArray VerticalSprings + { + get => WrappedArray.FromSource(VerticalSpringsField.GetValue(Src)); + set => VerticalSpringsField.SetValue(Src, value.Src); + } + + private static FastMethod TickMethod; + /// + /// 毎フレーム呼び出されます。 + /// + public void Tick(double elapsedSeconds) => TickMethod.Invoke(Src, new object[] { elapsedSeconds }); + + private static FastMethod UpdateCarBodyTransformMethod; + /// + /// 車両 + /// + public void UpdateCarBodyTransform() => UpdateCarBodyTransformMethod.Invoke(Src, null); } } diff --git a/Libs/BveTypes/WrapTypes/5.8.7554.391.xml b/Libs/BveTypes/WrapTypes/5.8.7554.391.xml index 73998a4b..bc5096e8 100644 --- a/Libs/BveTypes/WrapTypes/5.8.7554.391.xml +++ b/Libs/BveTypes/WrapTypes/5.8.7554.391.xml @@ -46,6 +46,9 @@ + + + @@ -804,6 +807,18 @@ + + + + + + + + + + + + @@ -821,6 +836,17 @@ + + + + + + + + + + + @@ -1261,8 +1287,27 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Libs/BveTypes/WrapTypes/6.0.7554.619.xml b/Libs/BveTypes/WrapTypes/6.0.7554.619.xml index 73998a4b..bc5096e8 100644 --- a/Libs/BveTypes/WrapTypes/6.0.7554.619.xml +++ b/Libs/BveTypes/WrapTypes/6.0.7554.619.xml @@ -46,6 +46,9 @@ + + + @@ -804,6 +807,18 @@ + + + + + + + + + + + + @@ -821,6 +836,17 @@ + + + + + + + + + + + @@ -1261,8 +1287,27 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file