public PlungerHit(PlungerData data, float zHeight) : base(ItemType.Plunger)
        {
            _data    = data;
            _zHeight = zHeight;
            _x       = _data.Center.X - _data.Width;
            _y       = _data.Center.Y + _data.Height;
            _x2      = _data.Center.X + _data.Width;

            FrameTop    = data.Center.Y - data.Stroke;
            FrameBottom = data.Center.Y;
            FrameLen    = FrameBottom - FrameTop;
            RestPos     = data.ParkPosition;
            Position    = FrameTop + RestPos * FrameLen;

            // static
            LineSegBase  = new LineSeg(new Vertex2D(_x, _y), new Vertex2D(_x2, _y), zHeight, zHeight + Plunger.PlungerHeight, ItemType.Plunger);
            JointBase[0] = new HitLineZ(new Vertex2D(_x, _y), zHeight, zHeight + Plunger.PlungerHeight, ItemType.Plunger);
            JointBase[1] = new HitLineZ(new Vertex2D(_x2, _y), zHeight, zHeight + Plunger.PlungerHeight, ItemType.Plunger);

            // dynamic
            LineSegSide[0] = new LineSeg(new Vertex2D(_x + 0.0001f, Position), new Vertex2D(_x, _y), zHeight, zHeight + Plunger.PlungerHeight, ItemType.Plunger);
            LineSegSide[1] = new LineSeg(new Vertex2D(_x2, _y), new Vertex2D(_x2 + 0.0001f, Position), zHeight, zHeight + Plunger.PlungerHeight, ItemType.Plunger);
            LineSegEnd     = new LineSeg(new Vertex2D(_x2, Position), new Vertex2D(_x, Position), zHeight, zHeight + Plunger.PlungerHeight, ItemType.Plunger);
            JointEnd[0]    = new HitLineZ(new Vertex2D(_x, Position), zHeight, zHeight + Plunger.PlungerHeight, ItemType.Plunger);
            JointEnd[1]    = new HitLineZ(new Vertex2D(_x2, Position), zHeight, zHeight + Plunger.PlungerHeight, ItemType.Plunger);
        }
Exemplo n.º 2
0
        public static PlungerDesc GetCustom(PlungerData data, float beginY, float springMinSpacing,
                                            out float rody, out float springGauge, out float springRadius,
                                            out float springLoops, out float springEndLoops)
        {
            // Several of the entries are fixed:
            // shaft x 2 (top, bottom)
            // ring x 6 (inner top, outer top x 2, outer bottom x 2, inner bottom)
            // ring gap x 2 (top, bottom)
            // tip bottom inner x 1
            // first entry in custom tip list (there's always at least one;
            //    even if it's blank, we read the empty entry as "0,0" )
            var numCoords = 2 + 6 + 2 + 1 + 1;

            // Split the tip list.
            // Entries are separated by semicolons.
            var tipShapes = string.IsNullOrEmpty(data.TipShape)
                                ? new string[0]
                                : data.TipShape.Split(';');
            var numTips = tipShapes.Length;

            numCoords += numTips - 1;

            // allocate the descriptor and the coordinate array
            var desc = new PlungerDesc(new PlungerCoord[numCoords]);

            // figure the tip lathe descriptor from the shape point list
            //var c = customDesc.c;
            float tipLen = 0;
            int   i;

            for (i = 0; i < tipShapes.Length; i++)
            {
                // Parse the entry: "yOffset, diam".  yOffset is the
                // offset (in table distance units) from the previous
                // point.  "diam" is the diameter (relative to the
                // nominal width of the plunger, as given by the width
                // property) of the tip at this point.  1.0 means that
                // the diameter is the same as the nominal width; 0.5
                // is half the width.
                var     tipShape = tipShapes[i];
                var     ts       = tipShape.Trim().Split(' ');
                ref var c        = ref desc.c[i];

                try {
                    c.y = int.Parse(ts[0], CultureInfo.InvariantCulture);
                } catch (FormatException) {
                    c.y = 0;
                }

                try {
                    var v = ts.Length > 1 ? ts[1] : "0.0";
                    c.r = float.Parse(v.StartsWith(".") ? "0" + v : v, CultureInfo.InvariantCulture) * 0.5f;
                } catch (FormatException) {
                    c.r = 0;
                }

                // each entry has to have a higher y value than the last
                if (c.y < tipLen)
                {
                    c.y = tipLen;
                }

                // update the tip length so far
                tipLen = c.y;
            }
Exemplo n.º 3
0
 public PlungerMeshGenerator(PlungerData data)
 {
     _data = data;
     Init(null);
 }