コード例 #1
0
ファイル: Vertex.cs プロジェクト: YeeB3Warned/Delegate
 public VertexValue(RealQuat Data, ValueType Type, string Usage, int UsageIndex)
 {
     this.Data = Data;
     this.Type = Type;
     //this.Stream = Stream;
     this.Usage      = Usage;
     this.UsageIndex = UsageIndex;
 }
コード例 #2
0
ファイル: Vertex.cs プロジェクト: YeeB3Warned/Delegate
        public VertexValue(XmlNode Node, EndianReader reader)
        {
            //Stream = Convert.ToInt32(Node.Attributes["stream"].Value);
            if (Convert.ToInt32(Node.Attributes["stream"].Value) > 0)
            {
                throw new NotSupportedException("Multi-streamed vertices not supported");
            }
            Type       = (ValueType)Enum.Parse(typeof(ValueType), Node.Attributes["type"].Value);
            Usage      = Node.Attributes["usage"].Value;
            UsageIndex = Convert.ToInt32(Node.Attributes["usageIndex"].Value);
            //if (Stream > 0) throw new NotSupportedException("Multi-streamed vertices not supported");

            #region read data
            switch (Type)
            {
            case ValueType.Float32_2:
                Data = new RealQuat(reader.ReadSingle(), reader.ReadSingle());
                break;

            case ValueType.Float32_3:
                Data = new RealQuat(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                break;

            case ValueType.Float32_4:
                Data = new RealQuat(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                break;

            case ValueType.Int8_N4:
                Data = new RealQuat((float)reader.ReadByte() / (float)0x7F, (float)reader.ReadByte() / (float)0x7F, (float)reader.ReadByte() / (float)0x7F, (float)reader.ReadByte() / (float)0x7F);
                break;

            case ValueType.UInt8_2:
                Data = new RealQuat(reader.ReadByte(), reader.ReadByte(), 0, 0);
                break;

            case ValueType.UInt8_3:
                Data = new RealQuat(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), 0);
                break;

            case ValueType.UInt8_4:
                //Data = new RealQuat(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte());
                Data = RealQuat.FromUByte4(reader.ReadUInt32());
                break;

            case ValueType.UInt8_N2:
                Data = new RealQuat((float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF, 0, 0);
                break;

            case ValueType.UInt8_N3:
                Data = new RealQuat((float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF, 0);
                break;

            case ValueType.UInt8_N4:
                //Data = new RealQuat((float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF);
                Data = RealQuat.FromUByteN4(reader.ReadUInt32());
                break;

            case ValueType.Int16_N3:
                Data = new RealQuat(((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, 0);
                break;

            case ValueType.Int16_N4:
                Data = new RealQuat(((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF);
                break;

            case ValueType.UInt16_2:
                Data = new RealQuat(reader.ReadUInt16(), reader.ReadUInt16());
                break;

            case ValueType.UInt16_4:
                Data = new RealQuat(reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadUInt16());
                break;

            case ValueType.UInt16_N2:
                Data = new RealQuat((float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF);
                break;

            case ValueType.UInt16_N4:
                Data = new RealQuat((float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF);
                break;

            case ValueType.DecN4:
                Data = RealQuat.FromDecN4(reader.ReadUInt32());
                break;

            case ValueType.UDecN4:
                Data = RealQuat.FromUDecN4(reader.ReadUInt32());
                break;

            case ValueType.DHenN3:
                Data = RealQuat.FromDHenN3(reader.ReadUInt32());
                break;

            case ValueType.UDHenN3:
                Data = RealQuat.FromUDHenN3(reader.ReadUInt32());
                break;

            case ValueType.HenDN3:
                Data = RealQuat.FromHenDN3(reader.ReadUInt32());
                break;

            case ValueType.UHenDN3:
                Data = RealQuat.FromUHenDN3(reader.ReadUInt32());
                break;

            case ValueType.Float16_2:
                Data = new RealQuat(Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()));
                break;

            case ValueType.Float16_4:
                Data = new RealQuat(Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()));
                break;

            case ValueType.D3DColour:
                reader.ReadUInt32();
                break;
            }
            #endregion
        }