Esempio n. 1
0
        private VertexPin ReadVertexPin()
        {
            var pin = new VertexPin();

            pin.VertexIndex = _reader.ReadVarLenIntAsInt32(VertexElementSize, true);

            return(pin);
        }
Esempio n. 2
0
 public void SortVertexPinList()
 {
     if (VertexPinList.Count > 0)
     {
         List <int> list = new List <int>(VertexPinList.Count);
         for (int i = 0; i < VertexPinList.Count; i++)
         {
             list.Add(VertexPinList[i].Vertex);
         }
         list.Sort();
         for (int j = 0; j < VertexPinList.Count; j++)
         {
             VertexPin vertexPin = VertexPinList[j];
             vertexPin.Vertex    = list[j];
             vertexPin.NodeIndex = -1;
             vertexPin.RefVertex = null;
         }
     }
 }
Esempio n. 3
0
        public void NormalizeVertexPinList()
        {
            if (VertexPinList.Count <= 0)
            {
                return;
            }
            SortVertexPinList();
            bool[] array = new bool[VertexPinList.Count];
            array[0] = false;
            for (int i = 1; i < VertexPinList.Count; i++)
            {
                VertexPin vertexPin  = VertexPinList[i - 1];
                VertexPin vertexPin2 = VertexPinList[i];
                if (vertexPin.Vertex == vertexPin2.Vertex)
                {
                    array[i] = true;
                }
            }
            Dictionary <int, int> dictionary = new Dictionary <int, int>();

            foreach (BodyAnchor bodyAnchor in BodyAnchorList)
            {
                dictionary.Add(bodyAnchor.Vertex, 0);
            }
            for (int j = 0; j < VertexPinList.Count; j++)
            {
                int vertex = VertexPinList[j].Vertex;
                if (dictionary.ContainsKey(vertex))
                {
                    array[j] = true;
                }
            }
            for (int num = array.Length - 1; num > 0; num--)
            {
                if (array[num])
                {
                    VertexPinList.RemoveAt(num);
                }
            }
        }
Esempio n. 4
0
        private PmxSoftBody ReadPmxSoftBody()
        {
            var body = new PmxSoftBody();

            body.Name        = ReadString() ?? string.Empty;
            body.NameEnglish = ReadString() ?? string.Empty;

            body.Shape         = (SoftBodyShape)_reader.ReadByte(); // TODO: Signed? Unsigned?
            body.MaterialIndex = _reader.ReadVarLenIntAsInt32(MaterialElementSize);
            body.GroupIndex    = _reader.ReadByte();                // TODO: Signed? Unsigned?

            var bits      = _reader.ReadUInt16();
            var passGroup = PmxBodyPassGroup.FromFlagBits(bits);

            body.PassGroup = passGroup;

            body.Flags = (SoftBodyFlags)_reader.ReadByte();
            body.BendingLinkDistance = _reader.ReadInt32();
            body.ClusterCount        = _reader.ReadInt32();
            body.TotalMass           = _reader.ReadSingle();
            body.Margin = _reader.ReadSingle();

            var config = body.Config;

            config.AeroModel  = _reader.ReadInt32();
            config.VCF        = _reader.ReadSingle();
            config.DP         = _reader.ReadSingle();
            config.DG         = _reader.ReadSingle();
            config.LF         = _reader.ReadSingle();
            config.PR         = _reader.ReadSingle();
            config.VC         = _reader.ReadSingle();
            config.DF         = _reader.ReadSingle();
            config.MT         = _reader.ReadSingle();
            config.CHR        = _reader.ReadSingle();
            config.KHR        = _reader.ReadSingle();
            config.SHR        = _reader.ReadSingle();
            config.AHR        = _reader.ReadSingle();
            config.SRHR_CL    = _reader.ReadSingle();
            config.SKHR_CL    = _reader.ReadSingle();
            config.SSHR_CL    = _reader.ReadSingle();
            config.SR_SPLT_CL = _reader.ReadSingle();
            config.SK_SPLT_CL = _reader.ReadSingle();
            config.SS_SPLT_CL = _reader.ReadSingle();
            config.V_IT       = _reader.ReadInt32();
            config.P_IT       = _reader.ReadInt32();
            config.D_IT       = _reader.ReadInt32();
            config.C_IT       = _reader.ReadInt32();

            var matCfg = body.MaterialConfig;

            matCfg.LST = _reader.ReadSingle();
            matCfg.AST = _reader.ReadSingle();
            matCfg.VST = _reader.ReadSingle();

            var bodyAnchorCount = _reader.ReadInt32();
            var bodyAnchors     = new BodyAnchor[bodyAnchorCount];

            for (var i = 0; i < bodyAnchorCount; ++i)
            {
                bodyAnchors[i] = ReadBodyAnchor();
            }

            body.BodyAnchors = bodyAnchors.Distinct().ToArray();

            var vertexPinCount = _reader.ReadInt32();
            var vertexPins     = new VertexPin[vertexPinCount];

            for (var i = 0; i < vertexPinCount; ++i)
            {
                vertexPins[i] = ReadVertexPin();
            }

            body.VertexPins = vertexPins.Distinct().ToArray();

            return(body);
        }
Esempio n. 5
0
 private void WriteVertexPin([NotNull] VertexPin pin)
 {
     _writer.WriteInt32AsVarLenInt(pin.VertexIndex, VertexElementSize, true);
 }
Esempio n. 6
0
 public VertexPin(VertexPin pin)
 {
     Vertex    = pin.Vertex;
     NodeIndex = pin.NodeIndex;
 }