-
-
Notifications
You must be signed in to change notification settings - Fork 655
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1673 from helix-toolkit/release/2.20.0
Release/2.20.0
- Loading branch information
Showing
55 changed files
with
951 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Application x:Class="PointsAndLinesBinding.App" | ||
xmlns="http:https://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http:https://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:DynamicPointsAndLines" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> |
11 changes: 11 additions & 0 deletions
11
Source/Examples/SharpDX.Core/DynamicPointsAndLines/App.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Windows; | ||
|
||
namespace DynamicPointsAndLines | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Source/Examples/SharpDX.Core/DynamicPointsAndLines/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Windows; | ||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] |
14 changes: 14 additions & 0 deletions
14
Source/Examples/SharpDX.Core/DynamicPointsAndLines/DynamicPointsAndLines.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<UseWPF>true</UseWPF> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\HelixToolkit.SharpDX.Core.Assimp\HelixToolkit.SharpDX.Core.Assimp.csproj" /> | ||
<ProjectReference Include="..\..\..\HelixToolkit.SharpDX.Core.Wpf\HelixToolkit.SharpDX.Core.Wpf.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
176 changes: 176 additions & 0 deletions
176
Source/Examples/SharpDX.Core/DynamicPointsAndLines/MainViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="MainViewModel.cs" company="Helix Toolkit"> | ||
// Copyright (c) 2021 Helix Toolkit contributors | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using HelixToolkit.Wpf.SharpDX; | ||
using Point3D = System.Windows.Media.Media3D.Point3D; | ||
using Transform3D = System.Windows.Media.Media3D.Transform3D; | ||
using TranslateTransform3D = System.Windows.Media.Media3D.TranslateTransform3D; | ||
using Vector3D = System.Windows.Media.Media3D.Vector3D; | ||
using Color = System.Windows.Media.Color; | ||
using Vector3 = SharpDX.Vector3; | ||
using Colors = System.Windows.Media.Colors; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using HelixToolkit.SharpDX.Core; | ||
using System.ComponentModel; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace DynamicPointsAndLines | ||
{ | ||
public class MainViewModel : INotifyPropertyChanged, IDisposable | ||
{ | ||
#region INotifyPropertyChanged Support | ||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
protected void OnPropertyChanged([CallerMemberName] string info = "") => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(info)); | ||
|
||
protected bool SetValue<T>(ref T backingField, T value, [CallerMemberName] string propertyName = "") | ||
{ | ||
if (object.Equals(backingField, value)) | ||
{ | ||
return false; | ||
} | ||
|
||
backingField = value; | ||
this.OnPropertyChanged(propertyName); | ||
return true; | ||
} | ||
#endregion | ||
|
||
#region IDisposable Support | ||
private bool disposedValue = false; // To detect redundant calls | ||
|
||
protected virtual void Dispose(bool disposing) | ||
{ | ||
if (!disposedValue) | ||
{ | ||
if (disposing) | ||
{ | ||
// TODO: dispose managed state (managed objects). | ||
} | ||
|
||
// TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. | ||
// TODO: set large fields to null. | ||
if (EffectsManager != null) | ||
{ | ||
var effectManager = EffectsManager as IDisposable; | ||
Disposer.RemoveAndDispose(ref effectManager); | ||
} | ||
disposedValue = true; | ||
GC.SuppressFinalize(this); | ||
} | ||
} | ||
|
||
// TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources. | ||
~MainViewModel() | ||
{ | ||
// Do not change this code. Put cleanup code in Dispose(bool disposing) above. | ||
Dispose(false); | ||
} | ||
|
||
// This code added to correctly implement the disposable pattern. | ||
public void Dispose() | ||
{ | ||
// Do not change this code. Put cleanup code in Dispose(bool disposing) above. | ||
Dispose(true); | ||
// TODO: uncomment the following line if the finalizer is overridden above. | ||
// GC.SuppressFinalize(this); | ||
} | ||
#endregion | ||
|
||
public LineGeometry3D Lines { get; } | ||
public PointGeometry3D Points { get; } | ||
public Transform3D Lines1Transform { get; } | ||
public Transform3D Lines2Transform { get; } | ||
public Transform3D Points1Transform { get; } | ||
public Vector3D DirectionalLightDirection { get; } | ||
public Color DirectionalLightColor { get; } | ||
public Color AmbientLightColor { get; } | ||
public Stopwatch StopWatch { get; } | ||
|
||
public IEffectsManager EffectsManager { get; } | ||
public Camera Camera { get; } | ||
|
||
private int numberOfPoints; | ||
public int NumberOfPoints | ||
{ | ||
get => numberOfPoints; | ||
set | ||
{ | ||
StopWatch.Stop(); | ||
|
||
SetValue(ref numberOfPoints, value); | ||
Lines.Indices = new IntCollection(numberOfPoints * 2); | ||
for (int i = 0; i < numberOfPoints * 2; i++) | ||
{ | ||
Lines.Indices.Add(i); | ||
} | ||
|
||
StopWatch.Start(); | ||
} | ||
} | ||
|
||
public MainViewModel() | ||
{ | ||
EffectsManager = new DefaultEffectsManager(); | ||
Camera = new PerspectiveCamera | ||
{ | ||
Position = new Point3D(-90, 0, 95), | ||
LookDirection = new Vector3D(110, 0, -105), | ||
UpDirection = new Vector3D(0, 1, 0) | ||
}; | ||
|
||
// setup lighting | ||
AmbientLightColor = Colors.DimGray; | ||
DirectionalLightColor = Colors.White; | ||
DirectionalLightDirection = new Vector3D(-2, -5, -2); | ||
|
||
// model trafos | ||
Lines1Transform = new TranslateTransform3D(0, 0, 45); | ||
Lines2Transform = new TranslateTransform3D(0, 0, -45); | ||
Points1Transform = new TranslateTransform3D(0, 0, 0); | ||
|
||
Lines = new LineGeometry3D { IsDynamic = true }; | ||
Points = new PointGeometry3D { IsDynamic = true }; | ||
|
||
StopWatch = new Stopwatch(); | ||
StopWatch.Start(); | ||
|
||
NumberOfPoints = 900; | ||
} | ||
|
||
public void UpdatePoints() | ||
{ | ||
if (StopWatch.IsRunning) | ||
{ | ||
var vectors = new Vector3Collection(GeneratePoints(NumberOfPoints, StopWatch.ElapsedMilliseconds * 0.003)); | ||
Points.Positions = vectors; | ||
Lines.Positions = vectors; | ||
} | ||
} | ||
|
||
private static IEnumerable<Vector3> GeneratePoints(int n, double time) | ||
{ | ||
const double R = 30; | ||
const double Q = 5; | ||
for (int i = 0; i < n; i++) | ||
{ | ||
double t = Math.PI * 2 * i / (n - 1); | ||
double u = (t * 24) + (time * 5); | ||
var pt = new Vector3( | ||
(float)(Math.Cos(t) * (R + (Q * Math.Cos(u)))), | ||
(float)(Math.Sin(t) * (R + (Q * Math.Cos(u)))), | ||
(float)(Q * Math.Sin(u))); | ||
yield return pt; | ||
if (i > 0 && i < n - 1) | ||
{ | ||
yield return pt; | ||
} | ||
} | ||
} | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
Source/Examples/SharpDX.Core/DynamicPointsAndLines/MainWindow.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<Window x:Class="DynamicPointsAndLines.MainWindow" | ||
xmlns="http:https://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http:https://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http:https://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http:https://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:DynamicPointsAndLines" | ||
xmlns:hx="http:https://helix-toolkit.org/wpf/SharpDX" | ||
Title="DynamicPointsAndLines" | ||
Width="640" | ||
Height="480" | ||
d:DataContext="{d:DesignInstance local:MainViewModel}" | ||
mc:Ignorable="d" | ||
> | ||
<DockPanel> | ||
<DockPanel DockPanel.Dock="Bottom"> | ||
<StatusBar VerticalAlignment="Bottom"> | ||
<StatusBar.Background> | ||
<SolidColorBrush Opacity="0.5" Color="WhiteSmoke" /> | ||
</StatusBar.Background> | ||
<StatusBarItem> | ||
<TextBlock | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Top" | ||
Text="{Binding FrameRate, ElementName=view1, StringFormat=D3D11 - \{0:0.00\} FPS}" /> | ||
</StatusBarItem> | ||
<Separator /> | ||
<StatusBarItem> | ||
<TextBlock Text="{Binding Camera.Position, StringFormat=Position: \{0:0.0\}}" /> | ||
</StatusBarItem> | ||
<Separator /> | ||
<StatusBarItem> | ||
<TextBlock Text="{Binding Camera.LookDirection, StringFormat=LookDirection: \{0:0.0\}}" /> | ||
</StatusBarItem> | ||
<Separator /> | ||
<StatusBarItem> | ||
<TextBlock Text="{Binding Camera.UpDirection, StringFormat=UpDirection: \{0:0.0\}}" /> | ||
</StatusBarItem> | ||
<Separator /> | ||
<StatusBarItem> | ||
<TextBlock Text="{Binding Items.Count, ElementName=view1, StringFormat=Children: \{0\}}" /> | ||
</StatusBarItem> | ||
</StatusBar> | ||
</DockPanel> | ||
<DockPanel DockPanel.Dock="Bottom"> | ||
<TextBlock Width="80" Margin="2" | ||
DockPanel.Dock="Left" | ||
Text="{Binding NumberOfPoints, StringFormat='N = {0}'}" | ||
TextAlignment="Center" | ||
/> | ||
<Slider Margin="2" LargeChange="100" | ||
Maximum="10000" Minimum="75" | ||
SmallChange="1" | ||
Value="{Binding NumberOfPoints}" | ||
/> | ||
</DockPanel> | ||
<hx:Viewport3DX | ||
x:Name="view1" | ||
Camera="{Binding Camera}" | ||
EffectsManager="{Binding EffectsManager}" | ||
Title="Dynamic Points and Lines" | ||
SubTitle="change number of points and check FPS" | ||
ShowCoordinateSystem="True" | ||
CoordinateSystemLabelForeground="OrangeRed" | ||
TextBrush="Black" | ||
UseDefaultGestures="False"> | ||
<hx:Viewport3DX.InputBindings> | ||
<KeyBinding Key="B" Command="hx:ViewportCommands.BackView" /> | ||
<KeyBinding Key="F" Command="hx:ViewportCommands.FrontView" /> | ||
<KeyBinding Key="U" Command="hx:ViewportCommands.TopView" /> | ||
<KeyBinding Key="D" Command="hx:ViewportCommands.BottomView" /> | ||
<KeyBinding Key="L" Command="hx:ViewportCommands.LeftView" /> | ||
<KeyBinding Key="R" Command="hx:ViewportCommands.RightView" /> | ||
<KeyBinding Command="hx:ViewportCommands.ZoomExtents" Gesture="Control+E" /> | ||
<MouseBinding Command="hx:ViewportCommands.Rotate" Gesture="RightClick" /> | ||
<MouseBinding Command="hx:ViewportCommands.Zoom" Gesture="MiddleClick" /> | ||
<MouseBinding Command="hx:ViewportCommands.Pan" Gesture="LeftClick" /> | ||
</hx:Viewport3DX.InputBindings> | ||
<hx:AmbientLight3D Color="{Binding AmbientLightColor}" /> | ||
<hx:DirectionalLight3D Direction="{Binding DirectionalLightDirection}" Color="{Binding DirectionalLightColor}" /> | ||
|
||
<hx:LineGeometryModel3D | ||
Geometry="{Binding Lines}" | ||
Transform="{Binding Lines1Transform}" | ||
FixedSize="True" | ||
IsRendering="True" | ||
Smoothness="1.0" | ||
Thickness="1.0" | ||
Color="Green" /> | ||
|
||
<hx:LineGeometryModel3D | ||
Geometry="{Binding Lines}" | ||
Transform="{Binding Lines2Transform}" | ||
FixedSize="False" | ||
IsRendering="True" | ||
Smoothness="1.0" | ||
Thickness="0.2" | ||
Color="Blue" /> | ||
|
||
<hx:PointGeometryModel3D | ||
Geometry="{Binding Points}" | ||
Transform="{Binding Points1Transform}" | ||
IsRendering="True" | ||
FixedSize="True" | ||
Size="5.5, 1.5" | ||
Color="Red" /> | ||
|
||
</hx:Viewport3DX> | ||
</DockPanel> | ||
</Window> |
Oops, something went wrong.