コード例 #1
0
        public VertexArray getSkinIndices()
        {
            this.requireVertexBufferNotNull();
            VertexBuffer vertexBuffer = this.getVertexBuffer();
            VertexArray  skinIndices  = vertexBuffer.getSkinIndices();

            if (skinIndices == null)
            {
                if (this.m_skinIndices == null)
                {
                    int vertexCount = vertexBuffer.getVertexCount();
                    this.m_skinIndices = new VertexArray(vertexCount, 4, 1);
                    Node[]  boneArray = this.getBoneArray();
                    int[]   numArray1 = new int[4];
                    int[]   numArray2 = new int[4];
                    sbyte[] src       = new sbyte[4];
                    for (int firstVertex = 0; firstVertex < vertexCount; ++firstVertex)
                    {
                        for (int index = 0; index < 4; ++index)
                        {
                            numArray1[index] = 0;
                            numArray2[index] = 0;
                        }
                        for (int index1 = 0; index1 < boneArray.Length; ++index1)
                        {
                            int num = Math.Abs(this.getWeights(boneArray[index1])[firstVertex]);
                            if (num != 0)
                            {
                                for (int index2 = 0; index2 < 4; ++index2)
                                {
                                    if (num > numArray2[index2])
                                    {
                                        for (int index3 = 3; index3 > index2; --index3)
                                        {
                                            numArray1[index3] = numArray1[index3 - 1];
                                            numArray2[index3] = numArray2[index3 - 1];
                                        }
                                        numArray1[index2] = index1;
                                        numArray2[index2] = num;
                                        break;
                                    }
                                }
                            }
                        }
                        for (int index = 0; index < 4; ++index)
                        {
                            int num = numArray1[index];
                            if (num > (int)sbyte.MaxValue)
                            {
                                num -= 256;
                            }
                            src[index] = (sbyte)num;
                        }
                        this.m_skinIndices.set(firstVertex, 1, src);
                        this.m_vertexBuffer.finalVertexData[firstVertex].skinIndex.X = (float)src[0];
                        this.m_vertexBuffer.finalVertexData[firstVertex].skinIndex.Y = (float)src[1];
                        this.m_vertexBuffer.finalVertexData[firstVertex].skinIndex.Z = (float)src[2];
                        this.m_vertexBuffer.finalVertexData[firstVertex].skinIndex.W = 0.0f;
                    }
                }
                skinIndices = this.m_skinIndices;
            }
            return(skinIndices);
        }