public FlipperHit(FlipperData data, Table.Table table, IItem item) : base(ItemType.Flipper, item) { data.UpdatePhysicsSettings(table); _mover = new FlipperMover(data, table, item); _data = data; _tableData = table.Data; UpdatePhysicsFromFlipper(); }
private bool _solState; // m_solState public FlipperMover(FlipperData data, FlipperState state, EventProxy events, Table.Table table) { _data = data; _state = state; _events = events; _tableData = table.Data; if (data.FlipperRadiusMin > 0 && data.FlipperRadiusMax > data.FlipperRadiusMin) { data.FlipperRadius = data.FlipperRadiusMax - (data.FlipperRadiusMax - data.FlipperRadiusMin) /* m_ptable->m_globalDifficulty*/; data.FlipperRadius = MathF.Max(data.FlipperRadius, data.BaseRadius - data.EndRadius + 0.05f); } else { data.FlipperRadius = data.FlipperRadiusMax; } EndRadius = MathF.Max(data.EndRadius, 0.01f); // radius of flipper end FlipperRadius = MathF.Max(data.FlipperRadius, 0.01f); // radius of flipper arc, center-to-center radius AngleStart = MathF.DegToRad(data.StartAngle); AngleEnd = MathF.DegToRad(data.EndAngle); if (AngleEnd == AngleStart) { // otherwise hangs forever in collisions/updates AngleEnd += 0.0001f; } var height = table.GetSurfaceHeight(data.Surface, data.Center.X, data.Center.Y); var baseRadius = MathF.Max(data.BaseRadius, 0.01f); HitCircleBase = new HitCircle(data.Center, baseRadius, height, height + data.Height, ItemType.Flipper); IsInContact = false; EnableRotateEvent = 0; AngleSpeed = 0; _direction = AngleEnd >= AngleStart; _solState = false; _curTorque = 0.0f; _state.Angle = AngleStart; _angularMomentum = 0; _angularAcceleration = 0; var ratio = (baseRadius - EndRadius) / FlipperRadius; // model inertia of flipper as that of rod of length flipr around its end var mass = _data.GetFlipperMass(_tableData); Inertia = (float)(1.0 / 3.0) * mass * (FlipperRadius * FlipperRadius); LastHitFace = false; // used to optimize hit face search order // F2 Norm, used in Green's transform, in FPM time search // = sinf(faceNormOffset) ZeroAngNorm.X = MathF.Sqrt(1.0f - ratio * ratio); // F1 norm, change sign of x component, i.E -zeroAngNorm.X // = -cosf(faceNormOffset) ZeroAngNorm.Y = -ratio; }
private uint _lastHitTime; // m_last_hittime public FlipperHit(FlipperData data, FlipperState state, EventProxy events, Table.Table table) { data.UpdatePhysicsSettings(table); _events = events; _mover = new FlipperMover(data, state, events, table); _data = data; _state = state; _tableData = table.Data; UpdatePhysicsFromFlipper(); }
public static PbrMaterial GetMaterial(string id, Table.Table table, FlipperData data) { switch (id) { case Base: return(new PbrMaterial(table.GetMaterial(data.Material), table.GetTexture(data.Image))); case Rubber: return(new PbrMaterial(table.GetMaterial(data.RubberMaterial))); } throw new ArgumentException($"Unknown flipper ID \"{id}\".", nameof(id)); }
private bool _solState; // m_solState public FlipperMover(FlipperData data, Table.Table table, IItem item) { var tableData = table.Data; if (data.FlipperRadiusMin > 0 && data.FlipperRadiusMax > data.FlipperRadiusMin) { data.FlipperRadius = data.FlipperRadiusMax - (data.FlipperRadiusMax - data.FlipperRadiusMin) /* m_ptable->m_globalDifficulty*/; data.FlipperRadius = MathF.Max(data.FlipperRadius, data.BaseRadius - data.EndRadius + 0.05f); } else { data.FlipperRadius = data.FlipperRadiusMax; } EndRadius = MathF.Max(data.EndRadius, 0.01f); // radius of flipper end FlipperRadius = MathF.Max(data.FlipperRadius, 0.01f); // radius of flipper arc, center-to-center radius AngleStart = MathF.DegToRad(data.StartAngle); AngleEnd = MathF.DegToRad(data.EndAngle); if (AngleEnd == AngleStart) { // otherwise hangs forever in collisions/updates AngleEnd += 0.0001f; } var height = table.GetSurfaceHeight(data.Surface, data.Center.X, data.Center.Y); var baseRadius = MathF.Max(data.BaseRadius, 0.01f); HitCircleBase = new HitCircle(data.Center, baseRadius, height, height + data.Height, ItemType.Flipper, item); EnableRotateEvent = 0; AngleSpeed = 0; _solState = false; var ratio = (baseRadius - EndRadius) / FlipperRadius; // model inertia of flipper as that of rod of length flipr around its end var mass = data.GetFlipperMass(tableData); Inertia = (float)(1.0 / 3.0) * mass * (FlipperRadius * FlipperRadius); // F2 Norm, used in Green's transform, in FPM time search // = sinf(faceNormOffset) ZeroAngNorm.X = MathF.Sqrt(1.0f - ratio * ratio); // F1 norm, change sign of x component, i.E -zeroAngNorm.X // = -cosf(faceNormOffset) ZeroAngNorm.Y = -ratio; }
public FlipperMeshGenerator(FlipperData data) { _data = data; }