private void InitSkinInfo(Assimp.Mesh mesh, AssimpSceneContainer container)
        {
            var          boneIDs     = new uvec4[mesh.VertexCount];
            var          boneWeights = new vec4[mesh.VertexCount];
            AllBoneInfos allBones    = container.GetAllBoneInfos();
            Dictionary <string, uint> nameIndexDict = allBones.nameIndexDict;

            for (int i = 0; i < mesh.BoneCount; i++)
            {
                Assimp.Bone bone      = mesh.Bones[i]; // bones that influence this mesh.
                uint        boneIndex = nameIndexDict[bone.Name];

                for (int j = 0; j < bone.VertexWeightCount; j++)
                {
                    Assimp.VertexWeight vertexWeight = bone.VertexWeights[j];
                    uint vertexID = vertexWeight.VertexID;
                    for (int t = 0; t < 4; t++)
                    {
                        if (boneWeights[vertexID][t] == 0.0f) // fill in x y z w.
                        {
                            boneIDs[vertexID][t]     = boneIndex;
                            boneWeights[vertexID][t] = vertexWeight.Weight;
                            break;
                        }
                    }
                }
            }
            this.boneIDs     = boneIDs;
            this.boneWeights = boneWeights;
        }
Example #2
0
        private void CreateSkeletonNode(Assimp.Scene aiScene, AssimpSceneContainer container)
        {
            var rootElement = this.scene.RootNode;
            var model       = new SkeletonModel(aiScene, container.GetAllBoneInfos());
            var node        = SkeletonNode.Create(model);

            this.skeletonNode = node;
            rootElement.Children.Add(node);
        }
Example #3
0
        private void CreateJointNode(Assimp.Scene aiScene, AssimpSceneContainer container)
        {
            var rootElement = this.scene.RootNode;
            var model       = new JointModel(aiScene, container.GetAllBoneInfos());
            var node        = JointNode.Create(model);

            node.DiffuseColor = Color.Red;
            this.jointNode    = node;
            rootElement.Children.Add(node);
        }