示例#1
0
 /// <summary>
 /// Generate texture coordinates for the elements defined in this vertex array.
 /// </summary>
 /// <param name="genTexCoordCallback">
 /// A <see cref="VertexArrayTexGenDelegate"/> used for generating texture coordinates.
 /// </param>
 public void GenerateTexCoords(VertexArrayTexGenDelegate genTexCoordCallback)
 {
     foreach (Element vertexElement in DrawElements)
     {
         vertexElement.GenerateTexCoord(this, genTexCoordCallback);
     }
 }
示例#2
0
 /// <summary>
 /// Generate texture coordinates for the elements defined in this vertex array.
 /// </summary>
 /// <param name="genTexCoordCallback">
 /// A <see cref="VertexArrayTexGenDelegate"/> used for generating texture coordinates.
 /// </param>
 public void GenerateTexCoords(GraphicsContext ctx, VertexArrayTexGenDelegate genTexCoordCallback)
 {
     foreach (Element vertexElement in DrawElements)
     {
         vertexElement.GenerateTexCoord(ctx, this, genTexCoordCallback);
     }
 }
            /// <summary>
            /// Generate texture coordinates for this Element.
            /// </summary>
            /// <param name="vertexArray">
            /// The <see cref="VertexArrayObject"/>
            /// </param>
            public override void GenerateTexCoord(VertexArrayObject vertexArray, VertexArrayTexGenDelegate genTexCoordCallback)
            {
                IVertexArray positionArray = vertexArray.GetVertexArray(VertexArraySemantic.Position);

                if (positionArray == null)
                {
                    throw new InvalidOperationException("position semantic not set");
                }

                IVertexArray texArray = vertexArray.GetVertexArray(VertexArraySemantic.TexCoord);

                if (texArray == null)
                {
                    throw new InvalidOperationException("texture semantic not set");
                }
                if (texArray.Array == null)
                {
                    throw new InvalidOperationException("texture array not set");
                }

                if (positionArray.Array != null)
                {
                    positionArray.Array.Map();
                }
                texArray.Array.Map();
                ArrayIndices.Map();

                try {
                    switch (ElementsMode)
                    {
                    case PrimitiveType.Triangles:
                    case PrimitiveType.TriangleStrip:
                        switch (positionArray.ArraySection.ItemType)
                        {
                        case ArrayBufferItemType.Float3:
                            GenerateTexCoordsTriangle3f(positionArray, texArray, genTexCoordCallback);
                            break;

                        default:
                            throw new NotSupportedException("normals generation not supported for elements of type " + positionArray.ArraySection.ItemType);
                        }
                        break;

                    default:
                        throw new NotSupportedException("normals generation not supported for primitive " + ElementsMode);
                    }
                } finally {
                    if (positionArray.Array != null)
                    {
                        positionArray.Array.Unmap();
                    }
                    texArray.Array.Unmap();
                    ArrayIndices.Unmap();
                }
            }
            private void GenerateTexCoordsTriangle3f(IVertexArray positionArray, IVertexArray texArray, VertexArrayTexGenDelegate genTexCoordCallback)
            {
                for (uint i = 0, v = ElementOffset; i < ArrayIndices.ItemCount; i++, v++)
                {
                    uint vIndex = ArrayIndices.GetIndex(v);

                    Vertex3f v0 = positionArray.GetElement <Vertex3f>(vIndex);

                    texArray.SetElement <Vertex2f>(genTexCoordCallback(v0), vIndex);
                }
            }
 /// <summary>
 /// Generate texture coordinates for this Element.
 /// </summary>
 /// <param name="vertexArray">
 /// The <see cref="VertexArrayObject"/>
 /// </param>
 public virtual void GenerateTexCoord(VertexArrayObject vertexArray, VertexArrayTexGenDelegate genTexCoordCallback)
 {
     throw new NotImplementedException();
 }