Пример #1
0
 public void FormatToString()
 {
     var elements = new[] {
         new VertexElement(VertexElementType.Position3D),
         new VertexElement(VertexElementType.TextureUV) };
     var format = new VertexFormat(elements);
     Assert.AreEqual("VertexFormat: Position3D*3, TextureUV*2, Stride=20", format.ToString());
 }
Пример #2
0
        public void FormatToString()
        {
            var elements = new[] {
                new VertexElement(VertexElementType.Position3D),
                new VertexElement(VertexElementType.TextureUV)
            };
            var format = new VertexFormat(elements);

            Assert.AreEqual("VertexFormat: Position3D*3, TextureUV*2, Stride=20", format.ToString());
        }
Пример #3
0
        public static VertexChannelFormat ToVertexChannelFormat(this VertexFormat _this)
        {
            switch (_this)
            {
            case VertexFormat.Float:
                return(VertexChannelFormat.Float);

            case VertexFormat.Float16:
                return(VertexChannelFormat.Float16);

            case VertexFormat.Color:
                return(VertexChannelFormat.Color);

            default:
                throw new Exception(_this.ToString());
            }
        }
Пример #4
0
        public static VertexFormatV2017 ToVertexFormatV2017(this VertexFormat _this)
        {
            switch (_this)
            {
            case VertexFormat.Float:
                return(VertexFormatV2017.Float);

            case VertexFormat.Float16:
                return(VertexFormatV2017.Float16);

            case VertexFormat.Byte:
                return(VertexFormatV2017.UNorm8);

            case VertexFormat.Int:
                return(VertexFormatV2017.UInt32);

            default:
                throw new Exception(_this.ToString());
            }
        }
Пример #5
0
 public void Read(BinaryReader data, VertexFormat format)
 {
     if (format == VertexFormat.Pixlit1UvNmap)
     {
         Pos     = data.ReadVector3f();
         Normal  = data.ReadCompressedVector4f();
         Tangent = data.ReadCompressedVector4f();
         Uvs     = new vector4f(data.ReadInt16(), data.ReadInt16(), 0.0f, 0.0f);
     }
     else if (format == VertexFormat.Pixlit3UvNmap)
     {
         Pos     = data.ReadVector3f();
         Normal  = data.ReadCompressedVector4f();
         Tangent = data.ReadCompressedVector4f();
         Uvs     = new vector4f(data.ReadInt16(), data.ReadInt16(), 0.0f, 0.0f);
         data.Skip(8); //Skip other UVs, .obj files only support 1 uv per object so for now need to ignore these. These are usually just 0,0 anyway
     }
     else
     {
         throw new Exception($"{format.ToString()} is an unsupported vertex format! Please show the maintainer of this tool this error and the related mesh file.");
     }
 }
Пример #6
0
        public static int GetSize(this VertexFormat _this, Version version)
        {
            switch (_this)
            {
            case VertexFormat.Float:
                return(4);

            case VertexFormat.Float16:
                return(2);

            case VertexFormat.Color:
                return(ShaderChannelExtensions.ShaderChannel5Relevant(version) ? 1 : 4);

            case VertexFormat.Byte:
                return(1);

            case VertexFormat.Int:
                return(4);

            default:
                throw new Exception(_this.ToString());
            }
        }
Пример #7
0
        public static int GetSize(this VertexFormat _this)
        {
            switch (_this)
            {
            case VertexFormat.Float:
                return(4);

            case VertexFormat.Float16:
                return(2);

            case VertexFormat.Color:
                return(4);

            case VertexFormat.Byte:
                return(1);

            case VertexFormat.Int:
                return(4);

            default:
                throw new Exception(_this.ToString());
            }
        }