private DynamoMeshVertex[] CreateVertexArray() { var geometry = (MeshGeometry3D)Geometry; var colors = geometry.Colors != null?geometry.Colors.ToArray() : null; var textureCoordinates = geometry.TextureCoordinates != null?geometry.TextureCoordinates.ToArray() : null; var texScale = TextureCoodScale; var normals = geometry.Normals != null?geometry.Normals.ToArray() : null; var tangents = geometry.Tangents != null?geometry.Tangents.ToArray() : null; var bitangents = geometry.BiTangents != null?geometry.BiTangents.ToArray() : null; var positions = geometry.Positions.ToArray(); var vertexCount = geometry.Positions.Count; var result = new DynamoMeshVertex[vertexCount]; for (var i = 0; i < vertexCount; i++) { result[i] = new DynamoMeshVertex { Position = new Vector4(positions[i], 1f), Color = colors != null ? colors[i] : Color4.White, TexCoord = textureCoordinates != null ? texScale * textureCoordinates[i] : Vector2.Zero, Normal = normals != null ? normals[i] : Vector3.Zero, Tangent = tangents != null ? tangents[i] : Vector3.Zero, BiTangent = bitangents != null ? bitangents[i] : Vector3.Zero, Parameters = new Vector4((bool)GetValue(AttachedProperties.ShowSelectedProperty) ? 1 : 0, RequiresPerVertexColoration ? 1 : 0, 0, 0) }; } return(result); }
private DynamoMeshVertex[] CreateVertexArray() { var geometry = (MeshGeometry3D)Geometry; var colors = geometry.Colors != null ? geometry.Colors.ToArray() : null; var textureCoordinates = geometry.TextureCoordinates != null ? geometry.TextureCoordinates.ToArray() : null; var texScale = TextureCoodScale; var normals = geometry.Normals != null ? geometry.Normals.ToArray() : null; var tangents = geometry.Tangents != null ? geometry.Tangents.ToArray() : null; var bitangents = geometry.BiTangents != null ? geometry.BiTangents.ToArray() : null; var positions = geometry.Positions.ToArray(); var vertexCount = geometry.Positions.Count; var result = new DynamoMeshVertex[vertexCount]; for (var i = 0; i < vertexCount; i++) { result[i] = new DynamoMeshVertex { Position = new Vector4(positions[i], 1f), Color = colors != null ? colors[i] : Color4.White, TexCoord = textureCoordinates != null ? texScale * textureCoordinates[i] : Vector2.Zero, Normal = normals != null ? normals[i] : Vector3.Zero, Tangent = tangents != null ? tangents[i] : Vector3.Zero, BiTangent = bitangents != null ? bitangents[i] : Vector3.Zero, Parameters = new Vector4((bool)GetValue(AttachedProperties.ShowSelectedProperty) ? 1 : 0, RequiresPerVertexColoration ? 1 : 0,0,0) }; } return result; }