ReadFloat() public method

public ReadFloat ( ) : float
return float
Esempio n. 1
0
        public override void Read(ByteArray stream)
        {
            base.Read(stream);

            uint i, j, len = numVertex * 3;

            // NORMAL
            if ((attrib & 4) != 0)
            {
                normal = new float[len];

                i = 0;
                while (i < len)
                    normal[i++] = stream.ReadFloat();
            }

            // TANGENT
            if ((attrib & 8) != 0)
            {
                tangent = new float[len];

                i = 0;
                while (i < len)
                    tangent[i++] = stream.ReadFloat();

                // UVS
                if ((attrib & 32) != 0)
                {
                    int uvCount = stream.ReadUByte();
                    uint uvLen = numVertex * 2;

                    uv = new float[uvCount][];

                    i = 0;
                    while (i < uvLen)
                    {
                        // UV_VERTEX
                        uv[i++] = new float[uvLen];

                        j = 0;
                        while (j < numVertex)
                            uv[i][j++] = stream.ReadFloat();
                    }
                }
            }

            // JOINT_INDEXES | WEIGHTS
            if ((attrib & 64) != 0)
            {
                jointPerVertex = (uint)stream.ReadUByte();

                uint jntLen = numVertex * jointPerVertex;

                joint = new uint[jntLen];
                weight = new float[jntLen];

                i = 0;
                while (i < jntLen)
                    joint[i++] = (uint)stream.ReadUInt16();

                i = 0;
                while (i < jntLen)
                    weight[i++] = stream.ReadFloat();
            }

            // VERTEX_COLOR
            if ((attrib & 128) != 0)
            {
                int colorLen = stream.ReadUByte();

                color = new float[colorLen][];

                for (i = 0; i < colorLen; i++)
                {
                    color[i] = new float[len];

                    j = 0;
                    while (j < len)
                        color[j++][j] = (float)stream.ReadUByte() / 255.0f;
                }
            }

            // VERTEX
            vertex = new float[len];

            i = 0;
            while (i < len)
                vertex[i++] = stream.ReadFloat();

            int idxCount = stream.ReadUByte();

            indexes = new uint[idxCount][];

            // INDEXES
            if (isBig)
            {
                for (i = 0; i < idxCount; i++)
                {
                    uint triLen = stream.ReadUInt32() * 3;

                    indexes[i] = new uint[triLen];

                    j = 0;
                    while (j < triLen)
                        indexes[i][j++] = stream.ReadUInt32();
                }
            }
            else
            {
                for (i = 0; i < idxCount; i++)
                {
                    uint triLen = (uint)stream.ReadUInt16() * 3;

                    indexes[i] = new uint[triLen];

                    j = 0;
                    while (j < triLen)
                        indexes[i][j++] = (uint)stream.ReadUInt16();
                }
            }
        }