コード例 #1
0
        private void CreateSkinnedObjectsFromModel()
        {
            blendInfo         = new FrameBlendInfo();
            skeleton          = new FrameSkeleton();
            skeletonHierarchy = new FrameSkeletonHierachy();

            int jointCount = model.SkeletonData.Joints.Length;

            skeleton.BoneNames    = new HashName[jointCount];
            skeleton.NumBones     = new int[4];
            skeleton.UnkLodData   = new int[1];
            skeleton.BoneLODUsage = new byte[jointCount];

            skeleton.NumBlendIDs   = jointCount;
            skeleton.NumUnkCount2  = jointCount;
            skeleton.UnkLodData[0] = jointCount;


            for (int i = 0; i < 4; i++)
            {
                skeleton.NumBones[i] = jointCount;
            }

            for (int i = 0; i < jointCount; i++)
            {
                HashName bone = new HashName();
                bone.Set(model.SkeletonData.Joints[i].Name);
                skeleton.BoneNames[i] = bone;

                if (model.Lods.Length == 1)
                {
                    skeleton.BoneLODUsage[i] = 1;
                }
            }

            skeletonHierarchy.ParentIndices    = new byte[jointCount];
            skeletonHierarchy.LastChildIndices = new byte[jointCount];
            skeletonHierarchy.UnkData          = new byte[jointCount];
            skeleton.JointTransforms           = new Matrix[jointCount];

            skeletonHierarchy.UnkData[0] = (byte)(jointCount + 1);

            for (int i = 0; i < jointCount; i++)
            {
                skeletonHierarchy.ParentIndices[i] = model.SkeletonData.Joints[i].ParentIndex;
                skeletonHierarchy.UnkData[i]       = (byte)(i != jointCount ? i : 0);
                skeleton.JointTransforms[i]        = model.SkeletonData.Joints[i].LocalTransform;
            }
        }
コード例 #2
0
 public Model(FrameObjectModel frameModel, IndexBuffer[] indexBuffers, VertexBuffer[] vertexBuffers)
 {
     this.frameModel    = frameModel;
     this.indexBuffers  = indexBuffers;
     this.vertexBuffers = vertexBuffers;
     frameGeometry      = frameModel.Geometry;
     frameMaterial      = frameModel.Material;
     blendInfo          = frameModel.BlendInfo;
     skeleton           = frameModel.Skeleton;
     skeletonHierarchy  = frameModel.SkeletonHierarchy;
     model           = new M2TStructure();
     model.IsSkinned = true;
     model.Name      = frameModel.Name.ToString();
     model.AOTexture = frameModel.OMTextureHash.String;
     model.BuildLods(frameModel, indexBuffers, vertexBuffers);
 }