├── 3DTools ├── 3DTools │ ├── README.txt │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── ViewMode.cs │ ├── Trackport3D.xaml │ ├── Matrix3DStack.cs │ ├── Trackport3D.xaml.cs │ ├── 3DTools.csproj │ ├── TrackballDecorator.cs │ ├── Trackball.cs │ ├── ScreenSpaceLines3D.cs │ └── MeshUtils.cs ├── Samples │ ├── ModelViewer │ │ ├── CommandLineArguments.cs │ │ ├── Sample Models │ │ │ └── Tiger.bmp │ │ ├── app.config │ │ ├── Properties │ │ │ ├── Settings.settings │ │ │ ├── Settings.Designer.cs │ │ │ ├── AssemblyInfo.cs │ │ │ ├── Resources.Designer.cs │ │ │ └── Resources.resx │ │ ├── MyApp.xaml │ │ ├── MainWindow.xaml │ │ ├── MyApp.xaml.cs │ │ ├── MainWindow.xaml.cs │ │ └── ModelViewer.csproj │ ├── GeneratedTextureCoordinatesDemo │ │ ├── test.png │ │ ├── app.config │ │ ├── Properties │ │ │ ├── Settings.settings │ │ │ ├── Settings.Designer.cs │ │ │ ├── AssemblyInfo.cs │ │ │ ├── Resources.Designer.cs │ │ │ └── Resources.resx │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── Window1.xaml.cs │ │ └── GeneratedTextureCoordinatesDemo.csproj │ ├── Channel9Demo │ │ ├── app.config │ │ ├── Properties │ │ │ ├── Settings.settings │ │ │ ├── Settings.Designer.cs │ │ │ ├── AssemblyInfo.cs │ │ │ ├── Resources.Designer.cs │ │ │ └── Resources.resx │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── DemoWindow.xaml.cs │ │ ├── Channel9Demo.csproj │ │ └── DemoWindow.xaml │ └── InteractiveViewport3DSample │ │ ├── app.config │ │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── Window1.xaml.cs │ │ ├── InteractiveCylinder.cs │ │ ├── InteractiveCone.cs │ │ ├── InteractiveSphere.cs │ │ ├── InteractiveViewport3DSample.csproj │ │ └── Window1.xaml ├── 3DTools.sln └── .gitignore ├── readme.md └── BuildProcessTemplates └── UpgradeTemplate.xaml /3DTools/3DTools/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Siyy/3DTools/HEAD/3DTools/3DTools/README.txt -------------------------------------------------------------------------------- /3DTools/Samples/ModelViewer/CommandLineArguments.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Siyy/3DTools/HEAD/3DTools/Samples/ModelViewer/CommandLineArguments.cs -------------------------------------------------------------------------------- /3DTools/Samples/ModelViewer/Sample Models/Tiger.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Siyy/3DTools/HEAD/3DTools/Samples/ModelViewer/Sample Models/Tiger.bmp -------------------------------------------------------------------------------- /3DTools/Samples/GeneratedTextureCoordinatesDemo/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Siyy/3DTools/HEAD/3DTools/Samples/GeneratedTextureCoordinatesDemo/test.png -------------------------------------------------------------------------------- /3DTools/Samples/ModelViewer/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /3DTools/Samples/Channel9Demo/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /3DTools/Samples/GeneratedTextureCoordinatesDemo/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /3DTools/Samples/InteractiveViewport3DSample/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /3DTools/3DTools/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /3DTools/Samples/ModelViewer/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /3DTools/Samples/Channel9Demo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /3DTools/Samples/GeneratedTextureCoordinatesDemo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /3DTools/Samples/InteractiveViewport3DSample/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /3DTools/Samples/GeneratedTextureCoordinatesDemo/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /3DTools/Samples/GeneratedTextureCoordinatesDemo/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Data; 4 | using System.Xml; 5 | using System.Configuration; 6 | 7 | namespace GeneratedTextureCoordinatesDemo 8 | { 9 | /// 10 | /// Interaction logic for App.xaml 11 | /// 12 | 13 | public partial class App : System.Windows.Application 14 | { 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 3DTools 2 | == 3 | 4 | 这又是一个原来在 CodePlex 上重要的WPF纯托管的3D工具库项目。 5 | 6 | 现在也是是好像长期无人过问了。这么好的东西门口罗雀甚为可惜,因此将原来的库从 SVN 导入到 Git 以便给大家更好的访问平台。 7 | 8 | 一切权力属于原作者,如果作者禁止授权,则将删除。 9 | 10 | 此版本库此分支是从 SVN 直接导入的未改动原库,因 SVN 的库使用习惯,其中存在大量的二进制文件导致下载数据量较大。因此准备在配置好代码后,将新开一个库作为纯源代码的库的起点。 11 | 12 | 在此,也欢迎有兴趣的同学一起参与汉化和继续的开发工作。 13 | 14 | 协作地址: 15 | https://github.com/Siyy/3DTools 16 | https://gitee.com/Siyy/Wpf3DTools 17 | 18 | 19 | -------------------------------------------------------------------------------- /3DTools/Samples/GeneratedTextureCoordinatesDemo/Window1.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | using System.Windows.Data; 7 | using System.Windows.Documents; 8 | using System.Windows.Input; 9 | using System.Windows.Media; 10 | using System.Windows.Media.Imaging; 11 | using System.Windows.Shapes; 12 | 13 | 14 | namespace GeneratedTextureCoordinatesDemo 15 | { 16 | /// 17 | /// Interaction logic for Window1.xaml 18 | /// 19 | 20 | public partial class Window1 : System.Windows.Window 21 | { 22 | 23 | public Window1() 24 | { 25 | InitializeComponent(); 26 | } 27 | 28 | } 29 | } -------------------------------------------------------------------------------- /3DTools/3DTools/ViewMode.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | //--------------------------------------------------------------------------- 14 | 15 | using System; 16 | 17 | namespace _3DTools 18 | { 19 | public enum ViewMode 20 | { 21 | Solid, 22 | Wireframe 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /3DTools/Samples/ModelViewer/MyApp.xaml: -------------------------------------------------------------------------------- 1 | 14 | 15 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /3DTools/Samples/Channel9Demo/App.xaml: -------------------------------------------------------------------------------- 1 | 14 | 15 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /3DTools/Samples/InteractiveViewport3DSample/App.xaml: -------------------------------------------------------------------------------- 1 | 14 | 15 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /3DTools/Samples/Channel9Demo/App.xaml.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | //--------------------------------------------------------------------------- 14 | 15 | using System; 16 | using System.Windows; 17 | using System.Data; 18 | using System.Xml; 19 | using System.Configuration; 20 | 21 | namespace Channel9Demo 22 | { 23 | /// 24 | /// Interaction logic for App.xaml 25 | /// 26 | 27 | public partial class App : System.Windows.Application 28 | { 29 | 30 | } 31 | } -------------------------------------------------------------------------------- /3DTools/Samples/InteractiveViewport3DSample/App.xaml.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | //--------------------------------------------------------------------------- 14 | 15 | using System; 16 | using System.Windows; 17 | using System.Data; 18 | using System.Xml; 19 | using System.Configuration; 20 | 21 | namespace InteractiveViewport3DSample 22 | { 23 | /// 24 | /// Interaction logic for App.xaml 25 | /// 26 | 27 | public partial class App : System.Windows.Application 28 | { 29 | 30 | } 31 | } -------------------------------------------------------------------------------- /3DTools/3DTools/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace _3DTools.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /3DTools/Samples/ModelViewer/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ModelViewer.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /3DTools/Samples/Channel9Demo/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Channel9Demo.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /3DTools/Samples/InteractiveViewport3DSample/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace InteractiveViewport3DSample.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /3DTools/Samples/GeneratedTextureCoordinatesDemo/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace GeneratedTextureCoordinatesDemo.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /3DTools/Samples/Channel9Demo/DemoWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | //--------------------------------------------------------------------------- 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Text; 18 | using System.Windows; 19 | using System.Windows.Controls; 20 | using System.Windows.Data; 21 | using System.Windows.Documents; 22 | using System.Windows.Input; 23 | using System.Windows.Media; 24 | using System.Windows.Media.Imaging; 25 | using System.Windows.Shapes; 26 | 27 | namespace Channel9Demo 28 | { 29 | /// 30 | /// Interaction logic for DemoWindow.xaml 31 | /// 32 | 33 | public partial class DemoWindow : System.Windows.Window 34 | { 35 | 36 | public DemoWindow() 37 | { 38 | InitializeComponent(); 39 | } 40 | 41 | } 42 | } -------------------------------------------------------------------------------- /3DTools/Samples/InteractiveViewport3DSample/Window1.xaml.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | //--------------------------------------------------------------------------- 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Text; 18 | using System.Windows; 19 | using System.Windows.Controls; 20 | using System.Windows.Data; 21 | using System.Windows.Documents; 22 | using System.Windows.Input; 23 | using System.Windows.Media; 24 | using System.Windows.Media.Imaging; 25 | using System.Windows.Shapes; 26 | using System.Windows.Markup; 27 | using System.IO; 28 | using System.Windows.Media.Media3D; 29 | using System.Globalization; 30 | 31 | 32 | namespace InteractiveViewport3DSample 33 | { 34 | /// 35 | /// Interaction logic for Window1.xaml 36 | /// 37 | 38 | public partial class Window1 : System.Windows.Window 39 | { 40 | 41 | public Window1() 42 | { 43 | InitializeComponent(); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /3DTools/Samples/ModelViewer/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /3DTools/Samples/ModelViewer/MyApp.xaml.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | //--------------------------------------------------------------------------- 14 | 15 | using CommandLine; 16 | using System; 17 | using System.Diagnostics; 18 | using System.IO; 19 | using System.Windows; 20 | 21 | namespace ModelViewer 22 | { 23 | /// 24 | /// Interaction logic for MyApp.xaml 25 | /// 26 | 27 | public partial class MyApp : Application 28 | { 29 | class Arguments 30 | { 31 | [DefaultArgument(ArgumentType.AtMostOnce, HelpText = "")] 32 | public string Filename = null; 33 | } 34 | 35 | 36 | void OnStartup(object sender, StartupEventArgs e) 37 | { 38 | Arguments parsedArgs = new Arguments(); 39 | 40 | if (Parser.ParseArgumentsWithUsage(e.Args, parsedArgs)) 41 | { 42 | MainWindow mainWindow = new MainWindow(); 43 | mainWindow.Show(); 44 | 45 | if (parsedArgs.Filename != null) 46 | { 47 | mainWindow.Load(parsedArgs.Filename); 48 | } 49 | } 50 | } 51 | 52 | internal static void StartupError(string errorMsg) 53 | { 54 | MessageBox.Show(errorMsg, "Error", MessageBoxButton.OK, MessageBoxImage.Error); 55 | 56 | Application.Current.Shutdown(); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /3DTools/Samples/Channel9Demo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | using System.Resources; 6 | using System.Globalization; 7 | using System.Windows; 8 | using System.Runtime.InteropServices; 9 | 10 | #endregion 11 | 12 | // General Information about an assembly is controlled through the following 13 | // set of attributes. Change these attribute values to modify the information 14 | // associated with an assembly. 15 | [assembly: AssemblyTitle("Channel9Demo")] 16 | [assembly: AssemblyDescription("")] 17 | [assembly: AssemblyConfiguration("")] 18 | [assembly: AssemblyCompany("Microsoft")] 19 | [assembly: AssemblyProduct("Channel9Demo")] 20 | [assembly: AssemblyCopyright("Copyright @ Microsoft 2006")] 21 | [assembly: AssemblyTrademark("")] 22 | [assembly: AssemblyCulture("")] 23 | [assembly: ComVisible(false)] 24 | 25 | //In order to begin building localizable applications, set 26 | //CultureYouAreCodingWith in your .csproj file 27 | //inside a . For example, if you are using US english 28 | //in your source files, set the to en-US. Then uncomment 29 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 30 | //the line below to match the UICulture setting in the project file. 31 | 32 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 33 | 34 | 35 | [assembly: ThemeInfo( 36 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 37 | //(used if a resource is not found in the page, 38 | // or application resource dictionaries) 39 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 40 | //(used if a resource is not found in the page, 41 | // app, or any theme specific resource dictionaries) 42 | )] 43 | 44 | 45 | // Version information for an assembly consists of the following four values: 46 | // 47 | // Major Version 48 | // Minor Version 49 | // Build Number 50 | // Revision 51 | // 52 | // You can specify all the values or you can default the Revision and Build Numbers 53 | // by using the '*' as shown below: 54 | [assembly: AssemblyVersion("1.0.*")] 55 | -------------------------------------------------------------------------------- /3DTools/Samples/ModelViewer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | using System.Resources; 6 | using System.Globalization; 7 | using System.Windows; 8 | using System.Runtime.InteropServices; 9 | 10 | #endregion 11 | 12 | // General Information about an assembly is controlled through the following 13 | // set of attributes. Change these attribute values to modify the information 14 | // associated with an assembly. 15 | [assembly: AssemblyTitle("ModelViewer")] 16 | [assembly: AssemblyDescription("")] 17 | [assembly: AssemblyConfiguration("")] 18 | [assembly: AssemblyCompany("Microsoft")] 19 | [assembly: AssemblyProduct("WPF Model Viewer")] 20 | [assembly: AssemblyCopyright("Copyright @ Microsoft 2006")] 21 | [assembly: AssemblyTrademark("")] 22 | [assembly: AssemblyCulture("")] 23 | [assembly: ComVisible(false)] 24 | 25 | //In order to begin building localizable applications, set 26 | //CultureYouAreCodingWith in your .csproj file 27 | //inside a . For example, if you are using US english 28 | //in your source files, set the to en-US. Then uncomment 29 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 30 | //the line below to match the UICulture setting in the project file. 31 | 32 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 33 | 34 | 35 | [assembly: ThemeInfo( 36 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 37 | //(used if a resource is not found in the page, 38 | // or application resource dictionaries) 39 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 40 | //(used if a resource is not found in the page, 41 | // app, or any theme specific resource dictionaries) 42 | )] 43 | 44 | 45 | // Version information for an assembly consists of the following four values: 46 | // 47 | // Major Version 48 | // Minor Version 49 | // Build Number 50 | // Revision 51 | // 52 | // You can specify all the values or you can default the Revision and Build Numbers 53 | // by using the '*' as shown below: 54 | [assembly: AssemblyVersion("1.0.*")] 55 | -------------------------------------------------------------------------------- /3DTools/3DTools/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | using System.Resources; 6 | using System.Globalization; 7 | using System.Windows; 8 | using System.Runtime.InteropServices; 9 | 10 | #endregion 11 | 12 | // General Information about an assembly is controlled through the following 13 | // set of attributes. Change these attribute values to modify the information 14 | // associated with an assembly. 15 | [assembly: AssemblyTitle("3DTools")] 16 | [assembly: AssemblyDescription("")] 17 | [assembly: AssemblyConfiguration("")] 18 | [assembly: AssemblyCompany("Microsoft")] 19 | [assembly: AssemblyProduct("3D Tools for the Windows Presentation Foundation")] 20 | [assembly: AssemblyCopyright("Copyright @ Microsoft 2006")] 21 | [assembly: AssemblyTrademark("")] 22 | [assembly: AssemblyCulture("")] 23 | [assembly: ComVisible(false)] 24 | 25 | //In order to begin building localizable applications, set 26 | //CultureYouAreCodingWith in your .csproj file 27 | //inside a . For example, if you are using US english 28 | //in your source files, set the to en-US. Then uncomment 29 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 30 | //the line below to match the UICulture setting in the project file. 31 | 32 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 33 | 34 | 35 | [assembly: ThemeInfo( 36 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 37 | //(used if a resource is not found in the page, 38 | // or application resource dictionaries) 39 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 40 | //(used if a resource is not found in the page, 41 | // app, or any theme specific resource dictionaries) 42 | )] 43 | 44 | 45 | // Version information for an assembly consists of the following four values: 46 | // 47 | // Major Version 48 | // Minor Version 49 | // Build Number 50 | // Revision 51 | // 52 | // You can specify all the values or you can default the Revision and Build Numbers 53 | // by using the '*' as shown below: 54 | [assembly: AssemblyVersion("1.0.*")] 55 | -------------------------------------------------------------------------------- /3DTools/3DTools/Trackport3D.xaml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /3DTools/Samples/InteractiveViewport3DSample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | using System.Resources; 6 | using System.Globalization; 7 | using System.Windows; 8 | using System.Runtime.InteropServices; 9 | 10 | #endregion 11 | 12 | // General Information about an assembly is controlled through the following 13 | // set of attributes. Change these attribute values to modify the information 14 | // associated with an assembly. 15 | [assembly: AssemblyTitle("InteractiveViewport3DSample")] 16 | [assembly: AssemblyDescription("")] 17 | [assembly: AssemblyConfiguration("")] 18 | [assembly: AssemblyCompany("Microsoft")] 19 | [assembly: AssemblyProduct("InteractiveViewport3DSample")] 20 | [assembly: AssemblyCopyright("Copyright @ Microsoft 2006")] 21 | [assembly: AssemblyTrademark("")] 22 | [assembly: AssemblyCulture("")] 23 | [assembly: ComVisible(false)] 24 | 25 | //In order to begin building localizable applications, set 26 | //CultureYouAreCodingWith in your .csproj file 27 | //inside a . For example, if you are using US english 28 | //in your source files, set the to en-US. Then uncomment 29 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 30 | //the line below to match the UICulture setting in the project file. 31 | 32 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 33 | 34 | 35 | // Specifies the location in which theme dictionaries are stored for types in an assembly. 36 | [assembly: ThemeInfo( 37 | // Specifies the location of system theme-specific resource dictionaries for this project. 38 | // The default setting in this project is "None" since this default project does not 39 | // include these user-defined theme files: 40 | // Themes\Aero.NormalColor.xaml 41 | // Themes\Classic.xaml 42 | // Themes\Luna.Homestead.xaml 43 | // Themes\Luna.Metallic.xaml 44 | // Themes\Luna.NormalColor.xaml 45 | // Themes\Royale.NormalColor.xaml 46 | ResourceDictionaryLocation.None, 47 | 48 | // Specifies the location of the system non-theme specific resource dictionary: 49 | // Themes\generic.xaml 50 | ResourceDictionaryLocation.SourceAssembly)] 51 | 52 | 53 | // Version information for an assembly consists of the following four values: 54 | // 55 | // Major Version 56 | // Minor Version 57 | // Build Number 58 | // Revision 59 | // 60 | // You can specify all the values or you can default the Revision and Build Numbers 61 | // by using the '*' as shown below: 62 | [assembly: AssemblyVersion("1.0.*")] 63 | -------------------------------------------------------------------------------- /3DTools/Samples/GeneratedTextureCoordinatesDemo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | using System.Resources; 6 | using System.Globalization; 7 | using System.Windows; 8 | using System.Runtime.InteropServices; 9 | 10 | #endregion 11 | 12 | // General Information about an assembly is controlled through the following 13 | // set of attributes. Change these attribute values to modify the information 14 | // associated with an assembly. 15 | [assembly: AssemblyTitle("GeneratedTextureCoordinatesDemo")] 16 | [assembly: AssemblyDescription("")] 17 | [assembly: AssemblyConfiguration("")] 18 | [assembly: AssemblyCompany("MSIT")] 19 | [assembly: AssemblyProduct("GeneratedTextureCoordinatesDemo")] 20 | [assembly: AssemblyCopyright("Copyright @ MSIT 2006")] 21 | [assembly: AssemblyTrademark("")] 22 | [assembly: AssemblyCulture("")] 23 | [assembly: ComVisible(false)] 24 | 25 | //In order to begin building localizable applications, set 26 | //CultureYouAreCodingWith in your .csproj file 27 | //inside a . For example, if you are using US english 28 | //in your source files, set the to en-US. Then uncomment 29 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 30 | //the line below to match the UICulture setting in the project file. 31 | 32 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 33 | 34 | 35 | // Specifies the location in which theme dictionaries are stored for types in an assembly. 36 | [assembly: ThemeInfo( 37 | // Specifies the location of system theme-specific resource dictionaries for this project. 38 | // The default setting in this project is "None" since this default project does not 39 | // include these user-defined theme files: 40 | // Themes\Aero.NormalColor.xaml 41 | // Themes\Classic.xaml 42 | // Themes\Luna.Homestead.xaml 43 | // Themes\Luna.Metallic.xaml 44 | // Themes\Luna.NormalColor.xaml 45 | // Themes\Royale.NormalColor.xaml 46 | ResourceDictionaryLocation.None, 47 | 48 | // Specifies the location of the system non-theme specific resource dictionary: 49 | // Themes\generic.xaml 50 | ResourceDictionaryLocation.SourceAssembly)] 51 | 52 | 53 | // Version information for an assembly consists of the following four values: 54 | // 55 | // Major Version 56 | // Minor Version 57 | // Build Number 58 | // Revision 59 | // 60 | // You can specify all the values or you can default the Revision and Build Numbers 61 | // by using the '*' as shown below: 62 | [assembly: AssemblyVersion("1.0.*")] 63 | -------------------------------------------------------------------------------- /3DTools/3DTools/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace _3DTools.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("_3DTools.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /3DTools/Samples/ModelViewer/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ModelViewer.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ModelViewer.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /3DTools/Samples/Channel9Demo/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Channel9Demo.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Channel9Demo.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /3DTools/Samples/InteractiveViewport3DSample/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace InteractiveViewport3DSample.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("InteractiveViewport3DSample.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /3DTools/Samples/GeneratedTextureCoordinatesDemo/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace GeneratedTextureCoordinatesDemo.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GeneratedTextureCoordinatesDemo.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /3DTools/Samples/InteractiveViewport3DSample/InteractiveCylinder.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | //--------------------------------------------------------------------------- 14 | 15 | using System; 16 | using System.Windows; 17 | using System.Windows.Media; 18 | using System.Windows.Media.Media3D; 19 | using _3DTools; 20 | 21 | namespace InteractiveViewport3DSample 22 | { 23 | public class InteractiveCylinder : InteractiveVisual3D 24 | { 25 | public InteractiveCylinder() 26 | { 27 | Geometry = Tessellate(32, 32); 28 | } 29 | 30 | internal static Point3D GetPosition(double t, double y) 31 | { 32 | double x = Math.Cos(t); 33 | double z = Math.Sin(t); 34 | 35 | return new Point3D(x, y, z); 36 | } 37 | 38 | private static Vector3D GetNormal(double t, double y) 39 | { 40 | double x = Math.Cos(t); 41 | double z = Math.Sin(t); 42 | 43 | return new Vector3D(x, 0, z); 44 | } 45 | 46 | internal static double DegToRad(double degrees) 47 | { 48 | return (degrees / 180.0) * Math.PI; 49 | } 50 | 51 | private static Point GetTextureCoordinate(double t, double y) 52 | { 53 | return new Point(1.0 - t * 1 / (2 * Math.PI), y * -0.5 + 0.5); 54 | } 55 | 56 | internal static MeshGeometry3D Tessellate(int tDiv, int yDiv) 57 | { 58 | double maxTheta = DegToRad(360.0); 59 | double minY = -1.0; 60 | double maxY = 1.0; 61 | 62 | double dt = maxTheta / tDiv; 63 | double dy = (maxY - minY) / yDiv; 64 | 65 | MeshGeometry3D mesh = new MeshGeometry3D(); 66 | 67 | for (int yi = 0; yi <= yDiv; yi++) 68 | { 69 | double y = minY + yi * dy; 70 | 71 | for (int ti = 0; ti <= tDiv; ti++) 72 | { 73 | double t = ti * dt; 74 | 75 | mesh.Positions.Add(GetPosition(t, y)); 76 | mesh.Normals.Add(GetNormal(t, y)); 77 | mesh.TextureCoordinates.Add(GetTextureCoordinate(t, y)); 78 | } 79 | } 80 | 81 | for (int yi = 0; yi < yDiv; yi++) 82 | { 83 | for (int ti = 0; ti < tDiv; ti++) 84 | { 85 | int x0 = ti; 86 | int x1 = (ti + 1); 87 | int y0 = yi * (tDiv + 1); 88 | int y1 = (yi + 1) * (tDiv + 1); 89 | 90 | mesh.TriangleIndices.Add(x0 + y0); 91 | mesh.TriangleIndices.Add(x0 + y1); 92 | mesh.TriangleIndices.Add(x1 + y0); 93 | 94 | mesh.TriangleIndices.Add(x1 + y0); 95 | mesh.TriangleIndices.Add(x0 + y1); 96 | mesh.TriangleIndices.Add(x1 + y1); 97 | } 98 | } 99 | 100 | mesh.Freeze(); 101 | return mesh; 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /3DTools/Samples/InteractiveViewport3DSample/InteractiveCone.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | //--------------------------------------------------------------------------- 14 | 15 | using System; 16 | using System.Windows; 17 | using System.Windows.Media; 18 | using System.Windows.Media.Media3D; 19 | using _3DTools; 20 | 21 | namespace InteractiveViewport3DSample 22 | { 23 | public class InteractiveCone : InteractiveVisual3D 24 | { 25 | public InteractiveCone() 26 | { 27 | Geometry = Tessellate(); 28 | } 29 | 30 | 31 | internal double DegToRad(double degrees) 32 | { 33 | return (degrees / 180.0) * Math.PI; 34 | } 35 | 36 | 37 | internal Point3D GetPosition(double t, double y) 38 | { 39 | double r = (1 + y) / 2; 40 | double x = r * Math.Cos(t); 41 | double z = r * Math.Sin(t); 42 | 43 | return new Point3D(x, y, z); 44 | } 45 | 46 | 47 | private Vector3D GetNormal(double t, double y) 48 | { 49 | double x = 2 * Math.Cos(t); 50 | double z = 2 * Math.Sin(t); 51 | 52 | return new Vector3D(x, 1, z); 53 | } 54 | 55 | 56 | private Point GetTextureCoordinate(double t, double y) 57 | { 58 | return new Point(1.0 - t * 1 / (2 * Math.PI), y * -0.5 + 0.5); 59 | } 60 | 61 | internal MeshGeometry3D Tessellate() 62 | { 63 | int tDiv = 32; 64 | int yDiv = 32; 65 | double maxTheta = DegToRad(360.0); 66 | double minY = -1.0; 67 | double maxY = 1.0; 68 | 69 | double dt = maxTheta / tDiv; 70 | double dy = (maxY - minY) / yDiv; 71 | 72 | MeshGeometry3D mesh = new MeshGeometry3D(); 73 | 74 | for (int yi = 0; yi <= yDiv; yi++) 75 | { 76 | double y = minY + yi * dy; 77 | 78 | for (int ti = 0; ti <= tDiv; ti++) 79 | { 80 | double t = ti * dt; 81 | 82 | mesh.Positions.Add(GetPosition(t, y)); 83 | mesh.Normals.Add(GetNormal(t, y)); 84 | mesh.TextureCoordinates.Add(GetTextureCoordinate(t, y)); 85 | } 86 | } 87 | 88 | for (int yi = 0; yi < yDiv; yi++) 89 | { 90 | for (int ti = 0; ti < tDiv; ti++) 91 | { 92 | int x0 = ti; 93 | int x1 = (ti + 1); 94 | int y0 = yi * (tDiv + 1); 95 | int y1 = (yi + 1) * (tDiv + 1); 96 | 97 | mesh.TriangleIndices.Add(x0 + y0); 98 | mesh.TriangleIndices.Add(x0 + y1); 99 | mesh.TriangleIndices.Add(x1 + y0); 100 | 101 | mesh.TriangleIndices.Add(x1 + y0); 102 | mesh.TriangleIndices.Add(x0 + y1); 103 | mesh.TriangleIndices.Add(x1 + y1); 104 | } 105 | } 106 | 107 | mesh.Freeze(); 108 | return mesh; 109 | } 110 | 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /3DTools/3DTools/Matrix3DStack.cs: -------------------------------------------------------------------------------- 1 | ///--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | //--------------------------------------------------------------------------- 14 | 15 | using System; 16 | using System.Collections; 17 | using System.Collections.Generic; 18 | using System.Windows.Media.Media3D; 19 | 20 | namespace _3DTools 21 | { 22 | /// 23 | /// Matrix3DStack is a stack of Matrix3Ds. 24 | /// 25 | public class Matrix3DStack : IEnumerable, ICollection 26 | { 27 | public Matrix3D Peek() 28 | { 29 | return _storage[_storage.Count - 1]; 30 | } 31 | 32 | public void Push(Matrix3D item) 33 | { 34 | _storage.Add(item); 35 | } 36 | 37 | public void Append(Matrix3D item) 38 | { 39 | if (Count > 0) 40 | { 41 | Matrix3D top = Peek(); 42 | top.Append(item); 43 | Push(top); 44 | } 45 | else 46 | { 47 | Push(item); 48 | } 49 | } 50 | 51 | public void Prepend(Matrix3D item) 52 | { 53 | if (Count > 0) 54 | { 55 | Matrix3D top = Peek(); 56 | top.Prepend(item); 57 | Push(top); 58 | } 59 | else 60 | { 61 | Push(item); 62 | } 63 | } 64 | 65 | public Matrix3D Pop() 66 | { 67 | Matrix3D result = Peek(); 68 | _storage.RemoveAt(_storage.Count - 1); 69 | 70 | return result; 71 | } 72 | 73 | public int Count 74 | { 75 | get { return _storage.Count; } 76 | } 77 | 78 | void Clear() 79 | { 80 | _storage.Clear(); 81 | } 82 | 83 | bool Contains(Matrix3D item) 84 | { 85 | return _storage.Contains(item); 86 | } 87 | 88 | private readonly List _storage = new List(); 89 | 90 | #region ICollection Members 91 | 92 | void ICollection.CopyTo(Array array, int index) 93 | { 94 | ((ICollection)_storage).CopyTo(array, index); 95 | } 96 | 97 | bool ICollection.IsSynchronized 98 | { 99 | get { return ((ICollection)_storage).IsSynchronized; } 100 | } 101 | 102 | object ICollection.SyncRoot 103 | { 104 | get { return ((ICollection)_storage).SyncRoot; } 105 | } 106 | 107 | #endregion 108 | 109 | #region IEnumerable Members 110 | 111 | IEnumerator IEnumerable.GetEnumerator() 112 | { 113 | return ((IEnumerable)this).GetEnumerator(); 114 | } 115 | 116 | #endregion 117 | 118 | #region IEnumerable Members 119 | 120 | IEnumerator IEnumerable.GetEnumerator() 121 | { 122 | for (int i = _storage.Count - 1; i >= 0; i--) 123 | { 124 | yield return _storage[i]; 125 | } 126 | } 127 | 128 | #endregion 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /3DTools/3DTools.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{E41EA7FE-C162-4C20-859B-1872DB999D4F}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3DTools", "3DTools\3DTools.csproj", "{5F603892-DE40-4246-A969-1C6717AFE35D}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModelViewer", "Samples\ModelViewer\ModelViewer.csproj", "{0231FAF0-6A94-4211-8C62-82043BD747AD}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InteractiveViewport3DSample", "Samples\InteractiveViewport3DSample\InteractiveViewport3DSample.csproj", "{6E88F38A-029E-4BDE-8CFB-AD4898826FDF}" 13 | ProjectSection(ProjectDependencies) = postProject 14 | {5F603892-DE40-4246-A969-1C6717AFE35D} = {5F603892-DE40-4246-A969-1C6717AFE35D} 15 | EndProjectSection 16 | EndProject 17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Channel9Demo", "Samples\Channel9Demo\Channel9Demo.csproj", "{0414411F-1AFE-4506-AD9F-6917E4032581}" 18 | EndProject 19 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeneratedTextureCoordinatesDemo", "Samples\GeneratedTextureCoordinatesDemo\GeneratedTextureCoordinatesDemo.csproj", "{076F8821-DB8A-4D8A-9015-A8E5D68C82E4}" 20 | EndProject 21 | Global 22 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 23 | Debug|Any CPU = Debug|Any CPU 24 | Release|Any CPU = Release|Any CPU 25 | EndGlobalSection 26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 27 | {5F603892-DE40-4246-A969-1C6717AFE35D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {5F603892-DE40-4246-A969-1C6717AFE35D}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {5F603892-DE40-4246-A969-1C6717AFE35D}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {5F603892-DE40-4246-A969-1C6717AFE35D}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {0231FAF0-6A94-4211-8C62-82043BD747AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {0231FAF0-6A94-4211-8C62-82043BD747AD}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {0231FAF0-6A94-4211-8C62-82043BD747AD}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {0231FAF0-6A94-4211-8C62-82043BD747AD}.Release|Any CPU.Build.0 = Release|Any CPU 35 | {6E88F38A-029E-4BDE-8CFB-AD4898826FDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {6E88F38A-029E-4BDE-8CFB-AD4898826FDF}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {6E88F38A-029E-4BDE-8CFB-AD4898826FDF}.Release|Any CPU.ActiveCfg = Release|Any CPU 38 | {6E88F38A-029E-4BDE-8CFB-AD4898826FDF}.Release|Any CPU.Build.0 = Release|Any CPU 39 | {0414411F-1AFE-4506-AD9F-6917E4032581}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 40 | {0414411F-1AFE-4506-AD9F-6917E4032581}.Debug|Any CPU.Build.0 = Debug|Any CPU 41 | {0414411F-1AFE-4506-AD9F-6917E4032581}.Release|Any CPU.ActiveCfg = Release|Any CPU 42 | {0414411F-1AFE-4506-AD9F-6917E4032581}.Release|Any CPU.Build.0 = Release|Any CPU 43 | {076F8821-DB8A-4D8A-9015-A8E5D68C82E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 44 | {076F8821-DB8A-4D8A-9015-A8E5D68C82E4}.Debug|Any CPU.Build.0 = Debug|Any CPU 45 | {076F8821-DB8A-4D8A-9015-A8E5D68C82E4}.Release|Any CPU.ActiveCfg = Release|Any CPU 46 | {076F8821-DB8A-4D8A-9015-A8E5D68C82E4}.Release|Any CPU.Build.0 = Release|Any CPU 47 | EndGlobalSection 48 | GlobalSection(SolutionProperties) = preSolution 49 | HideSolutionNode = FALSE 50 | EndGlobalSection 51 | GlobalSection(NestedProjects) = preSolution 52 | {0231FAF0-6A94-4211-8C62-82043BD747AD} = {E41EA7FE-C162-4C20-859B-1872DB999D4F} 53 | {6E88F38A-029E-4BDE-8CFB-AD4898826FDF} = {E41EA7FE-C162-4C20-859B-1872DB999D4F} 54 | {0414411F-1AFE-4506-AD9F-6917E4032581} = {E41EA7FE-C162-4C20-859B-1872DB999D4F} 55 | {076F8821-DB8A-4D8A-9015-A8E5D68C82E4} = {E41EA7FE-C162-4C20-859B-1872DB999D4F} 56 | EndGlobalSection 57 | EndGlobal 58 | -------------------------------------------------------------------------------- /3DTools/3DTools/Trackport3D.xaml.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | // The following article discusses the mechanics behind this 14 | // trackball implementation: http://viewport3d.com/trackball.htm 15 | // 16 | // Reading the article is not required to use this sample code, 17 | // but skimming it might be useful. 18 | // 19 | //--------------------------------------------------------------------------- 20 | 21 | using System; 22 | using System.Diagnostics; 23 | using System.Windows; 24 | using System.Windows.Controls; 25 | using System.Windows.Media; 26 | using System.Windows.Media.Media3D; 27 | using System.Windows.Input; 28 | using System.Windows.Markup; 29 | 30 | namespace _3DTools 31 | { 32 | /// 33 | /// Trackport3D loads a Model3D from a xaml file and displays it. The user 34 | /// may rotate the view by dragging the mouse with the left mouse button. 35 | /// Dragging with the right mouse button will zoom in and out. 36 | /// 37 | /// Trackport3D is primarily an example of how to use the Trackball utility 38 | /// class, but it may be used as a custom control in your own applications. 39 | /// 40 | public partial class Trackport3D : UserControl 41 | { 42 | private Trackball _trackball = new Trackball(); 43 | private readonly ScreenSpaceLines3D Wireframe = new ScreenSpaceLines3D(); 44 | 45 | public Trackport3D() 46 | { 47 | InitializeComponent(); 48 | 49 | this.Viewport.Children.Add(Wireframe); 50 | this.Camera.Transform = _trackball.Transform; 51 | this.Headlight.Transform = _trackball.Transform; 52 | } 53 | 54 | /// 55 | /// Loads and displays the given Xaml file. Expects the root of 56 | /// the Xaml file to be a Model3D. 57 | /// 58 | public void LoadModel(System.IO.Stream fileStream) 59 | { 60 | _model = (Model3D)XamlReader.Load(fileStream); 61 | 62 | SetupScene(); 63 | } 64 | 65 | public Color HeadlightColor 66 | { 67 | get { return this.Headlight.Color; } 68 | set { this.Headlight.Color = value; } 69 | } 70 | 71 | public Color AmbientLightColor 72 | { 73 | get { return this.AmbientLight.Color; } 74 | set { this.AmbientLight.Color = value; } 75 | } 76 | 77 | public ViewMode ViewMode 78 | { 79 | get { return _viewMode; } 80 | set 81 | { 82 | _viewMode = value; 83 | SetupScene(); 84 | } 85 | } 86 | 87 | private void SetupScene() 88 | { 89 | switch (ViewMode) 90 | { 91 | case ViewMode.Solid: 92 | this.Root.Content = _model; 93 | this.Wireframe.Points.Clear(); 94 | break; 95 | 96 | case ViewMode.Wireframe: 97 | this.Root.Content = null; 98 | this.Wireframe.MakeWireframe(_model); 99 | break; 100 | } 101 | } 102 | 103 | private void OnLoaded(object sender, RoutedEventArgs e) 104 | { 105 | // Viewport3Ds only raise events when the mouse is over the rendered 3D geometry. 106 | // In order to capture events whenever the mouse is over the client are we use a 107 | // same sized transparent Border positioned on top of the Viewport3D. 108 | _trackball.EventSource = CaptureBorder; 109 | } 110 | 111 | private ViewMode _viewMode; 112 | private Model3D _model; 113 | } 114 | } -------------------------------------------------------------------------------- /3DTools/Samples/InteractiveViewport3DSample/InteractiveSphere.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | //--------------------------------------------------------------------------- 14 | 15 | using System; 16 | using System.Windows; 17 | using System.Windows.Media; 18 | using System.Windows.Media.Media3D; 19 | using _3DTools; 20 | 21 | namespace InteractiveViewport3DSample 22 | { 23 | public class InteractiveSphere : InteractiveVisual3D 24 | { 25 | // 26 | // 27 | // 28 | public InteractiveSphere() 29 | { 30 | // we'll use the constructor to just realize the sphere geometry 31 | Geometry = Tessellate(ThetaDiv, PhiDiv, Radius); 32 | } 33 | 34 | internal static Point3D GetPosition(double theta, double phi, double radius) 35 | { 36 | double x = radius * Math.Sin(theta) * Math.Sin(phi); 37 | double y = radius * Math.Cos(phi); 38 | double z = radius * Math.Cos(theta) * Math.Sin(phi); 39 | 40 | return new Point3D(x, y, z); 41 | } 42 | 43 | private static Vector3D GetNormal(double theta, double phi) 44 | { 45 | return (Vector3D)GetPosition(theta, phi, 1.0); 46 | } 47 | 48 | internal static double DegToRad(double degrees) 49 | { 50 | return (degrees / 180.0) * Math.PI; 51 | } 52 | 53 | private static Point GetTextureCoordinate(double theta, double phi) 54 | { 55 | Point p = new Point(theta / (2 * Math.PI), 56 | phi / (Math.PI)); 57 | 58 | return p; 59 | } 60 | 61 | private int _thetaDiv = 15; 62 | public int ThetaDiv 63 | { 64 | get { return _thetaDiv; } 65 | set { _thetaDiv = value; } 66 | } 67 | 68 | private int _phiDiv = 15; 69 | public int PhiDiv 70 | { 71 | get { return _phiDiv; } 72 | set { _phiDiv = value; } 73 | } 74 | 75 | private double _radius = 1; 76 | public double Radius 77 | { 78 | get { return _radius; } 79 | set { _radius = value; } 80 | } 81 | 82 | internal static MeshGeometry3D Tessellate(int tDiv, int pDiv, double radius) 83 | { 84 | double dt = DegToRad(360.0) / tDiv; 85 | double dp = DegToRad(180.0) / pDiv; 86 | 87 | MeshGeometry3D mesh = new MeshGeometry3D(); 88 | 89 | for (int pi = 0; pi <= pDiv; pi++) 90 | { 91 | double phi = pi * dp; 92 | 93 | for (int ti = 0; ti <= tDiv; ti++) 94 | { 95 | // we want to start the mesh on the x axis 96 | double theta = ti * dt; 97 | 98 | mesh.Positions.Add(GetPosition(theta, phi, radius)); 99 | mesh.Normals.Add(GetNormal(theta, phi)); 100 | mesh.TextureCoordinates.Add(GetTextureCoordinate(theta, phi)); 101 | } 102 | } 103 | 104 | for (int pi = 0; pi < pDiv; pi++) 105 | { 106 | for (int ti = 0; ti < tDiv; ti++) 107 | { 108 | int x0 = ti; 109 | int x1 = (ti + 1); 110 | int y0 = pi * (tDiv + 1); 111 | int y1 = (pi + 1) * (tDiv + 1); 112 | 113 | mesh.TriangleIndices.Add(x0 + y0); 114 | mesh.TriangleIndices.Add(x0 + y1); 115 | mesh.TriangleIndices.Add(x1 + y0); 116 | 117 | mesh.TriangleIndices.Add(x1 + y0); 118 | mesh.TriangleIndices.Add(x0 + y1); 119 | mesh.TriangleIndices.Add(x1 + y1); 120 | } 121 | } 122 | 123 | mesh.Freeze(); 124 | return mesh; 125 | } 126 | 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /3DTools/Samples/ModelViewer/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | //--------------------------------------------------------------------------- 14 | 15 | using _3DTools; 16 | using System; 17 | using System.Diagnostics; 18 | using System.IO; 19 | using System.Windows; 20 | using System.Windows.Controls; 21 | using System.Windows.Input; 22 | using System.Windows.Media; 23 | using System.Windows.Media.Media3D; 24 | using System.Windows.Threading; 25 | 26 | namespace ModelViewer 27 | { 28 | public partial class MainWindow : Window 29 | { 30 | public MainWindow() 31 | { 32 | InitializeComponent(); 33 | } 34 | 35 | private void OnExit(object sender, RoutedEventArgs e) 36 | { 37 | Application.Current.Shutdown(); 38 | } 39 | 40 | private void OnOpen(object sender, RoutedEventArgs e) 41 | { 42 | Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog(); 43 | openFileDialog.Filter = "Xaml files (*.xaml)|*.xaml"; 44 | 45 | if (openFileDialog.ShowDialog().Value) 46 | { 47 | Load(openFileDialog.FileName); 48 | } 49 | } 50 | 51 | private void OnHeadlightChecked(object sender, RoutedEventArgs e) 52 | { 53 | if (_trackport != null) 54 | { 55 | _trackport.HeadlightColor = Colors.White; 56 | } 57 | } 58 | 59 | private void OnHeadlightUnchecked(object sender, RoutedEventArgs e) 60 | { 61 | _trackport.HeadlightColor = Colors.Black; 62 | } 63 | 64 | private void OnAmbientLightChecked(object sender, RoutedEventArgs e) 65 | { 66 | _trackport.AmbientLightColor = Colors.White; 67 | } 68 | 69 | private void OnAmbientLightUnchecked(object sender, RoutedEventArgs e) 70 | { 71 | _trackport.AmbientLightColor = Colors.Black; 72 | } 73 | 74 | private void OnWireframeChecked(object sender, RoutedEventArgs e) 75 | { 76 | _trackport.ViewMode = ViewMode.Wireframe; 77 | } 78 | 79 | private void OnWireframeUnchecked(object sender, RoutedEventArgs e) 80 | { 81 | _trackport.ViewMode = ViewMode.Solid; 82 | } 83 | 84 | internal void Load(string path) 85 | { 86 | if (path != null && File.Exists(path)) 87 | { 88 | LoadCore(path); 89 | 90 | _watcher.BeginInit(); 91 | _watcher.Path = Path.GetDirectoryName(path); 92 | _watcher.Filter = Path.GetFileName(path); 93 | _watcher.Changed += FileChanged; 94 | _watcher.EnableRaisingEvents = true; 95 | _watcher.EndInit(); 96 | } 97 | } 98 | 99 | private void LoadCore(string path) 100 | { 101 | if (path != null) 102 | { 103 | try 104 | { 105 | using (FileStream file = File.OpenRead(path)) 106 | { 107 | _trackport.LoadModel(file); 108 | } 109 | } 110 | catch (Exception e) 111 | { 112 | MessageBox.Show( 113 | String.Format("Unable to parse file:\r\n\r\n{0}", 114 | e.Message), "Error", MessageBoxButton.OK, MessageBoxImage.Error); 115 | } 116 | } 117 | } 118 | 119 | private delegate void DispatcherCallback(); 120 | 121 | private void FileChanged(object sender, FileSystemEventArgs e) 122 | { 123 | 124 | if (e.ChangeType == WatcherChangeTypes.Changed) 125 | { 126 | this.Dispatcher.Invoke(DispatcherPriority.Normal, new DispatcherCallback(delegate() { this.LoadCore(e.FullPath); })); 127 | } 128 | } 129 | 130 | private readonly FileSystemWatcher _watcher = new FileSystemWatcher(); 131 | } 132 | } -------------------------------------------------------------------------------- /3DTools/3DTools/3DTools.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {5F603892-DE40-4246-A969-1C6717AFE35D} 7 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | _3DTools 9 | 3DTools 10 | 4 11 | library 12 | 1.0.0.* 13 | 14 | 3.0 15 | SAK 16 | SAK 17 | SAK 18 | SAK 19 | v4.6.1 20 | 21 | 22 | 23 | 24 | 2.0 25 | 26 | 27 | 28 | true 29 | full 30 | false 31 | .\bin\Debug\ 32 | DEBUG;TRACE 33 | false 34 | 35 | 36 | false 37 | true 38 | .\bin\Release\ 39 | TRACE 40 | false 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | ResXFileCodeGenerator 67 | Designer 68 | Resources.Designer.cs 69 | 70 | 71 | SettingsSingleFileGenerator 72 | Settings.Designer.cs 73 | 74 | 75 | True 76 | True 77 | Resources.resx 78 | 79 | 80 | True 81 | True 82 | Settings.settings 83 | 84 | 85 | 86 | 87 | 88 | Trackport3D.xaml 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | MSBuild:Compile 97 | Designer 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /3DTools/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Microsoft Azure ApplicationInsights config file 170 | ApplicationInsights.config 171 | 172 | # Windows Store app package directory 173 | AppPackages/ 174 | BundleArtifacts/ 175 | 176 | # Visual Studio cache files 177 | # files ending in .cache can be ignored 178 | *.[Cc]ache 179 | # but keep track of directories ending in .cache 180 | !*.[Cc]ache/ 181 | 182 | # Others 183 | ClientBin/ 184 | [Ss]tyle[Cc]op.* 185 | ~$* 186 | *~ 187 | *.dbmdl 188 | *.dbproj.schemaview 189 | *.pfx 190 | *.publishsettings 191 | node_modules/ 192 | orleans.codegen.cs 193 | 194 | # RIA/Silverlight projects 195 | Generated_Code/ 196 | 197 | # Backup & report files from converting an old project file 198 | # to a newer Visual Studio version. Backup files are not needed, 199 | # because we have git ;-) 200 | _UpgradeReport_Files/ 201 | Backup*/ 202 | UpgradeLog*.XML 203 | UpgradeLog*.htm 204 | 205 | # SQL Server files 206 | *.mdf 207 | *.ldf 208 | 209 | # Business Intelligence projects 210 | *.rdl.data 211 | *.bim.layout 212 | *.bim_*.settings 213 | 214 | # Microsoft Fakes 215 | FakesAssemblies/ 216 | 217 | # GhostDoc plugin setting file 218 | *.GhostDoc.xml 219 | 220 | # Node.js Tools for Visual Studio 221 | .ntvs_analysis.dat 222 | 223 | # Visual Studio 6 build log 224 | *.plg 225 | 226 | # Visual Studio 6 workspace options file 227 | *.opt 228 | 229 | # Visual Studio LightSwitch build output 230 | **/*.HTMLClient/GeneratedArtifacts 231 | **/*.DesktopClient/GeneratedArtifacts 232 | **/*.DesktopClient/ModelManifest.xml 233 | **/*.Server/GeneratedArtifacts 234 | **/*.Server/ModelManifest.xml 235 | _Pvt_Extensions 236 | 237 | # LightSwitch generated files 238 | GeneratedArtifacts/ 239 | ModelManifest.xml 240 | 241 | # Paket dependency manager 242 | .paket/paket.exe 243 | 244 | # FAKE - F# Make 245 | .fake/ -------------------------------------------------------------------------------- /3DTools/Samples/Channel9Demo/Channel9Demo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {0414411F-1AFE-4506-AD9F-6917E4032581} 7 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | Channel9Demo 9 | Channel9Demo 10 | 4 11 | winexe 12 | 3.0 13 | true 14 | Web 15 | true 16 | Foreground 17 | 7 18 | Days 19 | false 20 | false 21 | false 22 | 1.0.0.* 23 | true 24 | true 25 | Publish\ 26 | SAK 27 | SAK 28 | SAK 29 | SAK 30 | v4.6.1 31 | 32 | 33 | 34 | 35 | 2.0 36 | 37 | 38 | 39 | true 40 | full 41 | false 42 | .\bin\Debug\ 43 | DEBUG;TRACE 44 | false 45 | 46 | 47 | false 48 | true 49 | .\bin\Release\ 50 | TRACE 51 | false 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | MSBuild:Compile 72 | Designer 73 | 74 | 75 | True 76 | True 77 | Settings.settings 78 | 79 | 80 | MSBuild:Compile 81 | Designer 82 | 83 | 84 | App.xaml 85 | Code 86 | 87 | 88 | 89 | 90 | Code 91 | DemoWindow.xaml 92 | 93 | 94 | 95 | ResXFileCodeGenerator 96 | Designer 97 | Resources.Designer.cs 98 | 99 | 100 | 101 | SettingsSingleFileGenerator 102 | Settings.Designer.cs 103 | 104 | 105 | True 106 | True 107 | Resources.resx 108 | 109 | 110 | 111 | 112 | 113 | {5F603892-DE40-4246-A969-1C6717AFE35D} 114 | 3DTools 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /3DTools/Samples/GeneratedTextureCoordinatesDemo/GeneratedTextureCoordinatesDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {076F8821-DB8A-4D8A-9015-A8E5D68C82E4} 7 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | GeneratedTextureCoordinatesDemo 9 | GeneratedTextureCoordinatesDemo 10 | 4 11 | winexe 12 | 3.0 13 | true 14 | Web 15 | true 16 | Foreground 17 | 7 18 | Days 19 | false 20 | false 21 | false 22 | 1.0.0.* 23 | true 24 | true 25 | Publish\ 26 | SAK 27 | SAK 28 | SAK 29 | SAK 30 | v4.6.1 31 | 32 | 33 | 34 | 35 | 2.0 36 | 37 | 38 | 39 | true 40 | full 41 | false 42 | .\bin\Debug\ 43 | DEBUG;TRACE 44 | false 45 | 46 | 47 | false 48 | true 49 | .\bin\Release\ 50 | TRACE 51 | false 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | MSBuild:Compile 72 | Designer 73 | 74 | 75 | MSBuild:Compile 76 | Designer 77 | 78 | 79 | App.xaml 80 | Code 81 | 82 | 83 | True 84 | True 85 | Resources.resx 86 | 87 | 88 | True 89 | True 90 | Settings.settings 91 | 92 | 93 | Window1.xaml 94 | Code 95 | 96 | 97 | 98 | 99 | 100 | ResXFileCodeGenerator 101 | Designer 102 | Resources.Designer.cs 103 | 104 | 105 | 106 | SettingsSingleFileGenerator 107 | Settings.Designer.cs 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | {5F603892-DE40-4246-A969-1C6717AFE35D} 117 | 3DTools 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /3DTools/Samples/InteractiveViewport3DSample/InteractiveViewport3DSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {6E88F38A-029E-4BDE-8CFB-AD4898826FDF} 7 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | InteractiveViewport3DSample 9 | InteractiveViewport3DSample 10 | 4 11 | winexe 12 | 3.0 13 | true 14 | Web 15 | true 16 | Foreground 17 | 7 18 | Days 19 | false 20 | false 21 | false 22 | 1.0.0.* 23 | true 24 | true 25 | Publish\ 26 | SAK 27 | SAK 28 | SAK 29 | SAK 30 | v4.6.1 31 | 32 | 33 | 34 | 35 | 2.0 36 | 37 | 38 | 39 | true 40 | full 41 | false 42 | .\bin\Debug\ 43 | DEBUG;TRACE 44 | false 45 | 46 | 47 | false 48 | true 49 | .\bin\Release\ 50 | TRACE 51 | false 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | MSBuild:Compile 72 | Designer 73 | 74 | 75 | MSBuild:Compile 76 | Designer 77 | 78 | 79 | App.xaml 80 | Code 81 | 82 | 83 | Window1.xaml 84 | Code 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | ResXFileCodeGenerator 94 | Designer 95 | Resources.Designer.cs 96 | 97 | 98 | 99 | SettingsSingleFileGenerator 100 | Settings.Designer.cs 101 | 102 | 103 | True 104 | True 105 | Resources.resx 106 | 107 | 108 | True 109 | True 110 | Settings.settings 111 | 112 | 113 | 114 | 115 | 116 | {5F603892-DE40-4246-A969-1C6717AFE35D} 117 | 3DTools 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /3DTools/Samples/ModelViewer/ModelViewer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {0231FAF0-6A94-4211-8C62-82043BD747AD} 7 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | ModelViewer 9 | ModelViewer 10 | 4 11 | winexe 12 | 3.0 13 | true 14 | Web 15 | true 16 | Foreground 17 | 7 18 | Days 19 | false 20 | false 21 | false 22 | 1.0.0.* 23 | true 24 | true 25 | Publish\ 26 | SAK 27 | SAK 28 | SAK 29 | SAK 30 | v4.6.1 31 | 32 | 33 | 34 | 35 | 2.0 36 | 37 | 38 | 39 | true 40 | full 41 | false 42 | .\bin\Debug\ 43 | DEBUG;TRACE 44 | false 45 | 46 | 47 | false 48 | true 49 | .\bin\Release\ 50 | TRACE 51 | false 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | MainWindow.xaml 73 | 74 | 75 | MyApp.xaml 76 | 77 | 78 | 79 | ResXFileCodeGenerator 80 | Designer 81 | Resources.Designer.cs 82 | 83 | 84 | 85 | SettingsSingleFileGenerator 86 | Settings.Designer.cs 87 | 88 | 89 | True 90 | True 91 | Resources.resx 92 | 93 | 94 | True 95 | True 96 | Settings.settings 97 | 98 | 99 | 100 | 101 | 102 | MSBuild:Compile 103 | Designer 104 | 105 | 106 | PreserveNewest 107 | MSBuild:Compile 108 | Designer 109 | 110 | 111 | MSBuild:Compile 112 | Designer 113 | 114 | 115 | 116 | 117 | {5F603892-DE40-4246-A969-1C6717AFE35D} 118 | 3DTools 119 | 120 | 121 | 122 | 123 | PreserveNewest 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /3DTools/3DTools/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /3DTools/Samples/Channel9Demo/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /3DTools/Samples/ModelViewer/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /3DTools/Samples/InteractiveViewport3DSample/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /3DTools/Samples/GeneratedTextureCoordinatesDemo/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /BuildProcessTemplates/UpgradeTemplate.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | [New Microsoft.TeamFoundation.Build.Workflow.Activities.AgentSettings() With {.MaxWaitTime = New System.TimeSpan(4, 0, 0), .MaxExecutionTime = New System.TimeSpan(0, 0, 0), .TagComparison = Microsoft.TeamFoundation.Build.Workflow.Activities.TagComparison.MatchExactly }] 21 | 22 | 23 | 24 | [Microsoft.TeamFoundation.Build.Workflow.Activities.ToolPlatform.Auto] 25 | [False] 26 | [False] 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | [Microsoft.TeamFoundation.VersionControl.Client.RecursionType.OneLevel] 37 | [Microsoft.TeamFoundation.Build.Workflow.BuildVerbosity.Normal] 38 | 39 | 40 | 41 | All 42 | Assembly references and imported namespaces serialized as XML namespaces 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /3DTools/Samples/InteractiveViewport3DSample/Window1.xaml: -------------------------------------------------------------------------------- 1 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 67 | 68 | 70 | 71 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /3DTools/3DTools/TrackballDecorator.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | // The following article discusses the mechanics behind this 14 | // trackball implementation: http://viewport3d.com/trackball.htm 15 | // 16 | // Reading the article is not required to use this sample code, 17 | // but skimming it might be useful. 18 | // 19 | //--------------------------------------------------------------------------- 20 | 21 | using System; 22 | using System.Collections; 23 | using System.Collections.Generic; 24 | using System.Windows; 25 | using System.Windows.Controls; 26 | using System.Windows.Data; 27 | using System.Windows.Documents; 28 | using System.Windows.Media; 29 | using System.Windows.Media.Imaging; 30 | using System.Windows.Media.Media3D; 31 | using System.Windows.Shapes; 32 | using System.Windows.Input; 33 | using System.Windows.Markup; // IAddChild, ContentPropertyAttribute 34 | 35 | namespace _3DTools 36 | { 37 | public class TrackballDecorator : Viewport3DDecorator 38 | { 39 | public TrackballDecorator() 40 | { 41 | // the transform that will be applied to the viewport 3d's camera 42 | _transform = new Transform3DGroup(); 43 | _transform.Children.Add(_scale); 44 | _transform.Children.Add(new RotateTransform3D(_rotation)); 45 | 46 | // used so that we always get events while activity occurs within 47 | // the viewport3D 48 | _eventSource = new Border(); 49 | _eventSource.Background = Brushes.Transparent; 50 | 51 | PreViewportChildren.Add(_eventSource); 52 | } 53 | 54 | /// 55 | /// A transform to move the camera or scene to the trackball's 56 | /// current orientation and scale. 57 | /// 58 | public Transform3D Transform 59 | { 60 | get { return _transform; } 61 | } 62 | 63 | #region Event Handling 64 | 65 | protected override void OnMouseDown(MouseButtonEventArgs e) 66 | { 67 | base.OnMouseDown(e); 68 | 69 | _previousPosition2D = e.GetPosition(this); 70 | _previousPosition3D = ProjectToTrackball(ActualWidth, 71 | ActualHeight, 72 | _previousPosition2D); 73 | if (Mouse.Captured == null) 74 | { 75 | Mouse.Capture(this, CaptureMode.Element); 76 | } 77 | } 78 | 79 | protected override void OnMouseUp(MouseButtonEventArgs e) 80 | { 81 | base.OnMouseUp(e); 82 | 83 | if (IsMouseCaptured) 84 | { 85 | Mouse.Capture(this, CaptureMode.None); 86 | } 87 | } 88 | 89 | protected override void OnMouseMove(MouseEventArgs e) 90 | { 91 | base.OnMouseMove(e); 92 | 93 | if (IsMouseCaptured) 94 | { 95 | Point currentPosition = e.GetPosition(this); 96 | 97 | // avoid any zero axis conditions 98 | if (currentPosition == _previousPosition2D) return; 99 | 100 | // Prefer tracking to zooming if both buttons are pressed. 101 | if (e.LeftButton == MouseButtonState.Pressed) 102 | { 103 | Track(currentPosition); 104 | } 105 | else if (e.RightButton == MouseButtonState.Pressed) 106 | { 107 | Zoom(currentPosition); 108 | } 109 | 110 | _previousPosition2D = currentPosition; 111 | 112 | Viewport3D viewport3D = this.Viewport3D; 113 | if (viewport3D != null) 114 | { 115 | if (viewport3D.Camera != null) 116 | { 117 | if (viewport3D.Camera.IsFrozen) 118 | { 119 | viewport3D.Camera = viewport3D.Camera.Clone(); 120 | } 121 | 122 | if (viewport3D.Camera.Transform != _transform) 123 | { 124 | viewport3D.Camera.Transform = _transform; 125 | } 126 | } 127 | } 128 | } 129 | } 130 | 131 | #endregion Event Handling 132 | 133 | private void Track(Point currentPosition) 134 | { 135 | Vector3D currentPosition3D = ProjectToTrackball( 136 | ActualWidth, ActualHeight, currentPosition); 137 | 138 | Vector3D axis = Vector3D.CrossProduct(_previousPosition3D, currentPosition3D); 139 | double angle = Vector3D.AngleBetween(_previousPosition3D, currentPosition3D); 140 | 141 | // quaterion will throw if this happens - sometimes we can get 3D positions that 142 | // are very similar, so we avoid the throw by doing this check and just ignoring 143 | // the event 144 | if (axis.Length == 0) return; 145 | 146 | Quaternion delta = new Quaternion(axis, -angle); 147 | 148 | // Get the current orientantion from the RotateTransform3D 149 | AxisAngleRotation3D r = _rotation; 150 | Quaternion q = new Quaternion(_rotation.Axis, _rotation.Angle); 151 | 152 | // Compose the delta with the previous orientation 153 | q *= delta; 154 | 155 | // Write the new orientation back to the Rotation3D 156 | _rotation.Axis = q.Axis; 157 | _rotation.Angle = q.Angle; 158 | 159 | _previousPosition3D = currentPosition3D; 160 | } 161 | 162 | private Vector3D ProjectToTrackball(double width, double height, Point point) 163 | { 164 | double x = point.X / (width / 2); // Scale so bounds map to [0,0] - [2,2] 165 | double y = point.Y / (height / 2); 166 | 167 | x = x - 1; // Translate 0,0 to the center 168 | y = 1 - y; // Flip so +Y is up instead of down 169 | 170 | double z2 = 1 - x * x - y * y; // z^2 = 1 - x^2 - y^2 171 | double z = z2 > 0 ? Math.Sqrt(z2) : 0; 172 | 173 | return new Vector3D(x, y, z); 174 | } 175 | 176 | private void Zoom(Point currentPosition) 177 | { 178 | double yDelta = currentPosition.Y - _previousPosition2D.Y; 179 | 180 | double scale = Math.Exp(yDelta / 100); // e^(yDelta/100) is fairly arbitrary. 181 | 182 | _scale.ScaleX *= scale; 183 | _scale.ScaleY *= scale; 184 | _scale.ScaleZ *= scale; 185 | } 186 | 187 | //-------------------------------------------------------------------- 188 | // 189 | // Private data 190 | // 191 | //-------------------------------------------------------------------- 192 | 193 | private Point _previousPosition2D; 194 | private Vector3D _previousPosition3D = new Vector3D(0, 0, 1); 195 | 196 | private Transform3DGroup _transform; 197 | private ScaleTransform3D _scale = new ScaleTransform3D(); 198 | private AxisAngleRotation3D _rotation = new AxisAngleRotation3D(); 199 | 200 | private Border _eventSource; 201 | } 202 | } 203 | -------------------------------------------------------------------------------- /3DTools/Samples/Channel9Demo/DemoWindow.xaml: -------------------------------------------------------------------------------- 1 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 126 | 127 | 128 | Truth 129 | 130 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 141 | 142 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | -------------------------------------------------------------------------------- /3DTools/3DTools/Trackball.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | // The following article discusses the mechanics behind this 14 | // trackball implementation: http://viewport3d.com/trackball.htm 15 | // 16 | // Reading the article is not required to use this sample code, 17 | // but skimming it might be useful. 18 | // 19 | //--------------------------------------------------------------------------- 20 | 21 | using System; 22 | using System.Diagnostics; 23 | using System.Windows; 24 | using System.Windows.Input; 25 | using System.Windows.Media.Media3D; 26 | using System.Windows.Markup; 27 | 28 | namespace _3DTools 29 | { 30 | /// 31 | /// Trackball is a utility class which observes the mouse events 32 | /// on a specified FrameworkElement and produces a Transform3D 33 | /// with the resultant rotation and scale. 34 | /// 35 | /// Example Usage: 36 | /// 37 | /// Trackball trackball = new Trackball(); 38 | /// trackball.EventSource = myElement; 39 | /// myViewport3D.Camera.Transform = trackball.Transform; 40 | /// 41 | /// Because Viewport3Ds only raise events when the mouse is over the 42 | /// rendered 3D geometry (as opposed to not when the mouse is within 43 | /// the layout bounds) you usually want to use another element as 44 | /// your EventSource. For example, a transparent border placed on 45 | /// top of your Viewport3D works well: 46 | /// 47 | /// 48 | /// 49 | /// 50 | /// 51 | /// 52 | /// 53 | /// 54 | /// NOTE: The Transform property may be shared by multiple Cameras 55 | /// if you want to have auxilary views following the trackball. 56 | /// 57 | /// It can also be useful to share the Transform property with 58 | /// models in the scene that you want to move with the camera. 59 | /// (For example, the Trackport3D's headlight is implemented 60 | /// this way.) 61 | /// 62 | /// You may also use a Transform3DGroup to combine the 63 | /// Transform property with additional Transforms. 64 | /// 65 | public class Trackball 66 | { 67 | private FrameworkElement _eventSource; 68 | private Point _previousPosition2D; 69 | private Vector3D _previousPosition3D = new Vector3D(0, 0, 1); 70 | 71 | private Transform3DGroup _transform; 72 | private ScaleTransform3D _scale = new ScaleTransform3D(); 73 | private AxisAngleRotation3D _rotation = new AxisAngleRotation3D(); 74 | 75 | public Trackball() 76 | { 77 | _transform = new Transform3DGroup(); 78 | _transform.Children.Add(_scale); 79 | _transform.Children.Add(new RotateTransform3D(_rotation)); 80 | } 81 | 82 | /// 83 | /// A transform to move the camera or scene to the trackball's 84 | /// current orientation and scale. 85 | /// 86 | public Transform3D Transform 87 | { 88 | get { return _transform; } 89 | } 90 | 91 | #region Event Handling 92 | 93 | /// 94 | /// The FrameworkElement we listen to for mouse events. 95 | /// 96 | public FrameworkElement EventSource 97 | { 98 | get { return _eventSource; } 99 | 100 | set 101 | { 102 | if (_eventSource != null) 103 | { 104 | _eventSource.MouseDown -= this.OnMouseDown; 105 | _eventSource.MouseUp -= this.OnMouseUp; 106 | _eventSource.MouseMove -= this.OnMouseMove; 107 | } 108 | 109 | _eventSource = value; 110 | 111 | _eventSource.MouseDown += this.OnMouseDown; 112 | _eventSource.MouseUp += this.OnMouseUp; 113 | _eventSource.MouseMove += this.OnMouseMove; 114 | } 115 | } 116 | 117 | private void OnMouseDown(object sender, MouseEventArgs e) 118 | { 119 | Mouse.Capture(EventSource, CaptureMode.Element); 120 | _previousPosition2D = e.GetPosition(EventSource); 121 | _previousPosition3D = ProjectToTrackball( 122 | EventSource.ActualWidth, 123 | EventSource.ActualHeight, 124 | _previousPosition2D); 125 | } 126 | 127 | private void OnMouseUp(object sender, MouseEventArgs e) 128 | { 129 | Mouse.Capture(EventSource, CaptureMode.None); 130 | } 131 | 132 | private void OnMouseMove(object sender, MouseEventArgs e) 133 | { 134 | Point currentPosition = e.GetPosition(EventSource); 135 | 136 | // Prefer tracking to zooming if both buttons are pressed. 137 | if (e.LeftButton == MouseButtonState.Pressed) 138 | { 139 | Track(currentPosition); 140 | } 141 | else if (e.RightButton == MouseButtonState.Pressed) 142 | { 143 | Zoom(currentPosition); 144 | } 145 | 146 | _previousPosition2D = currentPosition; 147 | } 148 | 149 | #endregion Event Handling 150 | 151 | private void Track(Point currentPosition) 152 | { 153 | Vector3D currentPosition3D = ProjectToTrackball( 154 | EventSource.ActualWidth, EventSource.ActualHeight, currentPosition); 155 | 156 | Vector3D axis = Vector3D.CrossProduct(_previousPosition3D, currentPosition3D); 157 | double angle = Vector3D.AngleBetween(_previousPosition3D, currentPosition3D); 158 | Quaternion delta = new Quaternion(axis, -angle); 159 | 160 | // Get the current orientantion from the RotateTransform3D 161 | AxisAngleRotation3D r = _rotation; 162 | Quaternion q = new Quaternion(_rotation.Axis, _rotation.Angle); 163 | 164 | // Compose the delta with the previous orientation 165 | q *= delta; 166 | 167 | // Write the new orientation back to the Rotation3D 168 | _rotation.Axis = q.Axis; 169 | _rotation.Angle = q.Angle; 170 | 171 | _previousPosition3D = currentPosition3D; 172 | } 173 | 174 | private Vector3D ProjectToTrackball(double width, double height, Point point) 175 | { 176 | double x = point.X / (width / 2); // Scale so bounds map to [0,0] - [2,2] 177 | double y = point.Y / (height / 2); 178 | 179 | x = x - 1; // Translate 0,0 to the center 180 | y = 1 - y; // Flip so +Y is up instead of down 181 | 182 | double z2 = 1 - x * x - y * y; // z^2 = 1 - x^2 - y^2 183 | double z = z2 > 0 ? Math.Sqrt(z2) : 0; 184 | 185 | return new Vector3D(x, y, z); 186 | } 187 | 188 | private void Zoom(Point currentPosition) 189 | { 190 | double yDelta = currentPosition.Y - _previousPosition2D.Y; 191 | 192 | double scale = Math.Exp(yDelta / 100); // e^(yDelta/100) is fairly arbitrary. 193 | 194 | _scale.ScaleX *= scale; 195 | _scale.ScaleY *= scale; 196 | _scale.ScaleZ *= scale; 197 | } 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /3DTools/3DTools/ScreenSpaceLines3D.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | //--------------------------------------------------------------------------- 14 | 15 | using System; 16 | using System.Diagnostics; 17 | using System.Windows; 18 | using System.Windows.Media; 19 | using System.Windows.Media.Media3D; 20 | 21 | namespace _3DTools 22 | { 23 | /// 24 | /// ScreenSpaceLines3D are a 3D line primitive whose thickness 25 | /// is constant in 2D space post projection. 26 | /// 27 | /// This means that the lines do not become foreshortened as 28 | /// they receed from the camera as other 3D primitives do under 29 | /// a typical perspective projection. 30 | /// 31 | /// Example Usage: 32 | /// 33 | /// <tools:ScreenSpaceLines3D 34 | /// Points="0,0,0 0,1,0 0,1,0 1,1,0 1,1,0 0,0,1" 35 | /// Thickness="5" Color="Red"> 36 | /// 37 | /// "Screen space" is a bit of a misnomer as the line thickness 38 | /// is specified in the 2D coordinate system of the container 39 | /// Viewport3D, not the screen. 40 | /// 41 | public class ScreenSpaceLines3D : ModelVisual3D 42 | { 43 | public ScreenSpaceLines3D() 44 | { 45 | _mesh = new MeshGeometry3D(); 46 | _model = new GeometryModel3D(); 47 | _model.Geometry = _mesh; 48 | SetColor(this.Color); 49 | 50 | this.Content = _model; 51 | this.Points = new Point3DCollection(); 52 | 53 | CompositionTarget.Rendering += OnRender; 54 | } 55 | 56 | public static readonly DependencyProperty ColorProperty = 57 | DependencyProperty.Register( 58 | "Color", 59 | typeof(Color), 60 | typeof(ScreenSpaceLines3D), 61 | new PropertyMetadata( 62 | Colors.White, 63 | OnColorChanged)); 64 | 65 | private static void OnColorChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) 66 | { 67 | ((ScreenSpaceLines3D)sender).SetColor((Color) args.NewValue); 68 | } 69 | 70 | private void SetColor(Color color) 71 | { 72 | MaterialGroup unlitMaterial = new MaterialGroup(); 73 | unlitMaterial.Children.Add(new DiffuseMaterial(new SolidColorBrush(Colors.Black))); 74 | unlitMaterial.Children.Add(new EmissiveMaterial(new SolidColorBrush(color))); 75 | unlitMaterial.Freeze(); 76 | 77 | _model.Material = unlitMaterial; 78 | _model.BackMaterial = unlitMaterial; 79 | } 80 | 81 | public Color Color 82 | { 83 | get { return (Color) GetValue(ColorProperty); } 84 | set { SetValue(ColorProperty, value); } 85 | } 86 | 87 | public static readonly DependencyProperty ThicknessProperty = 88 | DependencyProperty.Register( 89 | "Thickness", 90 | typeof(double), 91 | typeof(ScreenSpaceLines3D), 92 | new PropertyMetadata( 93 | 1.0, 94 | OnThicknessChanged)); 95 | 96 | private static void OnThicknessChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) 97 | { 98 | ((ScreenSpaceLines3D)sender).GeometryDirty(); 99 | } 100 | 101 | public double Thickness 102 | { 103 | get { return (double)GetValue(ThicknessProperty); } 104 | set { SetValue(ThicknessProperty, value); } 105 | } 106 | 107 | public static readonly DependencyProperty PointsProperty = 108 | DependencyProperty.Register( 109 | "Points", 110 | typeof(Point3DCollection), 111 | typeof(ScreenSpaceLines3D), 112 | new PropertyMetadata( 113 | null, 114 | OnPointsChanged)); 115 | 116 | private static void OnPointsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) 117 | { 118 | ((ScreenSpaceLines3D)sender).GeometryDirty(); 119 | } 120 | 121 | public Point3DCollection Points 122 | { 123 | get { return (Point3DCollection)GetValue(PointsProperty); } 124 | set { SetValue(PointsProperty, value); } 125 | } 126 | 127 | private void OnRender(object sender, EventArgs e) 128 | { 129 | if (Points.Count == 0 && _mesh.Positions.Count == 0) 130 | { 131 | return; 132 | } 133 | 134 | if (UpdateTransforms()) 135 | { 136 | RebuildGeometry(); 137 | } 138 | } 139 | 140 | private void GeometryDirty() 141 | { 142 | // Force next call to UpdateTransforms() to return true. 143 | _visualToScreen = MathUtils.ZeroMatrix; 144 | } 145 | 146 | private void RebuildGeometry() 147 | { 148 | double halfThickness = Thickness / 2.0; 149 | int numLines = Points.Count / 2; 150 | 151 | Point3DCollection positions = new Point3DCollection(numLines * 4); 152 | 153 | for (int i = 0; i < numLines; i++) 154 | { 155 | int startIndex = i * 2; 156 | 157 | Point3D startPoint = Points[startIndex]; 158 | Point3D endPoint = Points[startIndex + 1]; 159 | 160 | AddSegment(positions, startPoint, endPoint, halfThickness); 161 | } 162 | 163 | positions.Freeze(); 164 | _mesh.Positions = positions; 165 | 166 | Int32Collection indices = new Int32Collection(Points.Count * 3); 167 | 168 | for (int i = 0; i < Points.Count / 2; i++) 169 | { 170 | indices.Add(i * 4 + 2); 171 | indices.Add(i * 4 + 1); 172 | indices.Add(i * 4 + 0); 173 | 174 | indices.Add(i * 4 + 2); 175 | indices.Add(i * 4 + 3); 176 | indices.Add(i * 4 + 1); 177 | } 178 | 179 | indices.Freeze(); 180 | _mesh.TriangleIndices = indices; 181 | } 182 | 183 | private void AddSegment(Point3DCollection positions, Point3D startPoint, Point3D endPoint, double halfThickness) 184 | { 185 | // NOTE: We want the vector below to be perpendicular post projection so 186 | // we need to compute the line direction in post-projective space. 187 | Vector3D lineDirection = endPoint * _visualToScreen - startPoint * _visualToScreen; 188 | lineDirection.Z = 0; 189 | lineDirection.Normalize(); 190 | 191 | // NOTE: Implicit Rot(90) during construction to get a perpendicular vector. 192 | Vector delta = new Vector(-lineDirection.Y, lineDirection.X); 193 | delta *= halfThickness; 194 | 195 | Point3D pOut1, pOut2; 196 | 197 | Widen(startPoint, delta, out pOut1, out pOut2); 198 | 199 | positions.Add(pOut1); 200 | positions.Add(pOut2); 201 | 202 | Widen(endPoint, delta, out pOut1, out pOut2); 203 | 204 | positions.Add(pOut1); 205 | positions.Add(pOut2); 206 | } 207 | 208 | private void Widen(Point3D pIn, Vector delta, out Point3D pOut1, out Point3D pOut2) 209 | { 210 | Point4D pIn4 = (Point4D)pIn; 211 | Point4D pOut41 = pIn4 * _visualToScreen; 212 | Point4D pOut42 = pOut41; 213 | 214 | pOut41.X += delta.X * pOut41.W; 215 | pOut41.Y += delta.Y * pOut41.W; 216 | 217 | pOut42.X -= delta.X * pOut42.W; 218 | pOut42.Y -= delta.Y * pOut42.W; 219 | 220 | pOut41 *= _screenToVisual; 221 | pOut42 *= _screenToVisual; 222 | 223 | // NOTE: Z is not modified above, so we use the original Z below. 224 | 225 | pOut1 = new Point3D( 226 | pOut41.X / pOut41.W, 227 | pOut41.Y / pOut41.W, 228 | pOut41.Z / pOut41.W); 229 | 230 | pOut2 = new Point3D( 231 | pOut42.X / pOut42.W, 232 | pOut42.Y / pOut42.W, 233 | pOut42.Z / pOut42.W); 234 | } 235 | 236 | private bool UpdateTransforms() 237 | { 238 | Viewport3DVisual viewport; 239 | bool success; 240 | 241 | Matrix3D visualToScreen = MathUtils.TryTransformTo2DAncestor(this, out viewport, out success); 242 | 243 | if (!success || !visualToScreen.HasInverse) 244 | { 245 | _mesh.Positions = null; 246 | return false; 247 | } 248 | 249 | if (visualToScreen == _visualToScreen) 250 | { 251 | return false; 252 | } 253 | 254 | _visualToScreen = _screenToVisual = visualToScreen; 255 | _screenToVisual.Invert(); 256 | 257 | return true; 258 | } 259 | 260 | #region MakeWireframe 261 | 262 | public void MakeWireframe(Model3D model) 263 | { 264 | this.Points.Clear(); 265 | 266 | if (model == null) 267 | { 268 | return; 269 | } 270 | 271 | Matrix3DStack transform = new Matrix3DStack(); 272 | transform.Push(Matrix3D.Identity); 273 | 274 | WireframeHelper(model, transform); 275 | } 276 | 277 | private void WireframeHelper(Model3D model, Matrix3DStack matrixStack) 278 | { 279 | Transform3D transform = model.Transform; 280 | 281 | if (transform != null && transform != Transform3D.Identity) 282 | { 283 | matrixStack.Prepend(model.Transform.Value); 284 | } 285 | 286 | try 287 | { 288 | Model3DGroup group = model as Model3DGroup; 289 | 290 | if (group != null) 291 | { 292 | WireframeHelper(group, matrixStack); 293 | return; 294 | } 295 | 296 | GeometryModel3D geometry = model as GeometryModel3D; 297 | 298 | if (geometry != null) 299 | { 300 | WireframeHelper(geometry, matrixStack); 301 | return; 302 | } 303 | } 304 | finally 305 | { 306 | if (transform != null && transform != Transform3D.Identity) 307 | { 308 | matrixStack.Pop(); 309 | } 310 | } 311 | } 312 | 313 | private void WireframeHelper(Model3DGroup group, Matrix3DStack matrixStack) 314 | { 315 | foreach (Model3D child in group.Children) 316 | { 317 | WireframeHelper(child, matrixStack); 318 | } 319 | } 320 | 321 | private void WireframeHelper(GeometryModel3D model, Matrix3DStack matrixStack) 322 | { 323 | Geometry3D geometry = model.Geometry; 324 | MeshGeometry3D mesh = geometry as MeshGeometry3D; 325 | 326 | if (mesh != null) 327 | { 328 | Point3D[] positions = new Point3D[mesh.Positions.Count]; 329 | mesh.Positions.CopyTo(positions, 0); 330 | matrixStack.Peek().Transform(positions); 331 | 332 | Int32Collection indices = mesh.TriangleIndices; 333 | 334 | if (indices.Count > 0) 335 | { 336 | int limit = positions.Length - 1; 337 | 338 | for (int i = 2, count = indices.Count; i < count; i += 3) 339 | { 340 | int i0 = indices[i - 2]; 341 | int i1 = indices[i - 1]; 342 | int i2 = indices[i]; 343 | 344 | // WPF halts rendering on the first deformed triangle. We should 345 | // do the same. 346 | if ((0 > i0 || i0 > limit) 347 | || (0 > i1 || i1 > limit) 348 | || (0 > i2 || i2 > limit)) 349 | { 350 | break; 351 | } 352 | 353 | AddTriangle(positions, i0, i1, i2); 354 | } 355 | } 356 | else 357 | { 358 | for (int i = 2, count = positions.Length; i < count; i += 3) 359 | { 360 | int i0 = i - 2; 361 | int i1 = i - 1; 362 | int i2 = i; 363 | 364 | AddTriangle(positions, i0, i1, i2); 365 | } 366 | } 367 | } 368 | } 369 | 370 | private void AddTriangle(Point3D[] positions, int i0, int i1, int i2) 371 | { 372 | Points.Add(positions[i0]); 373 | Points.Add(positions[i1]); 374 | Points.Add(positions[i1]); 375 | Points.Add(positions[i2]); 376 | Points.Add(positions[i2]); 377 | Points.Add(positions[i0]); 378 | } 379 | 380 | #endregion MakeWireframe 381 | 382 | private Matrix3D _visualToScreen; 383 | private Matrix3D _screenToVisual; 384 | private readonly GeometryModel3D _model; 385 | private readonly MeshGeometry3D _mesh; 386 | } 387 | } 388 | -------------------------------------------------------------------------------- /3DTools/3DTools/MeshUtils.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | // 3 | // (c) Copyright Microsoft Corporation. 4 | // This source is subject to the Microsoft Limited Permissive License. 5 | // See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx 6 | // All other rights reserved. 7 | // 8 | // This file is part of the 3D Tools for Windows Presentation Foundation 9 | // project. For more information, see: 10 | // 11 | // http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools 12 | // 13 | //--------------------------------------------------------------------------- 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Diagnostics; 18 | using System.Windows; 19 | using System.Windows.Data; 20 | using System.Windows.Media; 21 | using System.Windows.Media.Media3D; 22 | 23 | namespace _3DTools 24 | { 25 | #region Mesh IValueConverters 26 | 27 | /// 28 | /// Abstract base class for all type converters that have a MeshGeometry3D source 29 | /// 30 | public abstract class MeshConverter : IValueConverter 31 | { 32 | public MeshConverter() 33 | { 34 | } 35 | 36 | /// 37 | /// IValueConverter.Convert 38 | /// 39 | /// The binding source (should be a MeshGeometry3D) 40 | /// The binding target 41 | /// Optionaly parameter to the converter 42 | /// (ignored) 43 | /// The converted value 44 | object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 45 | { 46 | if (value == null) 47 | { 48 | return DependencyProperty.UnsetValue; 49 | } 50 | 51 | if (targetType != typeof(TargetType)) 52 | { 53 | throw new ArgumentException(String.Format("MeshConverter must target a {0}", typeof(TargetType).Name)); 54 | } 55 | 56 | MeshGeometry3D mesh = value as MeshGeometry3D; 57 | if (mesh == null) 58 | { 59 | throw new ArgumentException("MeshConverter can only convert from a MeshGeometry3D"); 60 | } 61 | 62 | return Convert(mesh, parameter); 63 | } 64 | 65 | /// 66 | /// IValueConverter.ConvertBack 67 | /// 68 | /// Not implemented 69 | /// 70 | object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 71 | { 72 | throw new NotImplementedException(); 73 | } 74 | 75 | /// 76 | /// Subclasses should override this to do conversion 77 | /// 78 | /// The mesh source 79 | /// Optional converter argument 80 | /// The converted value 81 | public abstract object Convert(MeshGeometry3D mesh, object parameter); 82 | } 83 | 84 | /// 85 | /// MeshTextureCoordinateConverter 86 | /// 87 | /// A MeshConverter that returns a PointCollection and takes an optional direction argument 88 | /// 89 | public abstract class MeshTextureCoordinateConverter : MeshConverter 90 | { 91 | public MeshTextureCoordinateConverter() 92 | { 93 | } 94 | 95 | /// 96 | /// 97 | /// 98 | /// The source mesh 99 | /// The optional parameter 100 | /// The converted value 101 | public override object Convert(MeshGeometry3D mesh, object parameter) 102 | { 103 | string paramAsString = parameter as string; 104 | if (parameter != null && paramAsString == null) 105 | { 106 | throw new ArgumentException("Parameter must be a string."); 107 | } 108 | 109 | // Default to the positive Y axis 110 | Vector3D dir = MathUtils.YAxis; 111 | 112 | if (paramAsString != null) 113 | { 114 | dir = Vector3D.Parse(paramAsString); 115 | MathUtils.TryNormalize(ref dir); 116 | } 117 | 118 | return Convert(mesh, dir); 119 | } 120 | 121 | /// 122 | /// Subclasses should override this to do conversion 123 | /// 124 | /// The source mesh 125 | /// The normalized direction parameter 126 | /// 127 | public abstract object Convert(MeshGeometry3D mesh, Vector3D dir); 128 | } 129 | 130 | /// 131 | /// IValueConverter that generates texture coordinates for a plane. 132 | /// 133 | public class PlanarTextureCoordinateGenerator : MeshTextureCoordinateConverter 134 | { 135 | public PlanarTextureCoordinateGenerator() 136 | { 137 | } 138 | 139 | public override object Convert(MeshGeometry3D mesh, Vector3D dir) 140 | { 141 | return MeshUtils.GeneratePlanarTextureCoordinates(mesh, dir); 142 | } 143 | } 144 | 145 | /// 146 | /// IValueConverter that generates texture coordinates for a sphere. 147 | /// 148 | public class SphericalTextureCoordinateGenerator : MeshTextureCoordinateConverter 149 | { 150 | public SphericalTextureCoordinateGenerator() 151 | { 152 | } 153 | 154 | public override object Convert(MeshGeometry3D mesh, Vector3D dir) 155 | { 156 | return MeshUtils.GenerateSphericalTextureCoordinates(mesh, dir); 157 | } 158 | } 159 | 160 | /// 161 | /// IValueConverter that generates texture coordinates for a cylinder 162 | /// 163 | public class CylindricalTextureCoordinateGenerator : MeshTextureCoordinateConverter 164 | { 165 | public CylindricalTextureCoordinateGenerator() 166 | { 167 | } 168 | 169 | public override object Convert(MeshGeometry3D mesh, Vector3D dir) 170 | { 171 | return MeshUtils.GenerateCylindricalTextureCoordinates(mesh, dir); 172 | } 173 | } 174 | 175 | #endregion 176 | 177 | public static class MeshUtils 178 | { 179 | #region Texture Coordinate Generation Methods 180 | 181 | /// 182 | /// Generates texture coordinates as if mesh were a cylinder. 183 | /// 184 | /// Notes: 185 | /// 1) v is flipped for you automatically 186 | /// 2) 'mesh' is not modified. If you want the generated coordinates 187 | /// to be assigned to mesh, do: 188 | /// 189 | /// mesh.TextureCoordinates = GenerateCylindricalTextureCoordinates(mesh, foo) 190 | /// 191 | /// 192 | /// The mesh 193 | /// The axis of rotation for the cylinder 194 | /// The generated texture coordinates 195 | public static PointCollection GenerateCylindricalTextureCoordinates(MeshGeometry3D mesh, Vector3D dir) 196 | { 197 | if (mesh == null) 198 | { 199 | return null; 200 | } 201 | 202 | Rect3D bounds = mesh.Bounds; 203 | int count = mesh.Positions.Count; 204 | PointCollection texcoords = new PointCollection(count); 205 | IEnumerable positions = TransformPoints(ref bounds, mesh.Positions, ref dir); 206 | 207 | foreach (Point3D vertex in positions) 208 | { 209 | texcoords.Add(new Point( 210 | GetUnitCircleCoordinate(-vertex.Z, vertex.X), 211 | 1.0 - GetPlanarCoordinate(vertex.Y, bounds.Y, bounds.SizeY) 212 | )); 213 | } 214 | 215 | return texcoords; 216 | } 217 | 218 | /// 219 | /// Generates texture coordinates as if mesh were a sphere. 220 | /// 221 | /// Notes: 222 | /// 1) v is flipped for you automatically 223 | /// 2) 'mesh' is not modified. If you want the generated coordinates 224 | /// to be assigned to mesh, do: 225 | /// 226 | /// mesh.TextureCoordinates = GenerateSphericalTextureCoordinates(mesh, foo) 227 | /// 228 | /// 229 | /// The mesh 230 | /// The axis of rotation for the sphere 231 | /// The generated texture coordinates 232 | public static PointCollection GenerateSphericalTextureCoordinates(MeshGeometry3D mesh, Vector3D dir) 233 | { 234 | if (mesh == null) 235 | { 236 | return null; 237 | } 238 | 239 | Rect3D bounds = mesh.Bounds; 240 | int count = mesh.Positions.Count; 241 | PointCollection texcoords = new PointCollection(count); 242 | IEnumerable positions = TransformPoints(ref bounds, mesh.Positions, ref dir); 243 | 244 | foreach (Point3D vertex in positions) 245 | { 246 | // Don't need to do 'vertex - center' since TransformPoints put us 247 | // at the origin 248 | Vector3D radius = new Vector3D(vertex.X, vertex.Y, vertex.Z); 249 | MathUtils.TryNormalize(ref radius); 250 | 251 | texcoords.Add(new Point( 252 | GetUnitCircleCoordinate(-radius.Z, radius.X), 253 | 1.0 - (Math.Asin(radius.Y) / Math.PI + 0.5) 254 | )); 255 | } 256 | 257 | return texcoords; 258 | } 259 | 260 | /// 261 | /// Generates texture coordinates as if mesh were a plane. 262 | /// 263 | /// Notes: 264 | /// 1) v is flipped for you automatically 265 | /// 2) 'mesh' is not modified. If you want the generated coordinates 266 | /// to be assigned to mesh, do: 267 | /// 268 | /// mesh.TextureCoordinates = GeneratePlanarTextureCoordinates(mesh, foo) 269 | /// 270 | /// 271 | /// The mesh 272 | /// The normal of the plane 273 | /// The generated texture coordinates 274 | public static PointCollection GeneratePlanarTextureCoordinates(MeshGeometry3D mesh, Vector3D dir) 275 | { 276 | if (mesh == null) 277 | { 278 | return null; 279 | } 280 | 281 | Rect3D bounds = mesh.Bounds; 282 | int count = mesh.Positions.Count; 283 | PointCollection texcoords = new PointCollection(count); 284 | IEnumerable positions = TransformPoints(ref bounds, mesh.Positions, ref dir); 285 | 286 | foreach (Point3D vertex in positions) 287 | { 288 | // The plane is looking along positive Y, so Z is really Y 289 | 290 | texcoords.Add(new Point( 291 | GetPlanarCoordinate(vertex.X, bounds.X, bounds.SizeX), 292 | GetPlanarCoordinate(vertex.Z, bounds.Z, bounds.SizeZ) 293 | )); 294 | } 295 | 296 | return texcoords; 297 | } 298 | 299 | #endregion 300 | 301 | internal static double GetPlanarCoordinate(double end, double start, double width) 302 | { 303 | return (end - start) / width; 304 | } 305 | 306 | internal static double GetUnitCircleCoordinate(double y, double x) 307 | { 308 | return Math.Atan2(y, x) / (2.0 * Math.PI) + 0.5; 309 | } 310 | 311 | /// 312 | /// Finds the transform from 'dir' to '<0, 1, 0>' and transforms 'bounds' 313 | /// and 'points' by it. 314 | /// 315 | /// The bounds to transform 316 | /// The vertices to transform 317 | /// The orientation of the mesh 318 | /// 319 | /// The transformed points. If 'dir' is already '<0, 1, 0>' then this 320 | /// will equal 'points.' 321 | /// 322 | internal static IEnumerable TransformPoints(ref Rect3D bounds, Point3DCollection points, ref Vector3D dir) 323 | { 324 | if (dir == MathUtils.YAxis) 325 | { 326 | return points; 327 | } 328 | 329 | Vector3D rotAxis = Vector3D.CrossProduct(dir, MathUtils.YAxis); 330 | double rotAngle = Vector3D.AngleBetween(dir, MathUtils.YAxis); 331 | Quaternion q; 332 | 333 | if (rotAxis.X != 0 || rotAxis.Y != 0 || rotAxis.Z != 0) 334 | { 335 | Debug.Assert(rotAngle != 0); 336 | 337 | q = new Quaternion(rotAxis, rotAngle); 338 | } 339 | else 340 | { 341 | Debug.Assert(dir == -MathUtils.YAxis); 342 | 343 | q = new Quaternion(MathUtils.XAxis, rotAngle); 344 | } 345 | 346 | Vector3D center = new Vector3D( 347 | bounds.X + bounds.SizeX / 2, 348 | bounds.Y + bounds.SizeY / 2, 349 | bounds.Z + bounds.SizeZ / 2 350 | ); 351 | 352 | Matrix3D t = Matrix3D.Identity; 353 | t.Translate(-center); 354 | t.Rotate(q); 355 | 356 | int count = points.Count; 357 | Point3D[] transformedPoints = new Point3D[count]; 358 | 359 | for (int i = 0; i < count; i++) 360 | { 361 | transformedPoints[i] = t.Transform(points[i]); 362 | } 363 | 364 | // Finally, transform the bounds too 365 | bounds = MathUtils.TransformBounds(bounds, t); 366 | 367 | return transformedPoints; 368 | } 369 | } 370 | } 371 | --------------------------------------------------------------------------------