Пример #1
0
 public string Comment;   //256 模型说明
 public void Read(BinaryReader reader)
 {
     PMDKey    = GlobleFuncs.GetString(reader, 3);
     Version   = reader.ReadInt32();
     ModelName = GlobleFuncs.GetString(reader, 20);
     Comment   = GlobleFuncs.GetString(reader, 256);
 }
Пример #2
0
 public Vector3 Position; // 骨骼位置
 public void Read(BinaryReader reader)
 {
     Name     = GlobleFuncs.GetString(reader, 20);
     Parent   = reader.ReadInt16();
     To       = reader.ReadInt16();
     Kind     = reader.ReadByte();
     IKNum    = reader.ReadInt16();
     Position = GlobleFuncs.ReadVector3(reader);
 }
Пример #3
0
 public byte    NonEdgeFlag; //无边标志(说明:当这个字节不为0时NonEdgeFlag=true)
 public void Read(BinaryReader reader)
 {
     Position    = GlobleFuncs.ReadVector3(reader);
     Normal      = GlobleFuncs.ReadVector3(reader);
     UV          = GlobleFuncs.ReadVector2(reader);
     Bone1       = reader.ReadUInt16();
     Bone2       = reader.ReadUInt16();
     Weight      = reader.ReadByte();
     NonEdgeFlag = reader.ReadByte();
 }
Пример #4
0
 public        SkinVertex[] VertexList; //=new SkinVertex[VertexListCount];  // 皮肤包含的所有顶点信息
 public void Read(BinaryReader reader)
 {
     Name            = GlobleFuncs.GetString(reader, 20);
     VertexListCount = reader.ReadUInt32();
     Category        = reader.ReadByte();
     VertexList      = new SkinVertex[VertexListCount];
     for (int i = 0; i < VertexListCount; i++)
     {
         VertexList[i].Read(reader);
     }
 }
Пример #5
0
 public void Read(BinaryReader reader)
 {
     Name            = GlobleFuncs.GetString(reader, 20);
     BodyA           = reader.ReadInt32();
     BodyB           = reader.ReadInt32();
     Position        = GlobleFuncs.ReadVector3(reader);
     Rotation        = GlobleFuncs.ReadVector3(reader);
     Limit_MoveLow   = GlobleFuncs.ReadVector3(reader);
     Limit_MoveHigh  = GlobleFuncs.ReadVector3(reader);
     Limit_AngleLow  = GlobleFuncs.ReadVector3(reader);
     Limit_AngleHigh = GlobleFuncs.ReadVector3(reader);
     SpConst_Move    = GlobleFuncs.ReadVector3(reader);
     SpConst_Rotate  = GlobleFuncs.ReadVector3(reader);
 }
Пример #6
0
 public void Read(BinaryReader reader)
 {
     Name             = GlobleFuncs.GetString(reader, 20);
     Bone             = reader.ReadInt16();
     Group            = reader.ReadByte();
     m_passGroupFlag  = reader.ReadUInt16();
     BoxType          = reader.ReadByte();
     BoxSize          = GlobleFuncs.ReadVector3(reader);
     PositionFromBone = GlobleFuncs.ReadVector3(reader);
     Rotation         = GlobleFuncs.ReadVector3(reader);
     Mass             = reader.ReadSingle();
     PositionDamping  = reader.ReadSingle();
     RotationDamping  = reader.ReadSingle();
     Restitution      = reader.ReadSingle();
     Friction         = reader.ReadSingle();
     Mode             = reader.ReadByte();
 }
Пример #7
0
 public string  Name;            // 包含了纹理路径,使用*分割(应该包含了混合模式吧,枚举:NONE、ADD、MUL)
 public void Read(BinaryReader reader)
 {
     Diffuse         = GlobleFuncs.ReadVector3(reader);
     Alpha           = reader.ReadSingle();
     Shininess       = reader.ReadSingle();
     Specular        = GlobleFuncs.ReadVector3(reader);
     Ambient         = GlobleFuncs.ReadVector3(reader);
     ToonNo          = reader.ReadByte();
     Edge            = reader.ReadByte();
     FaceVertexCount = reader.ReadInt32();
     Name            = GlobleFuncs.GetString(reader, 20);
     //暂时不处理sph纹理
     if (Name.EndsWith("sph"))
     {
         Name = "";
     }
     //包含了纹理路径,使用*分割(应该包含了混合模式吧,枚举:NONE、ADD、MUL)
     if (Name.EndsWith("spa"))
     {
         Name = Name.Split('*')[0];
     }
 }
Пример #8
0
        /// <summary>
        /// read vmd animation data
        /// </summary>
        /// <param name="reader"></param>
        public void Read(BinaryReader reader)
        {
            //1flagName
            vmdData.m_cFlagName = GlobleFuncs.GetString(reader, 30);
            //check version
            int version = int.Parse(vmdData.m_cFlagName.Substring(20));

            if (version != 2)
            {
                throw new InvalidOperationException("VMD版本号不为2.0");
            }
            //2motionName
            vmdData.m_cMotionName = GlobleFuncs.GetString(reader, 20);
            //3motionCount[TODO:ulong==int64]
            vmdData.m_iMotionCount = reader.ReadUInt32();

            //4 it's keyframes now
            vmdData.m_pBoneMotions = new BoneMotionData[vmdData.m_iMotionCount];
            //sorting the frame
            boneNames = new List <string>();

            for (uint i = 0; i < vmdData.m_iMotionCount; i++)
            {
                BoneMotionData boneData = vmdData.m_pBoneMotions[i];
                //fill the keyframe data
                boneData.m_cBoneName = GlobleFuncs.GetString(reader, 15);
                if (!boneNames.Contains(boneData.m_cBoneName))
                {
                    boneNames.Add(boneData.m_cBoneName);
                }
                boneData.m_uiFrameNum = reader.ReadUInt32();
                //position
                boneData.m_vPos.X = reader.ReadSingle();
                boneData.m_vPos.Y = reader.ReadSingle();
                boneData.m_vPos.Z = reader.ReadSingle();
                //quaternion
                boneData.m_qRot.X = reader.ReadSingle();
                boneData.m_qRot.Y = reader.ReadSingle();
                boneData.m_qRot.Z = reader.ReadSingle();
                boneData.m_qRot.W = reader.ReadSingle();
                //64 bytes
                boneData.m_bInterportation = new byte[64];
                boneData.m_bInterportation = reader.ReadBytes(64);
                //relative bone index
                //boneData.m_iBoneNum=reader.ReadInt16();

                vmdData.m_pBoneMotions[i] = boneData;
            }


            #region Keyframe in Bone Movement
            //arrange the bone keyframe
            keyframes = new List <Keyframe> [boneNames.Count];
            for (int i = 0; i < boneNames.Count; i++)
            {
                keyframes[i] = new List <Keyframe>();
            }
            for (uint i = 0; i < vmdData.m_iMotionCount; i++)
            {
                BoneMotionData boneData = vmdData.m_pBoneMotions[i];
                Keyframe       frame    = new Keyframe();
                frame.m_qRot       = boneData.m_qRot;
                frame.m_uiFrameNum = boneData.m_uiFrameNum;

                //get the max frame number to calculate time
                if (frame.m_uiFrameNum > maxFrameNumber)
                {
                    maxFrameNumber = frame.m_uiFrameNum;
                }
                frame.m_vPos        = boneData.m_vPos;
                frame.m_strBoneName = boneData.m_cBoneName;
                //add this frame
                keyframes[boneNames.IndexOf(boneData.m_cBoneName)].Add(frame);;
            }
            //sort the frames by its frameNumber
            for (int i = 0; i < keyframes.Length; i++)
            {
                keyframes[i].Sort();
            }
            #endregion


            //###################face motion###################
            #region everything for face motion
            uint nFaceMotionCount = reader.ReadUInt32();
            vmdData.m_pFaceMotions = new FaceMotionFrame[nFaceMotionCount];
            List <FaceMotionFrame> faceMotionFrames = new List <FaceMotionFrame>();
            for (int i = 0; i < nFaceMotionCount; i++)
            {
                FaceMotionFrame faceData = new FaceMotionFrame();
                //15char
                faceData.m_cName = GlobleFuncs.GetString(reader, 15);
                //index of frame
                faceData.m_bIndexOfFrame = reader.ReadUInt32();
                //weight of [base] vertex
                faceData.m_bWeight = reader.ReadSingle();

                faceMotionFrames.Add(faceData);
                //vmdData.m_pFaceMotions[i] = faceData;
            }
            faceMotionFrames.Sort();
            vmdData.m_pFaceMotions = faceMotionFrames.ToArray();
            #endregion
        }
Пример #9
0
 public void Read(BinaryReader reader)
 {
     Name = GlobleFuncs.GetString(reader, 50);
 }
Пример #10
0
 public Vector3 Offset; // 顶点位移
 public void Read(BinaryReader reader)
 {
     Index  = reader.ReadUInt32();
     Offset = GlobleFuncs.ReadVector3(reader);
 }