Esempio n. 1
0
 /// <summary>
 /// Sets the data for the current vertex using the provided <see cref="AttributeAccessor"/>
 /// </summary>
 /// <param name="accessor">Accessor to the vertex data</param>
 /// <param name="ptrRef">Pointer to the source data</param>
 public void SetAttribute(AttributeAccessor accessor, IntPtr ptrRef)
 {
     Utilities.CopyMemory(vertexBuffer + accessor.Offset, ptrRef, accessor.Size);
 }
Esempio n. 2
0
        /// <summary>
        /// Transforms attribute data using already written data from another attribute
        /// </summary>
        /// <typeparam name="T">Type data</typeparam>
        /// <param name="accessorTo">Vertex attribute accessor to the destination attribute</param>
        /// <param name="accessorFrom">Vertex attribute accessor to the source attribute</param>
        /// <param name="transformMethod">Transform method for the type data</param>
        public void TransformAttributePerParticle <T>(AttributeAccessor accessorFrom, AttributeAccessor accessorTo, TransformAttributeDelegate <T> transformMethod) where T : struct
        {
            for (var i = 0; i < verticesPerParticle; i++)
            {
                var temp = Utilities.Read <T>(vertexBuffer + accessorFrom.Offset + i * VertexDeclaration.VertexStride);

                transformMethod(ref temp);

                Utilities.Write(vertexBuffer + accessorTo.Offset + i * VertexDeclaration.VertexStride, ref temp);
            }
        }
        public void TransformAttributePerParticle <T, U>(AttributeAccessor accessorFrom, AttributeAccessor accessorTo, IAttributeTransformer <T, U> transformMethod, ref U transformer)
            where T : struct
            where U : struct
        {
            for (var i = 0; i < vertexBuilder.VerticesPerParticle; i++)
            {
                var temp = Utilities.Read <T>(VertexBuffer + accessorFrom.Offset + i * VertexStride);

                transformMethod.Transform(ref temp, ref transformer);

                Utilities.Write(VertexBuffer + accessorTo.Offset + i * VertexStride, ref temp);
            }
        }