Exemplo n.º 1
0
        public static VertexConverter CreteConverter(VertexDeclarationTypes type)
        {
            switch (type)
            {
            case VertexDeclarationTypes.Position:
                return(new VertexConverterPosition());

            case VertexDeclarationTypes.Normal:
                return(new VertexConverterNormal());

            case VertexDeclarationTypes.Tangent:
                return(new VertexConverterTangent());

            case VertexDeclarationTypes.BiTangent:
                return(new VertexConverterBiTangent());

            case VertexDeclarationTypes.VertexColor:
                return(new VertexConverterColor());

            case VertexDeclarationTypes.TexturePosition2D:
                return(new VertexConverterTexturePosition2D());

            case VertexDeclarationTypes.MeshIndex:
                return(new VertexConverterMeshIndex());

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Reads the data-block from a stream.
 /// </summary>
 public override void Read(ResourceDataReader reader, params object[] parameters)
 {
     // read structure data
     this.Flags           = (VertexDeclarationFlags)reader.ReadUInt16();
     this.Unknown_2h      = reader.ReadUInt16();
     this.Stride          = reader.ReadUInt16();
     this.Unknown_6h      = reader.ReadByte();
     this.ComponentsCount = reader.ReadByte();
     this.Types           = (VertexDeclarationTypes)reader.ReadUInt64();
 }
Exemplo n.º 3
0
        public static InputElement[] GetLayout(VertexType componentsFlags, VertexDeclarationTypes componentsTypes = VertexDeclarationTypes.Types1)
        {
            List <InputElement> inputElements = new List <InputElement>();

            var types = (ulong)componentsTypes;
            var flags = (uint)componentsFlags;

            var offset = 0;

            for (int k = 0; k < 16; k++)
            {
                if (((flags >> k) & 0x1) == 1)
                {
                    var componentType = (VertexComponentType)((types >> k * 4) & 0x0000000F);

                    if (componentType == VertexComponentType.Nothing)
                    {
                        continue;                                               // should never hit this
                    }
                    var componentTypeSize = GetVertexComponentTypeSizeInBytes(componentType);
                    var format            = GetDXGIFormat(componentType);

                    if (componentTypeSize == 0 || format == Format.Unknown)
                    {
                        continue;
                    }

                    int index = inputElements.Where(e => e.SemanticName.Equals(Semantics[k])).Count();
                    inputElements.Add(new InputElement(Semantics[k], index, format, offset, 0));

                    offset += componentTypeSize;
                }
            }

            return(inputElements.ToArray());
        }