Пример #1
0
        protected void ReadVertexBoneAssigment(XmlNode node, SubMesh subMesh)
        {
            VertexBoneAssignment assignment = new VertexBoneAssignment();

            // read the data from the file
            assignment.vertexIndex = int.Parse(node.Attributes["vertexindex"].Value);
            assignment.boneIndex   = ushort.Parse(node.Attributes["boneindex"].Value);;
            assignment.weight      = float.Parse(node.Attributes["weight"].Value);;

            // add the assignment to the mesh
            subMesh.AddBoneAssignment(assignment);
        }
Пример #2
0
        internal void RigidBindToBone(SubMesh subMesh, Bone bone)
        {
            m_Log.InfoFormat("Creating rigid binding from {0} to {1}", Id, bone.Name);

            for (int i = 0; i < subMesh.vertexData.vertexCount; ++i)
            {
                VertexBoneAssignment vba = new VertexBoneAssignment();

                vba.boneIndex = bone.Handle;

                vba.vertexIndex = i;

                vba.weight = 1.0f;

                subMesh.AddBoneAssignment(vba);
            }

            BoneAssignmentList = subMesh.BoneAssignmentList;
        }
Пример #3
0
 public static void CopyBoneAssignments(SubMesh dst, SubMesh src, Dictionary <uint, uint> vertexIdMap)
 {
     foreach (KeyValuePair <uint, uint> vertexMapping in vertexIdMap)
     {
         if (!src.BoneAssignmentList.ContainsKey((int)vertexMapping.Key))
         {
             continue;
         }
         List <VertexBoneAssignment> srcVbaList = src.BoneAssignmentList[(int)vertexMapping.Key];
         foreach (VertexBoneAssignment srcVba in srcVbaList)
         {
             Debug.Assert(srcVba.vertexIndex == (int)vertexMapping.Key);
             VertexBoneAssignment dstVba = new VertexBoneAssignment();
             dstVba.boneIndex   = srcVba.boneIndex;
             dstVba.vertexIndex = (int)vertexMapping.Value;
             dstVba.weight      = srcVba.weight;
             dst.AddBoneAssignment(dstVba);
         }
     }
 }
Пример #4
0
        internal void WeightedBindToBones(SubMesh subMesh, List <VertexBoneAssignment> vbaList)
        {
            // Some of these vertices needed to be split into multiple vertices.
            // Rebuild the vertex bone assignment list, to have entries for our
            // new vertex ids instead.
            foreach (VertexBoneAssignment item in vbaList)
            {
                List <int> subMeshVertexIds = GetVertexIds(item.vertexIndex);

                if (null != subMeshVertexIds)
                {
                    foreach (int subVertexId in subMeshVertexIds)
                    {
                        VertexBoneAssignment vba = new VertexBoneAssignment(item);

                        vba.vertexIndex = subVertexId;

                        subMesh.AddBoneAssignment(vba);
                    }
                }
            }

            BoneAssignmentList = subMesh.BoneAssignmentList;
        }