本文整理汇总了C#中System.ComponentModel.Model.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Model.Add方法的具体用法?C# Model.Add怎么用?C# Model.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.Model
的用法示例。
在下文中一共展示了Model.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: selectFilesButton_Click
private void selectFilesButton_Click(object sender, RoutedEventArgs e)
{
this.setTranslatedTitle("SelectFiles");
flipper.SwitchControl(selectFilesGroup);
choosePathButton.Visibility = System.Windows.Visibility.Collapsed;
selectFilesButton.Visibility = System.Windows.Visibility.Collapsed;
otherUserButton.Visibility = System.Windows.Visibility.Collapsed;
restoreButton.Visibility = System.Windows.Visibility.Visible;
files = new Model<SelectFile>();
foreach (string file in restore.archive.file_list) {
files.Add(new SelectFile(file));
}
ICollectionView files_list_view = System.Windows.Data.CollectionViewSource.GetDefaultView(files);
files_list_view.SortDescriptions.Clear();
files_list_view.SortDescriptions.Add(new SortDescription("name", ListSortDirection.Ascending));
listView1.DataContext = files;
}
示例2: Generate
//.........这里部分代码省略.........
if (LocalOffset != Vector3.Zero)
{
for (var index = 0; index < data.Vertices.Length; index++)
{
data.Vertices[index].Position += LocalOffset;
}
}
//Scale if necessary
if (Scale != Vector3.One)
{
var inverseMatrix = Matrix.Scaling(Scale);
inverseMatrix.Invert();
for (var index = 0; index < data.Vertices.Length; index++)
{
data.Vertices[index].Position *= Scale;
Vector3.TransformCoordinate(ref data.Vertices[index].Normal, ref inverseMatrix, out data.Vertices[index].Normal);
}
}
var boundingBox = BoundingBox.Empty;
for (int i = 0; i < data.Vertices.Length; i++)
BoundingBox.Merge(ref boundingBox, ref data.Vertices[i].Position, out boundingBox);
BoundingSphere boundingSphere;
unsafe
{
fixed (void* verticesPtr = data.Vertices)
BoundingSphere.FromPoints((IntPtr)verticesPtr, 0, data.Vertices.Length, VertexPositionNormalTexture.Size, out boundingSphere);
}
var originalLayout = data.Vertices[0].GetLayout();
// Generate Tangent/BiNormal vectors
var resultWithTangentBiNormal = VertexHelper.GenerateTangentBinormal(originalLayout, data.Vertices, data.Indices);
// Generate Multitexcoords
var result = VertexHelper.GenerateMultiTextureCoordinates(resultWithTangentBiNormal);
var meshDraw = new MeshDraw();
var layout = result.Layout;
var vertexBuffer = result.VertexBuffer;
var indices = data.Indices;
if (indices.Length < 0xFFFF)
{
var indicesShort = new ushort[indices.Length];
for (int i = 0; i < indicesShort.Length; i++)
{
indicesShort[i] = (ushort)indices[i];
}
meshDraw.IndexBuffer = new IndexBufferBinding(Buffer.Index.New(graphicsDevice, indicesShort).RecreateWith(indicesShort), false, indices.Length);
if (needsTempDevice)
{
var indexData = BufferData.New(BufferFlags.IndexBuffer, indicesShort);
meshDraw.IndexBuffer = new IndexBufferBinding(indexData.ToSerializableVersion(), false, indices.Length);
}
}
else
{
if (graphicsDevice.Features.CurrentProfile <= GraphicsProfile.Level_9_3)
{
throw new InvalidOperationException("Cannot generate more than 65535 indices on feature level HW <= 9.3");
}
meshDraw.IndexBuffer = new IndexBufferBinding(Buffer.Index.New(graphicsDevice, indices).RecreateWith(indices), true, indices.Length);
if (needsTempDevice)
{
var indexData = BufferData.New(BufferFlags.IndexBuffer, indices);
meshDraw.IndexBuffer = new IndexBufferBinding(indexData.ToSerializableVersion(), true, indices.Length);
}
}
meshDraw.VertexBuffers = new[] { new VertexBufferBinding(Buffer.New(graphicsDevice, vertexBuffer, BufferFlags.VertexBuffer).RecreateWith(vertexBuffer), layout, data.Vertices.Length) };
if (needsTempDevice)
{
var vertexData = BufferData.New(BufferFlags.VertexBuffer, vertexBuffer);
meshDraw.VertexBuffers = new[] { new VertexBufferBinding(vertexData.ToSerializableVersion(), layout, data.Vertices.Length) };
}
meshDraw.DrawCount = indices.Length;
meshDraw.PrimitiveType = PrimitiveType.TriangleList;
var mesh = new Mesh { Draw = meshDraw, BoundingBox = boundingBox, BoundingSphere = boundingSphere };
model.BoundingBox = boundingBox;
model.BoundingSphere = boundingSphere;
model.Add(mesh);
if (MaterialInstance?.Material != null)
{
model.Materials.Add(MaterialInstance);
}
if (needsTempDevice)
{
graphicsDevice.Dispose();
}
}