Exemplo n.º 1
0
        private int                   _alignedByteOffset; // D3D11_APPEND_ALIGNED_ELEMENT = -1


        /// <summary>
        /// Initializes a new instance of the <see cref="VertexElement"/> struct.
        /// </summary>
        /// <param name="semantic">The HLSL semantic of the element in a shader input-signature.</param>
        /// <param name="semanticIndex">The (zero-based) index of the semantic.</param>
        /// <param name="format">The data type of the element.</param>
        /// <param name="alignedByteOffset">
        /// The aligned offset in bytes from the beginning of the stream to the beginning of the
        /// element. Use -1 for convenience to define the current element directly after the previous
        /// one, including any packing if necessary.
        /// </param>
        public VertexElement(VertexElementSemantic semantic, int semanticIndex, DataFormat format, int alignedByteOffset = -1)
        {
            _semantic          = semantic;
            _semanticIndex     = semanticIndex;
            _format            = format;
            _alignedByteOffset = alignedByteOffset;
        }
Exemplo n.º 2
0
        public virtual int GetAttributeIndex(VertexElementSemantic semantic, int index)
        {
            int res = this.customAttribues[(int)semantic - 1, index];

            if (res == NullCustomAttributesIndex)
            {
                string attString = this.GetAttributeSemanticString(semantic);
                int    attrib    = GL.GetAttribLocation(this.glProgramHandle, attString);
                GLES2Config.GlCheckError(this);

                //sadly position is a special case
                if (attrib == NotFoundCustomAttributesIndex && semantic == VertexElementSemantic.Position)
                {
                    attrib = GL.GetAttribLocation(this.glProgramHandle, "position");
                    GLES2Config.GlCheckError(this);
                }

                //for uv and other case the index is a part of the name
                if (attrib == NotFoundCustomAttributesIndex)
                {
                    string attStringWithSemantic = attString + index.ToString();
                    attrib = GL.GetAttribLocation(this.glProgramHandle, attStringWithSemantic);
                    GLES2Config.GlCheckError(this);
                }

                //update customAttributes with the index we found (or didnt' find)
                this.customAttribues[(int)semantic - 1, index] = attrib;
                res = attrib;
            }
            return(res);
        }
        public bool VerticesWriteChannel <T>(VertexElementSemantic semantic, T[] data, byte[] writeToVertices) where T : unmanaged
        {
            var vertexStructure = VertexStructure.Value;

            if (vertexStructure != null)
            {
                vertexStructure.GetInfo(out var vertexSize, out _);
                var vertexCount = writeToVertices.Length / vertexSize;

                if (vertexStructure.GetElementBySemantic(semantic, out var element))
                {
                    unsafe
                    {
                        if (VertexElement.GetSizeInBytes(element.Type) == sizeof(T))
                        {
                            fixed(byte *pVertices = writeToVertices)
                            {
                                byte *src = pVertices + element.Offset;

                                for (int n = 0; n < vertexCount; n++)
                                {
                                    *(T *)src = data[n];
                                    src      += vertexSize;
                                }
                            }
                        }
                    }
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Constructs a new VertexElementDescription describing a per-vertex element.
 /// </summary>
 /// <param name="name">The name of the element.</param>
 /// <param name="semantic">The semantic type of the element.</param>
 /// <param name="format">The format of the element.</param>
 public VertexElementDescription(string name, VertexElementSemantic semantic, VertexElementFormat format)
 {
     Name     = name;
     Format   = format;
     Semantic = semantic;
     Offset   = 0;
 }
Exemplo n.º 5
0
        public virtual VertexElement AddElement(VertexElementType theType, VertexElementSemantic semantic)
        {
            VertexElement ve = mSubMesh.vertexData.vertexDeclaration.AddElement(0, offset, theType, semantic);

            offset += VertexElement.GetTypeSize(theType);
            return(ve);
        }
Exemplo n.º 6
0
        public override void ModifyElement(int elemIndex, short source, int offset, VertexElementType type,
                                           VertexElementSemantic semantic, int index)
        {
            base.ModifyElement(elemIndex, source, offset, type, semantic, index);

            needsRebuild = true;
        }
Exemplo n.º 7
0
 public VertexElement(ushort source, uint offset, VertexElementType theType, VertexElementSemantic semantic) : this(OgrePINVOKE.new_VertexElement__SWIG_2(source, offset, (int)theType, (int)semantic), true)
 {
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 8
0
        /// <summary>
        ///     Adds a new VertexElement to this declaration.
        /// </summary>
        /// <remarks>
        ///     This method adds a single element (positions, normals etc) to the
        ///     vertex declaration. <b>Please read the information in <see cref="VertexDeclaration"/> about
        ///     the importance of ordering and structure for compatibility with older D3D drivers</b>.
        /// </remarks>
        /// <param name="source">
        ///     The binding index of HardwareVertexBuffer which will provide the source for this element.
        /// </param>
        /// <param name="offset">The offset in bytes where this element is located in the buffer.</param>
        /// <param name="type">The data format of the element (3 floats, a color etc).</param>
        /// <param name="semantic">The meaning of the data (position, normal, diffuse color etc).</param>
        /// <param name="index">Optional index for multi-input elements like texture coordinates.</param>
        public virtual VertexElement AddElement(short source, int offset, VertexElementType type,
                                                VertexElementSemantic semantic, int index)
        {
            var element = new VertexElement(source, offset, type, semantic, index);

            this.elements.Add(element);
            return(element);
        }
Exemplo n.º 9
0
 public void removeElement(VertexElementSemantic semantic)
 {
     OgrePINVOKE.VertexDeclaration_removeElement__SWIG_2(swigCPtr, (int)semantic);
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 10
0
		public override Axiom.Graphics.VertexElement AddElement( short source, int offset, VertexElementType type, VertexElementSemantic semantic, int index )
		{
			Axiom.Graphics.VertexElement element = base.AddElement( source, offset, type, semantic, index );

			needsRebuild = true;

			return element;
		}
Exemplo n.º 11
0
 public VertexElement( short source, int offset, VertexElementType type, VertexElementSemantic semantic, int index )
 {
     this.source = source;
     this.offset = offset;
     this.type = type;
     this.semantic = semantic;
     this.index = index;
 }
Exemplo n.º 12
0
        public VertexElementDescription ReadVertexElementDesc(BinaryReader reader)
        {
            string name = reader.ReadString();
            VertexElementSemantic semantic = reader.ReadEnum <VertexElementSemantic>();
            VertexElementFormat   format   = reader.ReadEnum <VertexElementFormat>();

            return(new VertexElementDescription(name, format, semantic));
        }
Exemplo n.º 13
0
		public override Axiom.Graphics.VertexElement InsertElement( int position, short source, int offset, VertexElementType type, VertexElementSemantic semantic, int index )
		{
			Axiom.Graphics.VertexElement element = base.InsertElement( position, source, offset, type, semantic, index );

			needsRebuild = true;

			return element;
		}
Exemplo n.º 14
0
 public void buildTangentVectors(VertexElementSemantic targetSemantic, ushort sourceTexCoordSet)
 {
     OgrePINVOKE.Mesh_buildTangentVectors__SWIG_4(swigCPtr, (int)targetSemantic, sourceTexCoordSet);
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 15
0
 public void buildTangentVectors(VertexElementSemantic targetSemantic, ushort sourceTexCoordSet, ushort index, bool splitMirrored, bool splitRotated)
 {
     OgrePINVOKE.Mesh_buildTangentVectors__SWIG_1(swigCPtr, (int)targetSemantic, sourceTexCoordSet, index, splitMirrored, splitRotated);
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 16
0
 public void buildTangentVectors(VertexElementSemantic targetSemantic)
 {
     OgrePINVOKE.Mesh_buildTangentVectors__SWIG_5(swigCPtr, (int)targetSemantic);
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 17
0
 public virtual VertexElement AddElement(ushort source, VertexElementType theType,
     VertexElementSemantic semantic)
 {
     VertexElement ve = mSubMesh.vertexData.vertexDeclaration.AddElement(source, offset,
                                                                  theType, semantic);
     offset += VertexElement.GetTypeSize(theType);
     return ve;
 }
Exemplo n.º 18
0
 /// <summary>
 ///     Constructor.
 /// </summary>
 /// <param name="source">The source vertex buffer, as bound to an index using <see cref="VertexBufferBinding"/>.</param>
 /// <param name="offset">The offset in the buffer that this element starts at.</param>
 /// <param name="type">The type of element.</param>
 /// <param name="semantic">The meaning of the element.</param>
 /// <param name="index">Index of the item, only applicable for some elements like texture coords.</param>
 public VertexElement(ushort source, int offset, VertexElementType type, VertexElementSemantic semantic, int index)
 {
     this.source   = source;
     this.offset   = offset;
     this.type     = type;
     this.semantic = semantic;
     this.index    = index;
 }
Exemplo n.º 19
0
        //int index;

        public VertexElement(int source, int offset, VertexElementType type, VertexElementSemantic semantic)          //, int index = 0 )
        {
            this.source   = source;
            this.offset   = offset;
            this.type     = type;
            this.semantic = semantic;
            //this.index = index;
        }
Exemplo n.º 20
0
 public BufferBindingBuilder AddElement(
     VertexElementType type,
     VertexElementSemantic semantic,
     byte semanticIndex = 0
     )
 {
     var     elemIdx = mBinding._elementCount++;
     ref var elem    = ref mBinding._elements[elemIdx];
Exemplo n.º 21
0
        public override VertexElement AddElement(short source, int offset, VertexElementType type,
                                                 VertexElementSemantic semantic, int index)
        {
            var element = base.AddElement(source, offset, type, semantic, index);

            needsRebuild = true;

            return(element);
        }
Exemplo n.º 22
0
        public override VertexElement InsertElement(int position, short source, int offset, VertexElementType type,
                                                    VertexElementSemantic semantic, int index)
        {
            var element = base.InsertElement(position, source, offset, type, semantic, index);

            needsRebuild = true;

            return(element);
        }
Exemplo n.º 23
0
        internal static uint FixedAttributeIndex(VertexElementSemantic semantic, uint index)
        {
            // Some drivers (e.g. OS X on nvidia) incorrectly determine the attribute binding automatically
            // and end up aliasing existing built-ins. So avoid! Fixed builtins are:

            //  a  builtin                          custom attrib name
            // ----------------------------------------------
            //      0  gl_Vertex                    vertex
            //  1  n/a                                      blendWeights
            //      2  gl_Normal                    normal
            //      3  gl_Color                             colour
            //      4  gl_SecondaryColor    secondary_colour
            //      5  gl_FogCoord                  fog_coord
            //  7  n/a                                      blendIndices
            //      8  gl_MultiTexCoord0    uv0
            //      9  gl_MultiTexCoord1    uv1
            //      10 gl_MultiTexCoord2    uv2
            //      11 gl_MultiTexCoord3    uv3
            //      12 gl_MultiTexCoord4    uv4
            //      13 gl_MultiTexCoord5    uv5
            //      14 gl_MultiTexCoord6    uv6, tangent
            //      15 gl_MultiTexCoord7    uv7, binormal
            switch (semantic)
            {
            case VertexElementSemantic.Position:
                return(0);

            case VertexElementSemantic.BlendWeights:
                return(1);

            case VertexElementSemantic.Normal:
                return(2);

            case VertexElementSemantic.Diffuse:
                return(3);

            case VertexElementSemantic.Specular:
                return(4);

            case VertexElementSemantic.BlendIndices:
                return(7);

            case VertexElementSemantic.TexCoords:
                return(8 + index);

            case VertexElementSemantic.Tangent:
                return(14);

            case VertexElementSemantic.Binormal:
                return(15);

            default:
                Debug.Assert(false, "Missing attribute!");
                // Unreachable code, but keeps compiler happy
                return(0);
            }
        }
 /// <summary>
 ///   Adds a vertex element to the vertexData and allocates the vertex
 ///   buffer and populates it with the information in the data array.
 ///   This variant uses the data in the mesh to determine appropriate
 ///   settings for the vertexBufferUsage and useVertexShadowBuffer
 ///   parameters.
 /// </summary>
 /// <param name="vertexData">
 ///   the vertex data object whose vertex declaration and buffer
 ///   bindings must be modified to include the reference to the new
 ///   buffer
 /// </param>
 /// <param name="type">the type of vertex element being added</param>
 /// <param name="semantic">the semantic of the element being added</param>
 /// <param name="bindIdx">the index that will be used for this buffer</param>
 /// <param name="index">the texture index to which this buffer will apply (or 0)</param>
 /// <param name="data">the raw data that will be used to populate the buffer</param>
 internal void AllocateBuffer(VertexData vertexData, VertexElementType type,
                              VertexElementSemantic semantic,
                              ushort bindIdx, int index, int[] data)
 {
     AllocateBuffer(vertexData, type, semantic,
                    bindIdx, index, data,
                    m_AxiomMesh.VertexBufferUsage,
                    m_AxiomMesh.UseVertexShadowBuffer);
 }
Exemplo n.º 25
0
        public VertexElementSemantic getSemantic()
        {
            VertexElementSemantic ret = (VertexElementSemantic)OgrePINVOKE.VertexElement_getSemantic(swigCPtr);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 26
0
        public bool suggestTangentVectorBuildParams(VertexElementSemantic targetSemantic, SWIGTYPE_p_unsigned_short outSourceCoordSet, SWIGTYPE_p_unsigned_short outIndex)
        {
            bool ret = OgrePINVOKE.Mesh_suggestTangentVectorBuildParams(swigCPtr, (int)targetSemantic, SWIGTYPE_p_unsigned_short.getCPtr(outSourceCoordSet), SWIGTYPE_p_unsigned_short.getCPtr(outIndex));

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 27
0
        public VertexElement findElementBySemantic(VertexElementSemantic sem)
        {
            global::System.IntPtr cPtr = OgrePINVOKE.VertexDeclaration_findElementBySemantic__SWIG_1(swigCPtr, (int)sem);
            VertexElement         ret  = (cPtr == global::System.IntPtr.Zero) ? null : new VertexElement(cPtr, false);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 28
0
 public VertexElementDescription(
     string name,
     VertexElementFormat format,
     VertexElementSemantic semantic,
     uint instanceStepRate)
 {
     Name             = name;
     Format           = format;
     Semantic         = semantic;
     InstanceStepRate = instanceStepRate;
 }
Exemplo n.º 29
0
        //public static int GetPrimitivesCount(this PrimitiveType primitiveType, int indicesCount)
        //{
        //    switch (primitiveType)
        //    {
        //        case PrimitiveType.LineList:
        //            return indicesCount / 2;
        //        case PrimitiveType.LineStrip:
        //            return MathUtils.Max(indicesCount - 1, 0);
        //        case PrimitiveType.TriangleList:
        //            return indicesCount / 3;
        //        case PrimitiveType.TriangleStrip:
        //            return MathUtils.Max(indicesCount - 2, 0);
        //        default:
        //            throw new InvalidOperationException("Unsupported PrimitiveType.");
        //    }
        //}

        public static string GetSemanticString(this VertexElementSemantic semantic)
        {
            switch (semantic)
            {
            case VertexElementSemantic.Position:
                return("POSITION");

            case VertexElementSemantic.Color:
                return("COLOR");

            case VertexElementSemantic.Normal:
                return("NORMAL");

            case VertexElementSemantic.TextureCoordinate:
                return("TEXCOORD");

            case VertexElementSemantic.TextureCoordinate0:
                return("TEXCOORD0");

            case VertexElementSemantic.TextureCoordinate1:
                return("TEXCOORD1");

            case VertexElementSemantic.TextureCoordinate2:
                return("TEXCOORD2");

            case VertexElementSemantic.TextureCoordinate3:
                return("TEXCOORD3");

            case VertexElementSemantic.TextureCoordinate4:
                return("TEXCOORD4");

            case VertexElementSemantic.TextureCoordinate5:
                return("TEXCOORD5");

            case VertexElementSemantic.TextureCoordinate6:
                return("TEXCOORD6");

            case VertexElementSemantic.TextureCoordinate7:
                return("TEXCOORD7");

            case VertexElementSemantic.Instance:
                return("INSTANCE");

            case VertexElementSemantic.BlendIndices:
                return("BLENDINDICES");

            case VertexElementSemantic.BlendWeights:
                return("BLENDWEIGHTS");

            default:
                throw new InvalidOperationException("Unrecognized vertex semantic.");
            }
        }
Exemplo n.º 30
0
        protected string GetAttributeSemanticString(VertexElementSemantic semantic)
        {
            foreach (var key in this.semanticTypeMap.Keys)
            {
                if (this.semanticTypeMap[key] == semantic)
                {
                    return(key);
                }
            }

            return(string.Empty);
        }
Exemplo n.º 31
0
        public ushort GetVertexElementSemanticCount(VertexElementSemantic semantic)
        {
            ushort count = 0;

            foreach (var vbe in vertexBufferElements)
            {
                if (vbe.VertexElementSemantic == semantic)
                {
                    count++;
                }
            }
            return(count);
        }
Exemplo n.º 32
0
        /// <summary>
        ///		Remove the element with the given semantic and usage index.
        /// </summary>
        /// <param name="semantic">Semantic to remove.</param>
        /// <param name="index">Usage index to remove, typically only applies to tex coords.</param>
        public virtual void RemoveElement(VertexElementSemantic semantic, int index)
        {
            for (int i = elements.Count - 1; i >= 0; i--)
            {
                VertexElement element = elements[i];

                if (element.Semantic == semantic && element.Index == index)
                {
                    // we have a winner!
                    elements.RemoveAt(i);
                }
            }
        }
Exemplo n.º 33
0
        /// <summary>
        ///		Inserts a new <see cref="VertexElement"/> at a given position in this declaration.
        /// </summary>
        /// <remarks>
        ///		This method adds a single element (positions, normals etc) at a given position in this
        ///		vertex declaration. <b>Please read the information in VertexDeclaration about
        ///		the importance of ordering and structure for compatibility with older D3D drivers</b>.
        /// </remarks>
        /// <param name="position">Position to insert into.</param>
        /// <param name="source">The binding index of HardwareVertexBuffer which will provide the source for this element.</param>
        /// <param name="offset">The offset in bytes where this element is located in the buffer.</param>
        /// <param name="type">The data format of the element (3 floats, a color, etc).</param>
        /// <param name="semantic">The meaning of the data (position, normal, diffuse color etc).</param>
        /// <param name="index">Optional index for multi-input elements like texture coordinates.</param>
        /// <returns>A reference to the newly created element.</returns>
        public virtual VertexElement InsertElement(int position, short source, int offset, VertexElementType type,
                                                   VertexElementSemantic semantic, int index)
        {
            if (position >= this.elements.Count)
            {
                return(AddElement(source, offset, type, semantic, index));
            }

            var element = new VertexElement(source, offset, type, semantic, index);

            this.elements.Insert(position, element);

            return(element);
        }
Exemplo n.º 34
0
        internal override bool IsAttributeValid(VertexElementSemantic semantic, uint index)
        {
            // get link program - only call this in the context of bound program
            var linkProgram = GLSLLinkProgramManager.Instance.ActiveLinkProgram;

            if (linkProgram.IsAttributeValid(semantic, index))
            {
                return(true);
            }
            //else
            {
                // fall back to default implementation, allow default bindings
                return(base.IsAttributeValid(semantic, index));
            }
        }
Exemplo n.º 35
0
		public override void RemoveElement( VertexElementSemantic semantic, int index )
		{
			base.RemoveElement( semantic, index );

			needsRebuild = true;
		}
Exemplo n.º 36
0
		public override void RemoveElement( VertexElementSemantic semantic, int index )
		{
			base.RemoveElement( semantic, index );
			_releaseDeclaration();
		}
Exemplo n.º 37
0
		public override void ModifyElement( int elemIndex, short source, int offset, VertexElementType type, VertexElementSemantic semantic, int index )
		{
			base.ModifyElement( elemIndex, source, offset, type, semantic, index );

			needsRebuild = true;
		}
Exemplo n.º 38
0
 public VertexElement FindElementBySemantic( VertexElementSemantic semantic )
 {
     return FindElementBySemantic( semantic, 0 );
 }
Exemplo n.º 39
0
		public override void ModifyElement( int elemIndex, short source, int offset, VertexElementType type,
		                                    VertexElementSemantic semantic, int index )
		{
			base.ModifyElement( elemIndex, source, offset, type, semantic, index );
			_releaseDeclaration();
		}
Exemplo n.º 40
0
		public bool IsAttributeValid( VertexElementSemantic semantic, int index )
		{
			return this.GetAttributeIndex( semantic, index ) != NotFoundCustomAttributesIndex;
		}
Exemplo n.º 41
0
 public VertexElement AddElement( short source, int offset, VertexElementType type, VertexElementSemantic semantic )
 {
     return AddElement( source, offset, type, semantic, 0 );
 }
Exemplo n.º 42
0
 public void ModifyElement( int elemIndex, short source, int offset, VertexElementType type, VertexElementSemantic semantic )
 {
     ModifyElement( elemIndex, source, offset, type, semantic, 0 );
 }
Exemplo n.º 43
0
        public virtual VertexElement InsertElement( int position, short source, int offset, VertexElementType type, VertexElementSemantic semantic, int index )
        {
            if ( position >= elements.Count )
            {
                return AddElement( source, offset, type, semantic, index );
            }

            VertexElement element = new VertexElement( source, offset, type, semantic, index );
            elements.Insert( position, element );
            return element;
        }
Exemplo n.º 44
0
 public virtual void ModifyElement( int elemIndex, short source, int offset, VertexElementType type, VertexElementSemantic semantic, int index )
 {
     elements[ elemIndex ] = new VertexElement( source, offset, type, semantic, index );
 }
Exemplo n.º 45
0
		internal virtual bool IsAttributeValid( VertexElementSemantic semantic, uint index )
		{
			switch ( semantic )
			{
				case VertexElementSemantic.Diffuse:
				case VertexElementSemantic.Normal:
				case VertexElementSemantic.Position:
				case VertexElementSemantic.Specular:
				case VertexElementSemantic.TexCoords:
				default:
			        return false;
				case VertexElementSemantic.Binormal:
				case VertexElementSemantic.BlendIndices:
				case VertexElementSemantic.BlendWeights:
				case VertexElementSemantic.Tangent:
					return true;

			}
			return false; // keeps compiler happy

		}
Exemplo n.º 46
0
        internal static uint FixedAttributeIndex( VertexElementSemantic semantic, uint index )
        {
            // Some drivers (e.g. OS X on nvidia) incorrectly determine the attribute binding automatically
            // and end up aliasing existing built-ins. So avoid! Fixed builtins are: 

            //  a  builtin                          custom attrib name
            // ----------------------------------------------
            //      0  gl_Vertex                    vertex
            //  1  n/a                                      blendWeights            
            //      2  gl_Normal                    normal
            //      3  gl_Color                             colour
            //      4  gl_SecondaryColor    secondary_colour
            //      5  gl_FogCoord                  fog_coord
            //  7  n/a                                      blendIndices
            //      8  gl_MultiTexCoord0    uv0
            //      9  gl_MultiTexCoord1    uv1
            //      10 gl_MultiTexCoord2    uv2
            //      11 gl_MultiTexCoord3    uv3
            //      12 gl_MultiTexCoord4    uv4
            //      13 gl_MultiTexCoord5    uv5
            //      14 gl_MultiTexCoord6    uv6, tangent
            //      15 gl_MultiTexCoord7    uv7, binormal
            switch (semantic)
            {
                case VertexElementSemantic.Position:
                    return 0;
                case VertexElementSemantic.BlendWeights:
                    return 1;
                case VertexElementSemantic.Normal:
                    return 2;
                case VertexElementSemantic.Diffuse:
                    return 3;
                case VertexElementSemantic.Specular:
                    return 4;
                case VertexElementSemantic.BlendIndices:
                    return 7;
                case VertexElementSemantic.TexCoords:
                    return 8 + index;
                case VertexElementSemantic.Tangent:
                    return 14;
                case VertexElementSemantic.Binormal:
                    return 15;
                default:
                    Debug.Assert(false,  "Missing attribute!");
                    return 0;
            }
        }
Exemplo n.º 47
0
 public void RemoveElement( VertexElementSemantic semantic )
 {
     RemoveElement( semantic, 0 );
 }
Exemplo n.º 48
0
        public virtual void RemoveElement( VertexElementSemantic semantic, int index )
        {
            for ( int i = elements.Count - 1; i >= 0; i-- )
            {
                VertexElement element = (VertexElement)elements[ i ];

                if ( element.Semantic == semantic && element.Index == index )
                {
                    elements.RemoveAt( i );
                }
            }
        }
Exemplo n.º 49
0
		public override Axiom.Graphics.VertexElement InsertElement( int position, short source, int offset,
		                                                            VertexElementType type, VertexElementSemantic semantic,
		                                                            int index )
		{
			_releaseDeclaration();
			return base.InsertElement( position, source, offset, type, semantic, index );
		}
Exemplo n.º 50
0
		protected string GetAttributeSemanticString( VertexElementSemantic semantic )
		{
			foreach ( var key in this.semanticTypeMap.Keys )
			{
				if ( this.semanticTypeMap[ key ] == semantic )
				{
					return key;
				}
			}

			return string.Empty;
		}
Exemplo n.º 51
0
		public override Axiom.Graphics.VertexElement AddElement( short source, int offset, VertexElementType type,
		                                                         VertexElementSemantic semantic, int index )
		{
			_releaseDeclaration();
			return base.AddElement( source, offset, type, semantic, index );
		}
Exemplo n.º 52
0
		/// <summary>
		///     Constructor.
		/// </summary>
		/// <param name="source">The source vertex buffer, as bound to an index using <see cref="VertexBufferBinding"/>.</param>
		/// <param name="offset">The offset in the buffer that this element starts at.</param>
		/// <param name="type">The type of element.</param>
		/// <param name="semantic">The meaning of the element.</param>
		public VertexElement( short source, int offset, VertexElementType type, VertexElementSemantic semantic )
			: this( source, offset, type, semantic, 0 )
		{
		}
Exemplo n.º 53
0
		public virtual int GetAttributeIndex( VertexElementSemantic semantic, int index )
		{
			int res = this.customAttribues[ (int) semantic - 1, index ];
			if ( res == NullCustomAttributesIndex )
			{
				string attString = this.GetAttributeSemanticString( semantic );
				int attrib = GL.GetAttribLocation( this.glProgramHandle, attString );
				GLES2Config.GlCheckError( this );

				//sadly position is a special case
				if ( attrib == NotFoundCustomAttributesIndex && semantic == VertexElementSemantic.Position )
				{
					attrib = GL.GetAttribLocation( this.glProgramHandle, "position" );
					GLES2Config.GlCheckError( this );
				}

				//for uv and other case the index is a part of the name
				if ( attrib == NotFoundCustomAttributesIndex )
				{
					string attStringWithSemantic = attString + index.ToString();
					attrib = GL.GetAttribLocation( this.glProgramHandle, attStringWithSemantic );
					GLES2Config.GlCheckError( this );
				}

				//update customAttributes with the index we found (or didnt' find)
				this.customAttribues[ (int) semantic - 1, index ] = attrib;
				res = attrib;
			}
			return res;
		}
Exemplo n.º 54
0
 public virtual VertexElement AddElement( short source, int offset, VertexElementType type, VertexElementSemantic semantic, int index )
 {
     VertexElement element = new VertexElement( source, offset, type, semantic, index );
     elements.Add( element );
     return element;
 }
Exemplo n.º 55
0
        internal virtual uint AttributeIndex(VertexElementSemantic semantic, uint index)
		{
            return FixedAttributeIndex(semantic, index);
		}
Exemplo n.º 56
0
 public VertexElement InsertElement( int position, short source, int offset, VertexElementType type, VertexElementSemantic semantic )
 {
     return InsertElement( position, source, offset, type, semantic, 0 );
 }
Exemplo n.º 57
0
		public static XFG.VertexElementUsage Convert( VertexElementSemantic semantic )
		{
			switch ( semantic )
			{
				case VertexElementSemantic.BlendIndices:
					return XFG.VertexElementUsage.BlendIndices;

				case VertexElementSemantic.BlendWeights:
					return XFG.VertexElementUsage.BlendWeight;

				case VertexElementSemantic.Diffuse:
					// index makes the difference (diffuse - 0)
					return XFG.VertexElementUsage.Color;

				case VertexElementSemantic.Specular:
					// index makes the difference (specular - 1)
					return XFG.VertexElementUsage.Color;

				case VertexElementSemantic.Normal:
					return XFG.VertexElementUsage.Normal;

				case VertexElementSemantic.Position:
					return XFG.VertexElementUsage.Position;

				case VertexElementSemantic.TexCoords:
					return XFG.VertexElementUsage.TextureCoordinate;

				case VertexElementSemantic.Binormal:
					return XFG.VertexElementUsage.Binormal;

				case VertexElementSemantic.Tangent:
					return XFG.VertexElementUsage.Tangent;
			} // switch

			// keep the compiler happy
			return XFG.VertexElementUsage.Position;
		}
Exemplo n.º 58
0
 public virtual VertexElement FindElementBySemantic( VertexElementSemantic semantic, short index )
 {
     for ( int i = 0; i < elements.Count; i++ )
     {
         VertexElement element = (VertexElement)elements[ i ];
         if ( element.Semantic == semantic && element.Index == index )
             return element;
     }
     return null;
 }
Exemplo n.º 59
0
        internal override bool IsAttributeValid(VertexElementSemantic semantic, uint index)
        {
            // get link program - only call this in the context of bound program
            var linkProgram = GLSLLinkProgramManager.Instance.ActiveLinkProgram;

            if (linkProgram.IsAttributeValid(semantic, index))
            {
                return true;
            } 
            //else
            {
                // fall back to default implementation, allow default bindings
                return base.IsAttributeValid(semantic, index);
            }
        }
Exemplo n.º 60
0
 public virtual VertexElement AddElement(VertexElementType theType,
     VertexElementSemantic semantic)
 {
     return this.AddElement((ushort)0, theType, semantic);
 }