Exemplo n.º 1
0
        public Transform getBoneTransform(Node bone)
        {
            SkinnedMesh.requireBoneNotNull(bone);
            Dictionary <Node, Transform> restTransformByBone = this.m_atRestTransformByBone;

            return(this.m_atRestTransformByBone[bone]);
        }
Exemplo n.º 2
0
 public void setSkeleton(Group skeleton)
 {
     SkinnedMesh.requireBoneNotNull((Node)skeleton);
     this.requireVertexBufferNotNull();
     this.m_skeleton = skeleton;
     this.m_skeleton.setParent((Node)this);
     if (!this.isLegacy())
     {
         return;
     }
     this.addTransformWithoutWeightCheck((Node)this.m_skeleton, 0, 0, this.getVertexBuffer().getVertexCount());
 }
Exemplo n.º 3
0
        protected void addBone(Node bone)
        {
            SkinnedMesh.requireBoneNotNull(bone);
            this.getSkeleton();
            if (this.m_atRestTransformByBone == null)
            {
                this.m_atRestTransformByBone = new Dictionary <Node, Transform>();
            }
            if (this.m_bones == null)
            {
                this.m_bones = new List <Node>();
            }
            if (this.m_atRestTransformByBone.ContainsKey(bone))
            {
                return;
            }
            Transform transform = new Transform();

            this.getTransformTo(bone, ref transform);
            this.m_atRestTransformByBone.Add(bone, transform);
            this.m_bones.Add(bone);
        }
Exemplo n.º 4
0
        public int getBoneVertices(Node bone, ref int[] indices, ref float[] weights)
        {
            this.requireIsLegacy();
            SkinnedMesh.requireBoneNotNull(bone);
            this.requireVertexBufferNotNull();
            if (!this.m_weightsByBone.ContainsKey(bone))
            {
                return(0);
            }
            int[] numArray1 = this.m_weightsByBone[bone];
            if (numArray1 == null)
            {
                return(0);
            }
            bool flag        = indices.Length == 0;
            int  vertexCount = this.getVertexBuffer().getVertexCount();

            int[] numArray2     = numArray1;
            int[] summedWeights = this.m_summedWeights;
            int   index1        = 0;

            for (int index2 = 0; index2 < vertexCount; ++index2)
            {
                int num1 = numArray2[index2];
                if (num1 != 0)
                {
                    if (!flag)
                    {
                        indices[index1] = index2;
                        int num2 = summedWeights[index2];
                        weights[index1] = (float)num1 / (float)num2;
                    }
                    ++index1;
                }
            }
            return(index1);
        }
Exemplo n.º 5
0
        protected void addWeight(Node bone, int weight, int firstVertex, int numVertices)
        {
            SkinnedMesh.requireBoneNotNull(bone);
            this.requireVertexBufferNotNull();
            int vertexCount = this.getVertexBuffer().getVertexCount();

            SkinnedMesh.requireValidVertexRange(firstVertex, numVertices, vertexCount);
            if (this.m_weightsByBone == null)
            {
                this.m_weightsByBone = new Dictionary <Node, int[]>();
            }
            int[] numArray1 = this.m_weightsByBone.ContainsKey(bone) ? this.m_weightsByBone[bone] : new int[vertexCount];
            if (this.m_summedWeights.Length == 0)
            {
                this.m_summedWeights = new int[vertexCount];
            }
            int[] numArray2 = numArray1;
            int   num1      = firstVertex + numVertices;

            for (int index = firstVertex; index < num1; ++index)
            {
                int num2 = numArray2[index];
                this.m_summedWeights[index] -= Math.Abs(num2);
                int num3 = num2 + weight;
                this.m_summedWeights[index] += Math.Abs(num3);
                numArray2[index]             = num3;
            }
            if (this.m_weightsByBone.ContainsKey(bone))
            {
                this.m_weightsByBone[bone] = numArray1;
            }
            else
            {
                this.m_weightsByBone.Add(bone, numArray1);
            }
        }