port from perforce
This commit is contained in:
63
intromat/Intromat/Views/Previews/DxMeshPreview.xaml.cs
Normal file
63
intromat/Intromat/Views/Previews/DxMeshPreview.xaml.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Reactive.Disposables;
|
||||
using Intromat.Graphics;
|
||||
using Intromat.Pipelines;
|
||||
using Intromat.ViewModels;
|
||||
using Intromat.ViewModels.Previews;
|
||||
using ReactiveUI;
|
||||
using SharpDX.Direct3D11;
|
||||
using Splat;
|
||||
|
||||
namespace Intromat.Views.Previews
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for DxMeshPreview.xaml
|
||||
/// </summary>
|
||||
public partial class DxMeshPreview : IViewFor<DxMeshPreviewViewModel>
|
||||
{
|
||||
private DisplayMeshPipeline? _pipeline;
|
||||
|
||||
public DxMeshPreview()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
MouseDoubleClick += (_, _) =>
|
||||
{
|
||||
if (ViewModel == null)
|
||||
return;
|
||||
|
||||
var network = (CodeGenNetworkViewModel)ViewModel.Parent.Parent;
|
||||
var main = network.Document.MainViewModel;
|
||||
main.Preview3dContext = ViewModel;
|
||||
};
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
_pipeline = Locator.Current.GetService<DisplayMeshPipeline>()!;
|
||||
this.WhenAnyObservable(v => v.ViewModel!.MeshValue).Subscribe(meshValue =>
|
||||
{
|
||||
//var srv = meshValue?.ShaderResourceView;
|
||||
//if (srv != null)
|
||||
//{
|
||||
// _pipeline.ShaderResourceView = srv;
|
||||
// _dxView.Render();
|
||||
//}
|
||||
}).DisposeWith(d);
|
||||
_dxView.SetUpdateHandler(UpdateFrameAction);
|
||||
});
|
||||
}
|
||||
|
||||
private void UpdateFrameAction(Device device, DeviceContext context)
|
||||
{
|
||||
_pipeline?.Apply();
|
||||
}
|
||||
|
||||
object? IViewFor.ViewModel
|
||||
{
|
||||
get => ViewModel;
|
||||
set => ViewModel = (DxMeshPreviewViewModel?)value;
|
||||
}
|
||||
|
||||
public DxMeshPreviewViewModel? ViewModel { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user