Exemple #1
0
        public void NormalizeBodyAnchorList()
        {
            if (BodyAnchorList.Count <= 0)
            {
                return;
            }
            List <int> list = new List <int>(BodyAnchorList.Count);
            Dictionary <string, int> dictionary = new Dictionary <string, int>(BodyAnchorList.Count);

            for (int i = 0; i < BodyAnchorList.Count; i++)
            {
                BodyAnchor bodyAnchor = BodyAnchorList[i];
                string     key        = bodyAnchor.Body + "_" + bodyAnchor.Vertex;
                if (!dictionary.ContainsKey(key))
                {
                    dictionary.Add(key, i);
                }
                else
                {
                    list.Add(i);
                }
            }
            if (list.Count > 0)
            {
                int[] array = CP.SortIndexForRemove(list.ToArray());
                for (int j = 0; j < array.Length; j++)
                {
                    BodyAnchorList.RemoveAt(array[j]);
                }
            }
        }
Exemple #2
0
 public BodyAnchor(BodyAnchor ac)
 {
     Body      = ac.Body;
     Vertex    = ac.Vertex;
     NodeIndex = ac.NodeIndex;
     IsNear    = ac.IsNear;
 }
Exemple #3
0
        private BodyAnchor ReadBodyAnchor()
        {
            var anchor = new BodyAnchor();

            anchor.BodyIndex   = _reader.ReadVarLenIntAsInt32(RigidBodyElementSize);
            anchor.VertexIndex = _reader.ReadVarLenIntAsInt32(VertexElementSize, true);
            anchor.IsNear      = _reader.ReadBoolean();

            return(anchor);
        }
Exemple #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);
        }
Exemple #5
0
 private void WriteBodyAnchor([NotNull] BodyAnchor anchor)
 {
     _writer.WriteInt32AsVarLenInt(anchor.BodyIndex, RigidBodyElementSize);
     _writer.WriteInt32AsVarLenInt(anchor.VertexIndex, VertexElementSize, true);
     _writer.Write(anchor.IsNear);
 }