예제 #1
0
        private PmxRigidBody ReadPmxRigidBody()
        {
            var body = new PmxRigidBody();

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

            body.BoneIndex  = _reader.ReadVarLenIntAsInt32(BoneElementSize);
            body.GroupIndex = _reader.ReadByte(); // TODO: Signed? Unsigned?

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

            body.PassGroup = passGroup;

            body.BoundingBoxKind = (BoundingBoxKind)_reader.ReadByte();
            body.BoundingBoxSize = _reader.ReadVector3();
            body.Position        = _reader.ReadVector3();
            body.RotationAngles  = _reader.ReadVector3();
            body.Mass            = _reader.ReadSingle();
            body.PositionDamping = _reader.ReadSingle();
            body.RotationDamping = _reader.ReadSingle();
            body.Restitution     = _reader.ReadSingle();
            body.Friction        = _reader.ReadSingle();
            body.KineticMode     = (KineticMode)_reader.ReadByte();

            return(body);
        }
예제 #2
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);
        }