コード例 #1
0
            /// <summary>
            /// Builds the vertex array.
            /// </summary>
            /// <param name="geometry">The geometry.</param>
            /// <returns></returns>
            private DefaultVertex[] BuildVertexArray(MeshGeometry3D geometry)
            {
                //var geometry = this.geometryInternal as MeshGeometry3D;
                var positions   = geometry.Positions.GetEnumerator();
                var vertexCount = geometry.Positions.Count;

                var normals = geometry.Normals != null?geometry.Normals.GetEnumerator() : Enumerable.Repeat(Vector3.Zero, vertexCount).GetEnumerator();

                var tangents = geometry.Tangents != null?geometry.Tangents.GetEnumerator() : Enumerable.Repeat(Vector3.Zero, vertexCount).GetEnumerator();

                var bitangents = geometry.BiTangents != null?geometry.BiTangents.GetEnumerator() : Enumerable.Repeat(Vector3.Zero, vertexCount).GetEnumerator();

                var array = ThreadBufferManager <DefaultVertex> .GetBuffer(vertexCount);

                for (var i = 0; i < vertexCount; i++)
                {
                    positions.MoveNext();
                    normals.MoveNext();
                    tangents.MoveNext();
                    bitangents.MoveNext();
                    array[i].Position  = new Vector4(positions.Current, 1f);
                    array[i].Normal    = normals.Current;
                    array[i].Tangent   = tangents.Current;
                    array[i].BiTangent = bitangents.Current;
                }
                normals.Dispose();
                tangents.Dispose();
                bitangents.Dispose();
                positions.Dispose();
                return(array);
            }
コード例 #2
0
            /// <summary>
            /// Called when [build vertex array].
            /// </summary>
            /// <param name="geometry">The geometry.</param>
            /// <returns></returns>
            private PointsVertex[] OnBuildVertexArray(Geometry3D geometry)
            {
                var positions   = geometry.Positions;
                var vertexCount = geometry.Positions.Count;
                var array       = ThreadBufferManager <PointsVertex> .GetBuffer(vertexCount);

                var colors = geometry.Colors != null?geometry.Colors.GetEnumerator() : Enumerable.Repeat(Color4.White, vertexCount).GetEnumerator();

                for (var i = 0; i < vertexCount; i++)
                {
                    colors.MoveNext();
                    array[i].Position = new Vector4(positions[i], 1f);
                    array[i].Color    = colors.Current;
                }
                colors.Dispose();
                return(array);
            }