Пример #1
0
            public AddVDataArguments(OpsParsedStatement statement)
            {
                OpsParsedArgument typeArg = statement.FindArgument("type");

                if (typeArg == null)
                {
                    typeArg = statement.FindArgument("");
                    if (typeArg == null)
                    {
                        throw new OpsException("'type' argument argument");
                    }
                }
                type = MeshDeclarationHelper.DecodeType(typeArg.Value);

                OpsParsedArgument usageArg = statement.FindArgument("usage");

                if (usageArg != null)
                {
                    usage = MeshDeclarationHelper.DecodeUsage(usageArg.Value);
                }

                OpsParsedArgument usageIdxArg = statement.FindArgument("usageIdx");

                if (usageIdxArg != null)
                {
                    usageIdx = int.Parse(usageIdxArg.Value);
                }
            }
Пример #2
0
 public StreamDataType(short id, int numValues, int dataSize, DeclarationType declarationType, DeclarationUsage declarationUsage, byte usageIndex)
 {
     this.Id = id;
     this.NumValues = numValues;
     this.DataSize = dataSize;
     this.DeclarationType = declarationType;
     this.DeclarationUsage = declarationUsage;
     this.UsageIndex = usageIndex;
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VertexElement"/> struct.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="type">The type.</param>
 /// <param name="method">The method.</param>
 /// <param name="usage">The usage.</param>
 /// <param name="usageIndex">Index of the usage.</param>
 public VertexElement(short stream, short offset, DeclarationType type, DeclarationMethod method, DeclarationUsage usage, byte usageIndex = 0)
 {
     Stream     = stream;
     Offset     = offset;
     Type       = type;
     Method     = method;
     Usage      = usage;
     UsageIndex = usageIndex;
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VertexElement"/> struct.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="type">The type.</param>
 /// <param name="method">The method.</param>
 /// <param name="usage">The usage.</param>
 /// <param name="usageIndex">Index of the usage.</param>
 public VertexElement(short stream, short offset, DeclarationType type, DeclarationMethod method, DeclarationUsage usage, byte usageIndex)
 {
     Stream = stream;
     Offset = offset;
     Type = type;
     Method = method;
     Usage = usage;
     UsageIndex = usageIndex;
 }
Пример #5
0
 /// <summary>
 /// VertexElement - Defines input vertex data to the pipeline
 /// </summary>
 /// <param name="stream">Stream number</param>
 /// <param name="offset">Offset (if any) from the beginning of the stream to the start of the data</param>
 /// <param name="declarationType">One of several predefined types that define the data size</param>
 /// <param name="declarationMethod">Tessellator processing method. This method determines how the tessellator interprets/operates on the vertex data</param>
 /// <param name="declarationUsage">Defines the intended use of the data</param>
 /// <param name="usageIndex">Modifies the usage data to allow the user to specify multiple usage types</param>
 public VertexElement(short stream, short offset, DeclarationType declarationType, DeclarationMethod declarationMethod,
                      DeclarationUsage declarationUsage, byte usageIndex)
 {
     Stream            = stream;
     Offset            = offset;
     DeclarationType   = declarationType;
     DeclarationMethod = declarationMethod;
     DeclarationUsage  = declarationUsage;
     UsageIndex        = usageIndex;
 }
Пример #6
0
        /// <summary>
        /// Returns the number of streams of a certain <see cref="DeclarationUsage"/>.
        /// </summary>
        /// <param name="usage">The <see cref="DeclarationUsage"/> to get the number of streams for.</param>
        /// <returns>The number of streams of a certain <see cref="DeclarationUsage"/>.</returns>
        public int Count(DeclarationUsage usage)
        {
            int counter = 0;

            for (int i = 0; i < types.Length; i++)
            {
                if (StreamFactory.Instance.VertexElement(types[i]).DeclarationUsage == usage)
                {
                    counter++;
                }
            }
            return(counter);
        }
Пример #7
0
        public static bool FindElement(VertexElement[] decl, DeclarationUsage usage, int usageIdx, out int found)
        {
            for (int iExists = 0; decl[iExists].Stream != 255 && iExists < decl.Length; iExists++)
            {
                if (decl[iExists].DeclarationUsage == usage && decl[iExists].UsageIndex == usageIdx)
                {
                    found = iExists;
                    return(true);
                }
            }

            found = -1;
            return(false);
        }
        public static bool ExtractUsage(VertexElement[] elements, DeclarationUsage usage, int index, out DeclarationType format, out int offset)
        {
            format = (DeclarationType)0;
            offset = 0;

            for (int i = 0; i < elements.Length; i++)
            {
                if (elements[i].Usage == usage &&
                    elements[i].UsageIndex == index)
                {
                    format = elements[i].Type;
                    offset = elements[i].Offset;
                    return(true);
                }
            }
            return(false);
        }
Пример #9
0
        public static bool FindValidUsageIndex(VertexElement[] decl, DeclarationUsage usage, out int usageIndex, out int insertBefore)
        {
            int length = GetLength(decl);

            usageIndex   = 0;
            insertBefore = length;

            for (int iExists = 0; iExists < length; iExists++)
            {
                if (decl[iExists].DeclarationUsage == usage && decl[iExists].UsageIndex >= usageIndex)
                {
                    insertBefore = iExists + 1;
                    usageIndex   = decl[iExists].UsageIndex + 1;
                }
            }

            return(usageIndex < MaxUsageIndex + 1);
        }
Пример #10
0
            public AddVDataArguments(OpsParsedStatement statement)
            {
                OpsParsedArgument typeArg = statement.FindArgument("type");
                if(typeArg == null)
                {
                    typeArg = statement.FindArgument("");
                    if(typeArg == null)
                        throw new OpsException("'type' argument argument");
                }
                type = MeshDeclarationHelper.DecodeType(typeArg.Value);

                OpsParsedArgument usageArg = statement.FindArgument("usage");
                if(usageArg != null)
                    usage = MeshDeclarationHelper.DecodeUsage(usageArg.Value);

                OpsParsedArgument usageIdxArg = statement.FindArgument("usageIdx");
                if(usageIdxArg != null)
                    usageIdx = int.Parse( usageIdxArg.Value );

            }
Пример #11
0
        static VertexDeclarationBuilder()
        {
            _formatMapping     = new Dictionary <Type, DeclarationType>();
            _formatMappingSize = new Dictionary <DeclarationType, int>();
            _usageMapping      = new Dictionary <string, DeclarationUsage>();

            _formatMapping.Add(typeof(Color), DeclarationType.Color);
            _formatMapping.Add(typeof(Half2), DeclarationType.HalfTwo);
            _formatMapping.Add(typeof(Half4), DeclarationType.HalfFour);
            _formatMapping.Add(typeof(float), DeclarationType.Float1);
            _formatMapping.Add(typeof(Vector2), DeclarationType.Float2);
            _formatMapping.Add(typeof(Vector3), DeclarationType.Float3);
            _formatMapping.Add(typeof(Vector4), DeclarationType.Float4);

            foreach (KeyValuePair <Type, DeclarationType> kvp in _formatMapping)
            {
                _formatMappingSize.Add(kvp.Value, Marshal.SizeOf(kvp.Key));
            }

            FieldInfo[] enums = typeof(DeclarationUsage).GetFields(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);

            foreach (FieldInfo field in enums)
            {
                DeclarationUsage usage = (DeclarationUsage)field.GetValue(null);
                _usageMapping.Add(usage.ToString().ToLower(), usage);
            }

            _usageMapping.Add("norm", DeclarationUsage.Normal);
            _usageMapping.Add("pos", DeclarationUsage.Position);
            _usageMapping.Add("binorm", DeclarationUsage.Binormal);
            _usageMapping.Add("colour", DeclarationUsage.Color);
            _usageMapping.Add("diffuse", DeclarationUsage.Color);
            _usageMapping.Add("col", DeclarationUsage.Color);
            _usageMapping.Add("size", DeclarationUsage.PointSize);
            _usageMapping.Add("psize", DeclarationUsage.PointSize);
            _usageMapping.Add("tex", DeclarationUsage.TextureCoordinate);
            _usageMapping.Add("texture", DeclarationUsage.TextureCoordinate);
            _usageMapping.Add("texcoord", DeclarationUsage.TextureCoordinate);
            _usageMapping.Add("texcoordinate", DeclarationUsage.TextureCoordinate);
        }
Пример #12
0
            public DelVDataArguments(OpsParsedStatement statement)
            {
                OpsParsedArgument usageArg = statement.FindArgument("usage");

                if (usageArg == null)
                {
                    usageArg = statement.FindArgument("");
                    if (usageArg == null)
                    {
                        throw OpsException.ArgRequired("usage");
                    }
                }
                usage = MeshDeclarationHelper.DecodeUsage(usageArg.Value);

                OpsParsedArgument usageIdxArg = statement.FindArgument("usageIdx");

                if (usageIdxArg != null)
                {
                    hasSrcUsageIdx = true;
                    usageIdx       = int.Parse(usageIdxArg.Value);
                }
            }
Пример #13
0
            public CloneVDataArguments(OpsParsedStatement statement)
            {
                OpsParsedArgument usageArg = statement.FindArgument("usage");

                if (usageArg == null)
                {
                    usageArg = statement.FindArgument("");
                    if (usageArg == null)
                    {
                        throw OpsException.ArgRequired("usage");
                    }
                }
                srcUsage = MeshDeclarationHelper.DecodeUsage(usageArg.Value);

                OpsParsedArgument usageIdxArg = statement.FindArgument("usageIdx");

                if (usageIdxArg != null)
                {
                    srcUsageIdx    = int.Parse(usageIdxArg.Value);
                    hasSrcUsageIdx = true;
                }

                OpsParsedArgument dstUsageArg = statement.FindArgument("newusage");

                if (dstUsageArg != null)
                {
                    dstUsage = MeshDeclarationHelper.DecodeUsage(dstUsageArg.Value);
                }

                OpsParsedArgument dstUsageIdxArg = statement.FindArgument("newusageIdx");

                if (dstUsageIdxArg != null)
                {
                    dstUsageIdx    = int.Parse(dstUsageIdxArg.Value);
                    hasDstUsageIdx = true;
                }
            }
Пример #14
0
 public VectorDataType(short id, int numValues, int dataSize, DeclarationType declarationType, DeclarationUsage declarationUsage, byte usageIndex)
     : base(id, numValues, dataSize, declarationType, declarationUsage, usageIndex)
 {
 }
        public static bool FindValidUsageIndex(VertexElement[] decl, DeclarationUsage usage, out int usageIndex, out int insertBefore)
        {
            int length= GetLength(decl);

            usageIndex = 0;
            insertBefore = length;

            for(int iExists = 0; iExists < length; iExists++)
            {
                if( decl[iExists].DeclarationUsage == usage && decl[iExists].UsageIndex >= usageIndex )
                {
                    insertBefore = iExists+1;
                    usageIndex = decl[iExists].UsageIndex+1;
                }
            }    

            return (usageIndex < MaxUsageIndex+1);
        }
Пример #16
0
 public VertexElementAttribute(DeclarationUsage usage, byte usageIndex)
 {
     _usage  = usage;
     _format = DeclarationType.Unused;
     _index  = usageIndex;
 }
Пример #17
0
            public DelVDataArguments(OpsParsedStatement statement)
            {
                OpsParsedArgument usageArg = statement.FindArgument("usage");    
                if(usageArg == null)
                {
                    usageArg = statement.FindArgument("");    
                    if(usageArg == null)
                        throw OpsException.ArgRequired("usage");
                }
                usage = MeshDeclarationHelper.DecodeUsage(usageArg.Value);

                OpsParsedArgument usageIdxArg = statement.FindArgument("usageIdx");
                if(usageIdxArg != null)
                {
                    hasSrcUsageIdx = true;
                    usageIdx = int.Parse( usageIdxArg.Value );
                }

            }
Пример #18
0
        public static bool ExtractUsage(VertexElement[] elements, DeclarationUsage usage, int index, out DeclarationType format, out int offset)
        {
            format = (DeclarationType)0;
            offset = 0;

            for (int i = 0; i < elements.Length; i++)
            {
                if (elements[i].Usage == usage &&
                    elements[i].UsageIndex == index)
                {
                    format = elements[i].Type;
                    offset = elements[i].Offset;
                    return true;
                }
            }
            return false;
        }
Пример #19
0
 public VertexElementAttribute(DeclarationUsage usage, DeclarationType format)
 {
     _usage  = usage;
     _format = format;
 }
        public static VertexElement[] AddElement( VertexElement[] decl, DeclarationType type, DeclarationUsage usage, int usageIdx, out int insertBefore)
        {
            int length = GetLength(decl);
            if( length + 1 > MaxLength)
                throw new OpsException("Exceeded maximum declaration length: " + MaxLength);

            if( usageIdx + 1 > MaxUsageIndex)
                throw new OpsException("Exceeded MaxUsageIndex: " + MaxUsageIndex);

            int found;
            if( FindElement( decl, usage, usageIdx , out found) )
                throw new OpsException("VertexElement with that input usage+index already exists");


            VertexElement[] result= new VertexElement[MaxLength];
            
            insertBefore= length;
            for( int less = 1 ; less <= usageIdx ; less++ )
            {
                if( FindElement( decl, usage, usageIdx-less , out found) )
                {
                    //insertBefore should be 1 after where a previous is found...that way they are consecutive
                    //otherwise we just add it to the end.(see initialization insertBefore=length)
                    insertBefore = found+1;
                    break;
                }
            }

            //MOVE EVERYTHING OUT OF THE WAY FOR THE NEW ELEMENT
            short typeSize = (short)GetTypeSize(type);
            //go to decl.Length-1 so that we cant have room for the added element
            for( int iCopyFrom = 0, iCopyTo = 0; iCopyFrom < decl.Length-1; iCopyFrom++, iCopyTo++ )
            {

                //if we are the new element insert here
                if(iCopyFrom == insertBefore)
                {
                    VertexElement insertVE = new VertexElement();
                    insertVE.Stream = 0;
                    if(insertBefore < length)
                        insertVE.Offset = decl[iCopyFrom].Offset;
                    else if(length > 0)
                        insertVE.Offset = (short)((short)(decl[insertBefore-1].Offset) + (short)GetTypeSize( decl[insertBefore-1].DeclarationType ));
                    else
                        insertVE.Offset = 0;

                    insertVE.DeclarationType = type;
                    insertVE.DeclarationMethod = DeclarationMethod.Default;
                    insertVE.DeclarationUsage = usage;
                    insertVE.UsageIndex = (byte)usageIdx;


                    result[iCopyTo]=insertVE;

                    iCopyTo++;
                }


                VertexElement copyVE = decl[iCopyFrom];
                if(iCopyFrom >= insertBefore)
                {
                    copyVE.Offset += typeSize;
                }

                result[iCopyTo] = copyVE;
            }

            result[length+1]=VertexElement.VertexDeclarationEnd;
            return result;
        }    
Пример #21
0
 public VertexElementAttribute(DeclarationUsage usage, byte usageIndex)
 {
     _usage = usage;
     _format = DeclarationType.Unused;
     _index = usageIndex;
 }
Пример #22
0
        public static bool FindValidUsageIndex(VertexElement[] decl, DeclarationUsage usage, out int usageIndex)
        {
            int insertBefore;

            return(FindValidUsageIndex(decl, usage, out usageIndex, out insertBefore));
        }
Пример #23
0
        //---------------------------------------------------------------
        #endregion
        //---------------------------------------------------------------

        //---------------------------------------------------------------
        #region Initialisation
        //---------------------------------------------------------------
        /// <summary>
        /// Creates a new instance of a semantic object.
        /// </summary>
        /// <param name="usage">Usage of parameter.</param>
        /// <param name="usageIndex">UsageIndex of parameter.</param>
        public Semantic(DeclarationUsage usage, int usageIndex)
        {
            Usage      = usage;
            UsageIndex = usageIndex;
        }
Пример #24
0
        public static VertexElement[] AddElement(VertexElement[] decl, DeclarationType type, DeclarationUsage usage, int usageIdx, out int insertBefore)
        {
            int length = GetLength(decl);

            if (length + 1 > MaxLength)
            {
                throw new OpsException("Exceeded maximum declaration length: " + MaxLength);
            }

            if (usageIdx + 1 > MaxUsageIndex)
            {
                throw new OpsException("Exceeded MaxUsageIndex: " + MaxUsageIndex);
            }

            int found;

            if (FindElement(decl, usage, usageIdx, out found))
            {
                throw new OpsException("VertexElement with that input usage+index already exists");
            }


            VertexElement[] result = new VertexElement[MaxLength];

            insertBefore = length;
            for (int less = 1; less <= usageIdx; less++)
            {
                if (FindElement(decl, usage, usageIdx - less, out found))
                {
                    //insertBefore should be 1 after where a previous is found...that way they are consecutive
                    //otherwise we just add it to the end.(see initialization insertBefore=length)
                    insertBefore = found + 1;
                    break;
                }
            }

            //MOVE EVERYTHING OUT OF THE WAY FOR THE NEW ELEMENT
            short typeSize = (short)GetTypeSize(type);

            //go to decl.Length-1 so that we cant have room for the added element
            for (int iCopyFrom = 0, iCopyTo = 0; iCopyFrom < decl.Length - 1; iCopyFrom++, iCopyTo++)
            {
                //if we are the new element insert here
                if (iCopyFrom == insertBefore)
                {
                    VertexElement insertVE = new VertexElement();
                    insertVE.Stream = 0;
                    if (insertBefore < length)
                    {
                        insertVE.Offset = decl[iCopyFrom].Offset;
                    }
                    else if (length > 0)
                    {
                        insertVE.Offset = (short)((short)(decl[insertBefore - 1].Offset) + (short)GetTypeSize(decl[insertBefore - 1].DeclarationType));
                    }
                    else
                    {
                        insertVE.Offset = 0;
                    }

                    insertVE.DeclarationType   = type;
                    insertVE.DeclarationMethod = DeclarationMethod.Default;
                    insertVE.DeclarationUsage  = usage;
                    insertVE.UsageIndex        = (byte)usageIdx;


                    result[iCopyTo] = insertVE;

                    iCopyTo++;
                }


                VertexElement copyVE = decl[iCopyFrom];
                if (iCopyFrom >= insertBefore)
                {
                    copyVE.Offset += typeSize;
                }

                result[iCopyTo] = copyVE;
            }

            result[length + 1] = VertexElement.VertexDeclarationEnd;
            return(result);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="VertexElementAttribute"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="usage">The vertex element usage.</param>
 public VertexElementAttribute(DeclarationType type, DeclarationUsage usage)
 {
     Type = type;
     Usage = usage;
 }
Пример #26
0
        public VertexElement[] GetDeclaration(Type type)
        {
            lock (_declarationMapping)
            {
                VertexElement[] mapping;
                if (_declarationMapping.TryGetValue(type, out mapping))
                {
                    return(mapping);
                }

                if (type == typeof(Vector3))                //special case
                {
                    mapping = new VertexElement[] { new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0) }
                }
                ;
                if (type == typeof(Vector4))
                {
                    mapping = new VertexElement[] { new VertexElement(0, 0, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.Position, 0) }
                }
                ;

                if (mapping == null)
                {
                    List <VertexElement> elements = new List <VertexElement>();
                    int offset = 0;

                    if (type.IsValueType == false)
                    {
                        throw new ArgumentException("Type " + type.Name + " is a not a ValueType (struct)");
                    }

                    foreach (FieldInfo f in type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance))
                    {
                        if (!f.ReflectedType.IsValueType)
                        {
                            throw new ArgumentException("Field " + type.Name + "." + f.Name + " is a not a ValueType (struct)");
                        }

                        int size = Marshal.SizeOf(f.FieldType);

                        bool attribSet = false;

                        foreach (object o in f.GetCustomAttributes(true))
                        {
                            if (o is VertexElementAttribute)
                            {
                                VertexElementAttribute att    = (VertexElementAttribute)o;
                                DeclarationType        format = att.Type;

                                if (format == DeclarationType.Unused)
                                {
                                    format = DetermineFormat(f);
                                }
                                else
                                {
                                    int formatSize;

                                    if (!_formatMappingSize.TryGetValue(format, out formatSize))
                                    {
                                        throw new ArgumentException(string.Format("Invlaid DeclarationType ({0}) specified in VertexElementAttribute for {1}.{2}", format, type.FullName, f.Name));
                                    }

                                    if (formatSize != Marshal.SizeOf(f.FieldType))
                                    {
                                        throw new ArgumentException(string.Format("DeclarationType size mismatch in {4}.{5}, {0} requires a size of {1}, specified type {2} has size {3}", format, formatSize, f.FieldType.FullName, Marshal.SizeOf(f.FieldType), type.FullName, f.Name));
                                    }
                                }

                                elements.Add(new VertexElement(0, (short)offset, format, DeclarationMethod.Default, att.Usage, (byte)att.Index));
                                attribSet = true;
                                break;
                            }
                        }

                        if (!attribSet)
                        {
                            DeclarationType  format = DetermineFormat(f);
                            int              index;
                            DeclarationUsage usage = DetermineUsage(elements, f, out index);

                            elements.Add(new VertexElement(0, (short)offset, format, DeclarationMethod.Default, usage, (byte)index));
                        }

                        offset += size;
                    }

                    elements.Add(VertexElement.VertexDeclarationEnd);

                    mapping = elements.ToArray();
                }

                _declarationMapping.Add(type, mapping);

                return(mapping);
            }
        }
Пример #27
0
 public VertexElementAttribute(DeclarationUsage usage, DeclarationType format)
 {
     _usage = usage;
     _format = format;
 }
Пример #28
0
 public VertexElement(short stream, short offset, DeclarationType declType, DeclarationMethod declMethod, DeclarationUsage declUsage, byte usageIndex)
 {
 }
Пример #29
0
 public VertexElementAttribute(DeclarationUsage usage)
 {
     _usage = usage;
     _format = DeclarationType.Unused;
 }
 public static bool FindValidUsageIndex(VertexElement[] decl, DeclarationUsage usage, out int usageIndex)
 {
     int insertBefore;
     return FindValidUsageIndex( decl, usage, out usageIndex, out insertBefore);
 }    
Пример #31
0
 public VertexElementAttribute(DeclarationUsage usage, DeclarationType format, byte usageIndex)
 {
     _usage = usage;
     _format = format;
     _index = usageIndex;
 }
Пример #32
0
 static void ParseSemantic(string semanticString, out DeclarationUsage declarationUsage, out byte index)
 {
     var match = SemanticEx.Match(semanticString);
     if (!match.Success)
         throw new InvalidDataException(string.Format("'{0}' is not a correct D3D9 semantic", semanticString));
     declarationUsage = ParseDeclarationUsage(match.Groups[1].Value);
     index = string.IsNullOrEmpty(match.Groups[2].Value) ? (byte)0 : byte.Parse(match.Groups[2].Value);
 }
        public static bool FindElement(VertexElement[] decl, DeclarationUsage usage, int usageIdx, out int found)
        {
            for(int iExists = 0; decl[iExists].Stream != 255 && iExists < decl.Length; iExists++)
            {
                if( decl[iExists].DeclarationUsage == usage && decl[iExists].UsageIndex == usageIdx )
                {
                    found = iExists;
                    return true;
                }
            }    

            found = -1;
            return false;
        }    
 /// <summary>
 /// Initializes a new instance of the <see cref="VertexElementAttribute"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="usage">The vertex element usage.</param>
 public VertexElementAttribute(DeclarationType type, DeclarationUsage usage)
 {
     Type  = type;
     Usage = usage;
 }
Пример #35
0
 public VertexElementAttribute(DeclarationUsage usage)
 {
     _usage  = usage;
     _format = DeclarationType.Unused;
 }
Пример #36
0
 public StreamDataType(short id, int numValues, int dataSize, DeclarationType declarationType, DeclarationUsage declarationUsage, byte usageIndex)
 {
     this.Id               = id;
     this.NumValues        = numValues;
     this.DataSize         = dataSize;
     this.DeclarationType  = declarationType;
     this.DeclarationUsage = declarationUsage;
     this.UsageIndex       = usageIndex;
 }
Пример #37
0
 public VertexElementAttribute(DeclarationUsage usage, DeclarationType format, byte usageIndex)
 {
     _usage  = usage;
     _format = format;
     _index  = usageIndex;
 }
Пример #38
0
 public BoneIndexDataType(short id, int numValues, int dataSize, DeclarationType declarationType, DeclarationUsage declarationUsage, byte usageIndex)
     : base(id, numValues, dataSize, declarationType, declarationUsage, usageIndex)
 {
 }
Пример #39
0
            public CloneVDataArguments(OpsParsedStatement statement)
            {
                OpsParsedArgument usageArg = statement.FindArgument("usage");    
                if(usageArg == null)
                {
                    usageArg = statement.FindArgument("");    
                    if(usageArg == null)
                        throw OpsException.ArgRequired("usage");
                }
                srcUsage = MeshDeclarationHelper.DecodeUsage(usageArg.Value);

                OpsParsedArgument usageIdxArg = statement.FindArgument("usageIdx");
                if( usageIdxArg != null )
                {
                    srcUsageIdx = int.Parse( usageIdxArg.Value );
                    hasSrcUsageIdx = true;
                }

                OpsParsedArgument dstUsageArg = statement.FindArgument("newusage");
                if(dstUsageArg != null)
                    dstUsage = MeshDeclarationHelper.DecodeUsage(dstUsageArg.Value);

                OpsParsedArgument dstUsageIdxArg = statement.FindArgument("newusageIdx");
                if( dstUsageIdxArg != null )
                {
                    dstUsageIdx = int.Parse( dstUsageIdxArg.Value );
                    hasDstUsageIdx = true;
                }
            }
Пример #40
0
 public VertexUsage(DeclarationUsage usage = DeclarationUsage.Position, int index = 0)
 {
     Usage = usage;
     Index = index;
 }
Пример #41
0
 public VertexFieldAttribute(DeclarationUsage usage)
 {
     this.usage = usage;
 }
Пример #42
0
        public static Vertices <TVertexType> CreateSingleElementVertices(DeviceContext context, TVertexType[] data, DeclarationUsage elementUsage, int index)
        {
            if (typeof(float) != typeof(TVertexType) &&
                typeof(Vector2) != typeof(TVertexType) &&
                typeof(Vector3) != typeof(TVertexType) &&
                typeof(Vector4) != typeof(TVertexType) &&
                typeof(Half2) != typeof(TVertexType) &&
                typeof(Half4) != typeof(TVertexType))
            {
                throw new ArgumentException("Only float and vector types are supported for single element vertex buffers");
            }

            if (data == null)
            {
                throw new ArgumentNullException();
            }
            if (index >= 16 || index < 0)
            {
                throw new ArgumentException("index");
            }

            DeclarationType format = VertexDeclarationBuilder.DetermineFormat(typeof(TVertexType));

            VertexElement[] elements = new VertexElement[] { new VertexElement(0, 0, format, DeclarationMethod.Default, elementUsage, (byte)index) };

            int stride = VertexElementAttribute.CalculateVertexStride(elements);

            return(new Vertices <TVertexType>(context, data, elements, stride));
        }