Example #1
0
        private void LoadMeshType8(BinaryReader br)
        {
            VertexCount = br.ReadUInt16();

            if (HasPosition())
            {
                for (int i = 0; i < VertexCount; i++)
                {
                    Vertex.Add(bh.ReadVector3f());
                }
            }

            if (HasNormal())
            {
                for (int i = 0; i < VertexCount; i++)
                {
                    Normal.Add(bh.ReadVector3f());
                }
            }

            if (HasColor())
            {
                for (int i = 0; i < VertexCount; i++)
                {
                    Color.Add(bh.ReadVector4f());
                }
            }

            if (HasSkin() & HasPosition())
            {
                for (int i = 0; i < VertexCount; i++)
                {
                    Vector4  weights = bh.ReadVector4f();
                    Vector4w ids     = bh.ReadVector4w();

                    for (int wi = 0; wi < 4; wi++)
                    {
                        if (weights[wi] != 0.0f)
                        {
                            BoneWeights.Add(new BoneWeight(i, BoneIndices[ids[wi]], weights[wi]));
                        }
                    }
                }
            }

            if (HasTangents())
            {
                for (int i = 0; i < VertexCount; i++)
                {
                    Tangent.Add(bh.ReadVector3f());
                }
            }

            for (int c = 0; c < 4; c++)
            {
                if (HasUVChannel(c))
                {
                    for (int i = 0; i < VertexCount; i++)
                    {
                        UV[c].Add(bh.ReadVector2f());
                    }
                }
            }

            FaceCount = br.ReadUInt16();

            for (int findex = 0; findex < FaceCount; findex++)
            {
                Face.Add(bh.ReadVector3w());
            }
        } // Load8