Example #1
0
        private static object loadSkinnedMesh(
            ref DataInputStream @in,
            ref List <Object3D> objectList,
            ref List <Object3D> rootObjectList)
        {
            SkinnedMesh skinnedMesh = new SkinnedMesh();

            Loader.loadMesh((Mesh)skinnedMesh, ref @in, ref objectList, ref rootObjectList);
            Group reference1 = (Group)Loader.getReference(ref @in, ref objectList, ref rootObjectList);

            skinnedMesh.setSkeleton(reference1);
            bool flag = true;

            if (flag)
            {
                skinnedMesh.setLegacy(true);
            }
            int length = Loader.readIntLE(ref @in);

            if (flag)
            {
                for (int index = 0; index < length; ++index)
                {
                    Node reference2  = (Node)Loader.getReference(ref @in, ref objectList, ref rootObjectList);
                    int  firstVertex = Loader.readIntLE(ref @in);
                    int  numVertices = Loader.readIntLE(ref @in);
                    int  weight      = Loader.readIntLE(ref @in);
                    skinnedMesh.addTransform(reference2, weight, firstVertex, numVertices);
                }
            }
            else
            {
                Node[] bones = new Node[length];
                for (int index = 0; index < length; ++index)
                {
                    bones[index] = (Node)Loader.getReference(ref @in, ref objectList, ref rootObjectList);
                }
                skinnedMesh.setBones(bones);
            }
            return((object)skinnedMesh);
        }
Example #2
0
        protected virtual void duplicateToAddWeight(SkinnedMesh that, Node thisBone, Node thatBone)
        {
            if (this.m_weightsByBone.ContainsKey(thisBone))
            {
                int[] numArray = this.m_weightsByBone[thisBone];
                if (numArray != null)
                {
                    int length = numArray.Length;
                    for (int firstVertex = 0; firstVertex < length; ++firstVertex)
                    {
                        int weight = numArray[firstVertex];
                        if (weight != 0)
                        {
                            that.addTransform(thatBone, weight, firstVertex, 1);
                        }
                    }
                }
            }
            if ((object)thisBone.GetType() != (object)typeof(Group) && !thisBone.GetType().IsSubclassOf(typeof(Group)))
            {
                return;
            }
            Group group1 = (Group)thisBone;

            if (group1 == null)
            {
                return;
            }
            Group group2     = (Group)thatBone;
            int   childCount = group1.getChildCount();

            for (int index = 0; index < childCount; ++index)
            {
                this.duplicateToAddWeight(that, group1.getChild(index), group2.getChild(index));
            }
        }