Beispiel #1
0
        protected virtual object ReadVariableValue(VertexDefinition.VariableTypeEnum variabletype)
        {
            switch (variabletype)
            {
            case VertexDefinition.VariableTypeEnum.vec2float:
                var vector2_1 = new Vector2()
                {
                    X = BigEndianBitConverter.ToSingle(fileData, iPos),
                    Y = BigEndianBitConverter.ToSingle(fileData, iPos + 4)
                };
                iPos += 8;
                return((object)vector2_1);

            case VertexDefinition.VariableTypeEnum.vec3float:
                var vector3_1 = new Vector3();
                vector3_1.X = BigEndianBitConverter.ToSingle(fileData, iPos);
                vector3_1.Y = BigEndianBitConverter.ToSingle(fileData, iPos + 4);
                vector3_1.Z = BigEndianBitConverter.ToSingle(fileData, iPos + 8);
                var vector3_2 = vector3_1;
                iPos += 12;
                return((object)vector3_2);

            case VertexDefinition.VariableTypeEnum.vec4float:
                var vector4_1 = new Vector4();
                vector4_1.X = BigEndianBitConverter.ToSingle(fileData, iPos);
                vector4_1.Y = BigEndianBitConverter.ToSingle(fileData, iPos + 4);
                vector4_1.Z = BigEndianBitConverter.ToSingle(fileData, iPos + 8);
                vector4_1.W = (float)BigEndianBitConverter.ToHalf(fileData, iPos + 12);
                var vector4_2 = vector4_1;
                iPos += 16;
                return((object)vector4_2);

            case VertexDefinition.VariableTypeEnum.vec2half:
                var vector2_2 = new Vector2()
                {
                    X = (float)BigEndianBitConverter.ToHalf(fileData, iPos),
                    Y = (float)BigEndianBitConverter.ToHalf(fileData, iPos + 2)
                };
                iPos += 4;
                return((object)vector2_2);

            case VertexDefinition.VariableTypeEnum.vec4half:
                var vector4_3 = new Vector4();
                vector4_3.X = (float)BigEndianBitConverter.ToHalf(fileData, iPos);
                vector4_3.Y = (float)BigEndianBitConverter.ToHalf(fileData, iPos + 2);
                vector4_3.Z = (float)BigEndianBitConverter.ToHalf(fileData, iPos + 4);
                vector4_3.W = (float)BigEndianBitConverter.ToHalf(fileData, iPos + 6);
                var vector4_4 = vector4_3;
                iPos += 8;
                return((object)vector4_4);

            case VertexDefinition.VariableTypeEnum.vec4char:
                iPos += 4;
                return((object)1);

            case VertexDefinition.VariableTypeEnum.vec4mini:
                var vector4_5 = new Vector4();
                vector4_5.X = LookUp[(int)fileData[iPos]];
                vector4_5.Y = LookUp[(int)fileData[iPos + 1]];
                vector4_5.Z = LookUp[(int)fileData[iPos + 2]];
                vector4_5.W = LookUp[(int)fileData[iPos + 3]];
                var vector4_6 = vector4_5;
                iPos += 4;
                return((object)vector4_6);

            case VertexDefinition.VariableTypeEnum.color4char:
                var color4 = new Color4()
                {
                    R = (int)fileData[iPos],
                    G = (int)fileData[iPos + 1],
                    B = (int)fileData[iPos + 2],
                    A = (int)fileData[iPos + 3]
                };
                iPos += 4;
                return((object)color4);

            default:
                throw new NotImplementedException(variabletype.ToString());
            }
        }