From 8b991ecaaa5bfb6e682f73e426b136600d249f4e Mon Sep 17 00:00:00 2001 From: Robin Sedlaczek Date: Wed, 8 Oct 2014 18:02:02 +0200 Subject: [PATCH 1/3] Implement IHasObjectSpace for Teapot. --- .../Core/IHasObjectSpace.cs | 1 + .../Evaluators/Evaluator.cs | 1 + .../SharpGL.SceneGraph/Primitives/Teapot.cs | 39 ++++++++++++++ .../SharpGL.SceneGraph/Quadrics/Quadric.cs | 1 + .../WPF/TeapotSample/MainWindow.xaml.cs | 14 +---- .../Tools/SceneBuilder/SceneBuilder.csproj | 19 +++---- .../Tools/SharpGLStudio/MainWindow.xaml.cs | 15 +----- .../Tools/SharpGLStudio/SharpGLStudio.csproj | 51 ++++++++++++------- 8 files changed, 86 insertions(+), 55 deletions(-) diff --git a/source/SharpGL/Core/SharpGL.SceneGraph/Core/IHasObjectSpace.cs b/source/SharpGL/Core/SharpGL.SceneGraph/Core/IHasObjectSpace.cs index 06848fa8..df36bdf4 100644 --- a/source/SharpGL/Core/SharpGL.SceneGraph/Core/IHasObjectSpace.cs +++ b/source/SharpGL/Core/SharpGL.SceneGraph/Core/IHasObjectSpace.cs @@ -29,6 +29,7 @@ public interface IHasObjectSpace /// LinearTransformation Transformation { + set; get; } } diff --git a/source/SharpGL/Core/SharpGL.SceneGraph/Evaluators/Evaluator.cs b/source/SharpGL/Core/SharpGL.SceneGraph/Evaluators/Evaluator.cs index a555c4b9..8ca93428 100644 --- a/source/SharpGL/Core/SharpGL.SceneGraph/Evaluators/Evaluator.cs +++ b/source/SharpGL/Core/SharpGL.SceneGraph/Evaluators/Evaluator.cs @@ -120,6 +120,7 @@ public bool DrawControlGrid [Description("The Quadric Object Space Transformation"), Category("Evaluator")] public LinearTransformation Transformation { + set { hasObjectSpaceHelper.Transformation = value; } get { return hasObjectSpaceHelper.Transformation; } } } diff --git a/source/SharpGL/Core/SharpGL.SceneGraph/Primitives/Teapot.cs b/source/SharpGL/Core/SharpGL.SceneGraph/Primitives/Teapot.cs index b96ef485..1f2dbf79 100644 --- a/source/SharpGL/Core/SharpGL.SceneGraph/Primitives/Teapot.cs +++ b/source/SharpGL/Core/SharpGL.SceneGraph/Primitives/Teapot.cs @@ -1,7 +1,10 @@ using System; +using System.ComponentModel; using System.Runtime.InteropServices; using SharpGL.SceneGraph.Core; using SharpGL.SceneGraph.Assets; +using SharpGL.SceneGraph.Helpers; +using SharpGL.SceneGraph.Transformations; namespace SharpGL.SceneGraph.Primitives { @@ -10,9 +13,15 @@ namespace SharpGL.SceneGraph.Primitives /// public class Teapot : SceneElement, + IHasObjectSpace, IRenderable, IHasMaterial { + /// + /// The IHasObjectSpace helper. + /// + private HasObjectSpaceHelper hasObjectSpaceHelper = new HasObjectSpaceHelper(); + /// /// Initializes a new instance of the class. /// @@ -240,6 +249,36 @@ public Material Material get; set; } + + /// + /// Pushes us into Object Space using the transformation into the specified OpenGL instance. + /// + /// The OpenGL instance. + public void PushObjectSpace(OpenGL gl) + { + // Use the helper to push us into object space. + hasObjectSpaceHelper.PushObjectSpace(gl); + } + + /// + /// Pops us from Object Space using the transformation into the specified OpenGL instance. + /// + /// The gl. + public void PopObjectSpace(OpenGL gl) + { + // Use the helper to pop us from object space. + hasObjectSpaceHelper.PopObjectSpace(gl); + } + + /// + /// Gets the transformation that pushes us into object space. + /// + [Description("The Teapot Object Space Transformation"), Category("Teapot")] + public LinearTransformation Transformation + { + get { return hasObjectSpaceHelper.Transformation; } + set { hasObjectSpaceHelper.Transformation = value; } + } } /// diff --git a/source/SharpGL/Core/SharpGL.SceneGraph/Quadrics/Quadric.cs b/source/SharpGL/Core/SharpGL.SceneGraph/Quadrics/Quadric.cs index 5cc42652..ba037424 100644 --- a/source/SharpGL/Core/SharpGL.SceneGraph/Quadrics/Quadric.cs +++ b/source/SharpGL/Core/SharpGL.SceneGraph/Quadrics/Quadric.cs @@ -158,6 +158,7 @@ public bool TextureCoords [Description("The Quadric Object Space Transformation"), Category("Quadric")] public LinearTransformation Transformation { + set { hasObjectSpaceHelper.Transformation = value; } get { return hasObjectSpaceHelper.Transformation; } } diff --git a/source/SharpGL/Samples/WPF/TeapotSample/MainWindow.xaml.cs b/source/SharpGL/Samples/WPF/TeapotSample/MainWindow.xaml.cs index 923f5329..b5dccb0e 100644 --- a/source/SharpGL/Samples/WPF/TeapotSample/MainWindow.xaml.cs +++ b/source/SharpGL/Samples/WPF/TeapotSample/MainWindow.xaml.cs @@ -1,16 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; +using System.Windows; using SharpGL; using SharpGL.SceneGraph.Primitives; using SharpGL.SceneGraph; diff --git a/source/SharpGL/Tools/SceneBuilder/SceneBuilder.csproj b/source/SharpGL/Tools/SceneBuilder/SceneBuilder.csproj index ea354122..20f23ca4 100644 --- a/source/SharpGL/Tools/SceneBuilder/SceneBuilder.csproj +++ b/source/SharpGL/Tools/SceneBuilder/SceneBuilder.csproj @@ -122,15 +122,6 @@ System.XML - - {B2984A6D-AD1C-4BE9-94AB-BA002B338751} - SharpGL.WinForms - - - SharpGL - {5EF45533-E2C7-46F2-B4A3-B8F36CD406E0} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - @@ -199,6 +190,16 @@ + + + {b2984a6d-ad1c-4be9-94ab-ba002b338751} + SharpGL.WinForms + + + {5ef45533-e2c7-46f2-b4a3-b8f36cd406e0} + SharpGL + + diff --git a/source/SharpGL/Tools/SharpGLStudio/MainWindow.xaml.cs b/source/SharpGL/Tools/SharpGLStudio/MainWindow.xaml.cs index 48174f1c..7302e2e9 100644 --- a/source/SharpGL/Tools/SharpGLStudio/MainWindow.xaml.cs +++ b/source/SharpGL/Tools/SharpGLStudio/MainWindow.xaml.cs @@ -1,17 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using Microsoft.Windows.Controls.Ribbon; +using Microsoft.Windows.Controls.Ribbon; using Apex.MVVM; using Microsoft.Win32; using SharpGL.SceneGraph; diff --git a/source/SharpGL/Tools/SharpGLStudio/SharpGLStudio.csproj b/source/SharpGL/Tools/SharpGLStudio/SharpGLStudio.csproj index 9c686246..2ec493e5 100644 --- a/source/SharpGL/Tools/SharpGLStudio/SharpGLStudio.csproj +++ b/source/SharpGL/Tools/SharpGLStudio/SharpGLStudio.csproj @@ -24,6 +24,8 @@ + ..\..\ + true x86 @@ -49,9 +51,13 @@ False ..\..\Dependencies\Apex.dll + + False + C:\Program Files (x86)\Microsoft Ribbon for WPF\V3.5\Microsoft.Windows.Shell.dll + False - ..\..\Dependencies\RibbonControlsLibrary.dll + C:\Program Files (x86)\Microsoft Ribbon for WPF\V3.5\RibbonControlsLibrary.dll @@ -142,24 +148,6 @@ - - - {47BCAA39-EDAD-4404-B6BD-4742B0ABB523} - SharpGL.SceneGraph - - - {FDFA2632-A960-4778-A517-CA9E337C037C} - SharpGL.Serialization - - - {53E67055-13D2-4467-BB57-79589AFAC2CD} - SharpGL.WPF - - - {5EF45533-E2C7-46F2-B4A3-B8F36CD406E0} - SharpGL - - @@ -251,7 +239,32 @@ + + + {47bcaa39-edad-4404-b6bd-4742b0abb523} + SharpGL.SceneGraph + + + {fdfa2632-a960-4778-a517-ca9e337c037c} + SharpGL.Serialization + + + {53e67055-13d2-4467-bb57-79589afac2cd} + SharpGL.WPF + + + {5ef45533-e2c7-46f2-b4a3-b8f36cd406e0} + SharpGL + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + +