<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="/rss.xsl"?><rss version="2.0"><channel><title>3D Tools for the Windows Presentation Foundation</title><link>http://3dtools.codeplex.com/project/feeds/rss</link><description>A collection of tools to help developers using the 3D features in the Windows Presentation Foundation.  This project currently includes utility code for rotating the camera with the mouse, drawing fixed width lines in 3D, and automatically generating texture coordinates.</description><item><title>New Post: How to create a circle with known center point and perpendicular to a line?</title><link>http://3dtools.codeplex.com/discussions/428741</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;Hi, sorry for asking such a beginner question, I am a beginner in WPF 3D programming.&amp;nbsp;How to create a circle with known center point and perpendicular to a line? Thank in advance.&lt;/p&gt;
&lt;/div&gt;</description><author>chinh_nguyen</author><pubDate>Mon, 07 Jan 2013 11:34:41 GMT</pubDate><guid isPermaLink="false">New Post: How to create a circle with known center point and perpendicular to a line? 20130107113441A</guid></item><item><title>New Post: How to create a circle with known center point and perpendicular to a line?</title><link>http://3dtools.codeplex.com/discussions/428741</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;Hi, sorry for asking such a beginner question, I am a beginner in WPF 3D programming.&amp;nbsp;How to create a circle with known center point and perpendicular to a line? Thank in advance.&lt;/p&gt;
&lt;/div&gt;</description><author>chinh_nguyen</author><pubDate>Mon, 07 Jan 2013 11:34:41 GMT</pubDate><guid isPermaLink="false">New Post: How to create a circle with known center point and perpendicular to a line? 20130107113441A</guid></item><item><title>Source code checked in, #99885</title><link>http://3dtools.codeplex.com/SourceControl/changeset/changes/99885</link><description>Upgrade&amp;#58; New Version of LabDefaultTemplate.xaml. To upgrade your build definitions, please visit the following link&amp;#58; http&amp;#58;&amp;#47;&amp;#47;go.microsoft.com&amp;#47;fwlink&amp;#47;&amp;#63;LinkId&amp;#61;254563</description><author>Project Collection Service Accounts</author><pubDate>Mon, 01 Oct 2012 21:24:31 GMT</pubDate><guid isPermaLink="false">Source code checked in, #99885 20121001092431P</guid></item><item><title>Source code checked in, #99884</title><link>http://3dtools.codeplex.com/SourceControl/changeset/changes/99884</link><description>Checked in by server upgrade</description><author>Project Collection Service Accounts</author><pubDate>Mon, 01 Oct 2012 21:16:08 GMT</pubDate><guid isPermaLink="false">Source code checked in, #99884 20121001091608P</guid></item><item><title>Created Issue: Namespace _3DTools [33148]</title><link>http://3dtools.codeplex.com/workitem/33148</link><description>_3DTools is not a good namespace at all. It will generate warnings in code quality checkers because of the leading underscore.&lt;br /&gt;You can use any other like WPF.3DTools or similar&lt;br /&gt;</description><author>jaime_olivares</author><pubDate>Sat, 22 Sep 2012 16:26:06 GMT</pubDate><guid isPermaLink="false">Created Issue: Namespace _3DTools [33148] 20120922042606P</guid></item><item><title>New Post: keyboard functionality</title><link>http://3dtools.codeplex.com/discussions/389570</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;How can I setup trackball to perform rotation instead mousebutton's press?&lt;br&gt;
&lt;br&gt;
I've tried creating a function similar to Track but something still not work correctly.&lt;br&gt;
&lt;br&gt;
Thank to all&lt;/p&gt;
&lt;/div&gt;</description><author>naryk</author><pubDate>Mon, 30 Jul 2012 14:26:13 GMT</pubDate><guid isPermaLink="false">New Post: keyboard functionality 20120730022613P</guid></item><item><title>New Post: keyboard functionality</title><link>http://3dtools.codeplex.com/discussions/389570</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;How can I setup trackball to perform rotation instead mousebutton's press?&lt;br&gt;
&lt;br&gt;
I've tried creating a function similar to Track but something still not work correctly.&lt;br&gt;
&lt;br&gt;
Thank to all&lt;/p&gt;
&lt;/div&gt;</description><author>naryk</author><pubDate>Mon, 30 Jul 2012 14:26:13 GMT</pubDate><guid isPermaLink="false">New Post: keyboard functionality 20120730022613P</guid></item><item><title>New Post: keyboard functionality</title><link>http://3dtools.codeplex.com/discussions/389570</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;How can I setup trackball to perform rotation instead mousebutton's press?&lt;br&gt;
&lt;br&gt;
I've tried creating a function similar to Track but something still not work correctly.&lt;br&gt;
&lt;br&gt;
Thank to all&lt;/p&gt;
&lt;/div&gt;</description><author>naryk</author><pubDate>Mon, 30 Jul 2012 14:26:13 GMT</pubDate><guid isPermaLink="false">New Post: keyboard functionality 20120730022613P</guid></item><item><title>New Post: keyboard functionality</title><link>http://3dtools.codeplex.com/discussions/389570</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;How can I setup trackball to perform rotation instead mousebutton's press?&lt;br&gt;
&lt;br&gt;
I've tried creating a function similar to Track but something still not work correctly.&lt;br&gt;
&lt;br&gt;
Thank to all&lt;/p&gt;
&lt;/div&gt;</description><author>naryk</author><pubDate>Mon, 30 Jul 2012 14:26:13 GMT</pubDate><guid isPermaLink="false">New Post: keyboard functionality 20120730022613P</guid></item><item><title>New Post: create pipes</title><link>http://3dtools.codeplex.com/discussions/360824</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;Hello!&lt;br&gt;
I've created a 3d line adding points to a ScreenSpaceLines3D object.&lt;br&gt;
Is there a way to create a &amp;quot;pipeline&amp;quot; instead of a flat line???&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Naryk&lt;/p&gt;
&lt;/div&gt;</description><author>naryk</author><pubDate>Mon, 25 Jun 2012 14:49:39 GMT</pubDate><guid isPermaLink="false">New Post: create pipes 20120625024939P</guid></item><item><title>New Post: create pipes</title><link>http://3dtools.codeplex.com/discussions/360824</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;Hello!&lt;br&gt;
I've created a 3d line adding points to a ScreenSpaceLines3D object.&lt;br&gt;
Is there a way to create a &amp;quot;pipeline&amp;quot; instead of a flat line???&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Naryk&lt;/p&gt;
&lt;/div&gt;</description><author>naryk</author><pubDate>Mon, 25 Jun 2012 14:49:39 GMT</pubDate><guid isPermaLink="false">New Post: create pipes 20120625024939P</guid></item><item><title>New Post: create pipes</title><link>http://3dtools.codeplex.com/discussions/360824</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;Hello!&lt;br&gt;
I've created a 3d line adding points to a ScreenSpaceLines3D object.&lt;br&gt;
Is there a way to create a &amp;quot;pipeline&amp;quot; instead of a flat line???&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Naryk&lt;/p&gt;
&lt;/div&gt;</description><author>naryk</author><pubDate>Mon, 25 Jun 2012 14:49:39 GMT</pubDate><guid isPermaLink="false">New Post: create pipes 20120625024939P</guid></item><item><title>New Post: create pipes</title><link>http://3dtools.codeplex.com/discussions/360824</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;Hello!&lt;br&gt;
I've created a 3d line adding points to a ScreenSpaceLines3D object.&lt;br&gt;
Is there a way to create a &amp;quot;pipeline&amp;quot; instead of a flat line???&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Naryk&lt;/p&gt;
&lt;/div&gt;</description><author>naryk</author><pubDate>Mon, 25 Jun 2012 14:49:39 GMT</pubDate><guid isPermaLink="false">New Post: create pipes 20120625024939P</guid></item><item><title>New Post: Helix Toolkit (active WPF 3D controls project)</title><link>http://3dtools.codeplex.com/discussions/357683</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;I'd just like to add a link to the excellent &lt;a href="http://helixtoolkit.codeplex.com/"&gt;
Helix 3D Toolkit&amp;nbsp;&lt;/a&gt;, which is a collection of controls and helper classes for WPF 3D. It is an active project that includes improved versions of everything from 3D Tools and a lot more. It is published under the Ms-Pl license, which is a bit more liberal
 that the 3D Tools license.&lt;/p&gt;
&lt;p&gt;I have been using the Helix 3D Viewport for nearly two years, and it works very well.&amp;nbsp;This 3D Tools project was an interesting start, but has not been active for many years, and finding Helix toolkit made it easy to stick with WPF 3D.&lt;/p&gt;
&lt;p&gt;So, definitely worth a look if you are interested in WPF 3D at all.&lt;/p&gt;
&lt;div id="_mcePaste" style="left:-10000px; top:0px; width:1px; height:1px; overflow:hidden"&gt;
&lt;h1 style="font-size:2.308em; margin:20px 0px 10px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent; font-weight:lighter; font-family:'Segoe UI Light','Segoe UI','Tahoma Light','Arial Light',Helvetica,sans-serif; color:#7b4f9d"&gt;
Ms-PL&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;</description><author>govert</author><pubDate>Wed, 30 May 2012 16:02:47 GMT</pubDate><guid isPermaLink="false">New Post: Helix Toolkit (active WPF 3D controls project) 20120530040247P</guid></item><item><title>New Post: Helix Toolkit (active WPF 3D controls project)</title><link>http://3dtools.codeplex.com/discussions/357683</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;I'd just like to add a link to the excellent &lt;a href="http://helixtoolkit.codeplex.com/"&gt;
Helix 3D Toolkit&amp;nbsp;&lt;/a&gt;, which is a collection of controls and helper classes for WPF 3D. It is an active project that includes improved versions of everything from 3D Tools and a lot more. It is published under the Ms-Pl license, which is a bit more liberal
 that the 3D Tools license.&lt;/p&gt;
&lt;p&gt;I have been using the Helix 3D Viewport for nearly two years, and it works very well.&amp;nbsp;This 3D Tools project was an interesting start, but has not been active for many years, and finding Helix toolkit made it easy to stick with WPF 3D.&lt;/p&gt;
&lt;p&gt;So, definitely worth a look if you are interested in WPF 3D at all.&lt;/p&gt;
&lt;div id="_mcePaste" style="left:-10000px; top:0px; width:1px; height:1px; overflow:hidden"&gt;
&lt;h1 style="font-size:2.308em; margin:20px 0px 10px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent; font-weight:lighter; font-family:'Segoe UI Light','Segoe UI','Tahoma Light','Arial Light',Helvetica,sans-serif; color:#7b4f9d"&gt;
Ms-PL&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;</description><author>govert</author><pubDate>Wed, 30 May 2012 16:02:47 GMT</pubDate><guid isPermaLink="false">New Post: Helix Toolkit (active WPF 3D controls project) 20120530040247P</guid></item><item><title>New Post: WheelZoom</title><link>http://3dtools.codeplex.com/discussions/355203</link><description>&lt;div style="line-height: normal;"&gt;&lt;p&gt;I rewrote the TrackBallDecorator to have Pan on left button, rotate on right and zoom on wheel.&lt;/p&gt;
&lt;p&gt;The rotation is a bit strange but the rest works ok:&lt;/p&gt;
&lt;p&gt;
&lt;div style="color: black; background-color: white;"&gt;
&lt;pre&gt;&lt;span style="color: green;"&gt;//---------------------------------------------------------------------------&lt;/span&gt;
&lt;span style="color: green;"&gt;//&lt;/span&gt;
&lt;span style="color: green;"&gt;// (c) Copyright Microsoft Corporation.&lt;/span&gt;
&lt;span style="color: green;"&gt;// This source is subject to the Microsoft Limited Permissive License.&lt;/span&gt;
&lt;span style="color: green;"&gt;// See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx&lt;/span&gt;
&lt;span style="color: green;"&gt;// All other rights reserved.&lt;/span&gt;
&lt;span style="color: green;"&gt;//&lt;/span&gt;
&lt;span style="color: green;"&gt;// This file is part of the 3D Tools for Windows Presentation Foundation&lt;/span&gt;
&lt;span style="color: green;"&gt;// project.  For more information, see:&lt;/span&gt;
&lt;span style="color: green;"&gt;// &lt;/span&gt;
&lt;span style="color: green;"&gt;// http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools&lt;/span&gt;
&lt;span style="color: green;"&gt;//&lt;/span&gt;
&lt;span style="color: green;"&gt;// The following article discusses the mechanics behind this&lt;/span&gt;
&lt;span style="color: green;"&gt;// trackball implementation: http://viewport3d.com/trackball.htm&lt;/span&gt;
&lt;span style="color: green;"&gt;//&lt;/span&gt;
&lt;span style="color: green;"&gt;// Reading the article is not required to use this sample code,&lt;/span&gt;
&lt;span style="color: green;"&gt;// but skimming it might be useful.&lt;/span&gt;
&lt;span style="color: green;"&gt;//&lt;/span&gt;
&lt;span style="color: green;"&gt;//---------------------------------------------------------------------------&lt;/span&gt;

&lt;span style="color: blue;"&gt;using&lt;/span&gt; System;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Collections;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Controls;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Data;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Documents;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Media;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Media.Imaging;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Media.Media3D;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Shapes;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Input;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Markup; &lt;span style="color: green;"&gt;// IAddChild, ContentPropertyAttribute&lt;/span&gt;

&lt;span style="color: blue;"&gt;namespace&lt;/span&gt; _3DTools
{
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; TrackballDecorator : Viewport3DDecorator
    {
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; TrackballDecorator()
        {
            &lt;span style="color: green;"&gt;// used so that we always get events while activity occurs within&lt;/span&gt;
            &lt;span style="color: green;"&gt;// the viewport3D&lt;/span&gt;
            _eventSource = &lt;span style="color: blue;"&gt;new&lt;/span&gt; Border();
            _eventSource.Background = Brushes.Transparent;
            
            PreViewportChildren.Add(_eventSource);
        }

        &lt;span style="color: gray;"&gt;///&lt;/span&gt; &lt;span style="color: gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt;     A transform to move the camera or scene to the trackball's&lt;/span&gt;
        &lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt;     current orientation and scale.&lt;/span&gt;
        &lt;span style="color: gray;"&gt;///&lt;/span&gt; &lt;span style="color: gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; Transform3D Transform
        {
            &lt;span style="color: blue;"&gt;get&lt;/span&gt;
            {
                &lt;span style="color: blue;"&gt;if&lt;/span&gt; (&lt;span style="color: blue;"&gt;this&lt;/span&gt;.Viewport3D == &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
                    &lt;span style="color: blue;"&gt;return&lt;/span&gt; Transform3D.Identity;
                &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Viewport3D.Camera.Transform;
            }
        }

        &lt;span style="color: blue;"&gt;#region&lt;/span&gt; Event Handling

        &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnMouseDown(MouseButtonEventArgs e)
        {
            &lt;span style="color: blue;"&gt;base&lt;/span&gt;.OnMouseDown(e);

            _previousPosition2D = e.GetPosition(&lt;span style="color: blue;"&gt;this&lt;/span&gt;);
            _previousPosition3D = ProjectToTrackball(ActualWidth, ActualHeight, _previousPosition2D);
            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (Mouse.Captured == &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
            {
                Mouse.Capture(&lt;span style="color: blue;"&gt;this&lt;/span&gt;, CaptureMode.Element);
            }
        }

        &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnMouseUp(MouseButtonEventArgs e)
        {
            &lt;span style="color: blue;"&gt;base&lt;/span&gt;.OnMouseUp(e);

            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (IsMouseCaptured)
            {
                Mouse.Capture(&lt;span style="color: blue;"&gt;this&lt;/span&gt;, CaptureMode.None);
            }
        }

        &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnMouseWheel(MouseWheelEventArgs e)
        {
            &lt;span style="color: blue;"&gt;base&lt;/span&gt;.OnMouseWheel(e);
            &lt;span style="color: blue;"&gt;double&lt;/span&gt; zoomValue;
            &lt;span style="color: blue;"&gt;const&lt;/span&gt; &lt;span style="color: blue;"&gt;double&lt;/span&gt; zoomFactor = 1.1;
            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (e.Delta &amp;lt; 0)
            {
                zoomValue = zoomFactor;
            }
            &lt;span style="color: blue;"&gt;else&lt;/span&gt;
            {
                zoomValue = 1 / zoomFactor;
            }
           
            &lt;span style="color: blue;"&gt;var&lt;/span&gt; scaleTransform3D = &lt;span style="color: blue;"&gt;new&lt;/span&gt; ScaleTransform3D(&lt;span style="color: blue;"&gt;new&lt;/span&gt; Vector3D(zoomValue, zoomValue, zoomValue), ScreenToWorld(e.GetPosition(&lt;span style="color: blue;"&gt;this&lt;/span&gt;)));
            UpdateCameraTransform(scaleTransform3D);

        }

        &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnMouseMove(MouseEventArgs e)
        {
            &lt;span style="color: blue;"&gt;base&lt;/span&gt;.OnMouseMove(e);

            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (IsMouseCaptured)
            {
                Point currentPosition = e.GetPosition(&lt;span style="color: blue;"&gt;this&lt;/span&gt;);

                &lt;span style="color: green;"&gt;// avoid any zero axis conditions&lt;/span&gt;
                &lt;span style="color: blue;"&gt;if&lt;/span&gt; (currentPosition == _previousPosition2D) &lt;span style="color: blue;"&gt;return&lt;/span&gt;;

                &lt;span style="color: green;"&gt;// Prefer tracking to zooming if both buttons are pressed.&lt;/span&gt;
                &lt;span style="color: blue;"&gt;if&lt;/span&gt; (e.LeftButton == MouseButtonState.Pressed)
                {
                    TranslateTransform3D translateTransform3D = Pan(currentPosition);
                    UpdateCameraTransform(translateTransform3D);
                }
                &lt;span style="color: blue;"&gt;else&lt;/span&gt; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (e.RightButton == MouseButtonState.Pressed)
                {
                    RotateTransform3D rotateTransform3D = Track(currentPosition);
                    UpdateCameraTransform(rotateTransform3D);
                }

                _previousPosition2D = currentPosition;
                _previousPosition3D = ProjectToTrackball(ActualWidth, ActualHeight, currentPosition);
            }
        }

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; UpdateCameraTransform(Transform3D transform3D)
        {
            Viewport3D viewport3D = &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Viewport3D;
            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (viewport3D != &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
            {
                &lt;span style="color: blue;"&gt;if&lt;/span&gt; (viewport3D.Camera != &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
                {
                    &lt;span style="color: blue;"&gt;if&lt;/span&gt; (viewport3D.Camera.IsFrozen)
                    {
                        viewport3D.Camera = viewport3D.Camera.Clone();
                    }
                    &lt;span style="color: blue;"&gt;var&lt;/span&gt; transform3DGroup = &lt;span style="color: blue;"&gt;new&lt;/span&gt; Transform3DGroup();
                    transform3DGroup.Children.Add(viewport3D.Camera.Transform);
                    transform3DGroup.Children.Add(transform3D);
                    viewport3D.Camera.Transform = transform3DGroup;
                }
            }
        }

        &lt;span style="color: blue;"&gt;#endregion&lt;/span&gt; Event Handling

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; TranslateTransform3D Pan(Point currentPosition)
        {
            &lt;span style="color: green;"&gt;//Vector3D currentPosition3D = ProjectToTrackball(ActualWidth, ActualHeight, currentPosition);&lt;/span&gt;
            Vector3D panVector3D = ScreenToWorld(_previousPosition2D) - ScreenToWorld(currentPosition);
            &lt;span style="color: blue;"&gt;var&lt;/span&gt; translateTransform3D = &lt;span style="color: blue;"&gt;new&lt;/span&gt; TranslateTransform3D(panVector3D);
            &lt;span style="color: blue;"&gt;return&lt;/span&gt; translateTransform3D;
        }

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; RotateTransform3D Track(Point currentPosition)
        {
            Vector3D currentPosition3D = ProjectToTrackball(ActualWidth, ActualHeight, currentPosition);

            Vector3D axis = Vector3D.CrossProduct(_previousPosition3D, currentPosition3D);
            &lt;span style="color: blue;"&gt;double&lt;/span&gt; angle = Vector3D.AngleBetween(_previousPosition3D, currentPosition3D);

            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (axis.Length == 0) 
                &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; RotateTransform3D();
            Quaternion delta = &lt;span style="color: blue;"&gt;new&lt;/span&gt; Quaternion(axis, -angle);
            &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; RotateTransform3D(&lt;span style="color: blue;"&gt;new&lt;/span&gt; QuaternionRotation3D(delta),ScreenToWorld(currentPosition));
        }

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; Camera Camera
        {
            &lt;span style="color: blue;"&gt;get&lt;/span&gt;
            {
                &lt;span style="color: blue;"&gt;if&lt;/span&gt; (&lt;span style="color: blue;"&gt;this&lt;/span&gt;.Viewport3D == &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
                    &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;null&lt;/span&gt;;
                &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Viewport3D.Camera;
            }
        }

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; Point3D ScreenToWorld(Point point)
        {
            &lt;span style="color: blue;"&gt;bool&lt;/span&gt; success = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;
            Matrix3D worldToViewportTransform = MathUtils.TryWorldToViewportTransform((Viewport3DVisual) VisualTreeHelper.GetParent(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.Viewport3D.Children[0]), &lt;span style="color: blue;"&gt;out&lt;/span&gt; success);
            &lt;span style="color: blue;"&gt;if&lt;/span&gt;(success &amp;amp;&amp;amp; worldToViewportTransform.HasInverse)
            {
                &lt;span style="color: blue;"&gt;var&lt;/span&gt; point3D = &lt;span style="color: blue;"&gt;new&lt;/span&gt; Point3D(point.X, point.Y, 0);
                worldToViewportTransform.Invert();
                Point3D transformed = worldToViewportTransform.Transform(point3D);
                &lt;span style="color: blue;"&gt;return&lt;/span&gt; transformed;
            }
            &lt;span style="color: blue;"&gt;else&lt;/span&gt;
            {
                &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; Point3D(0,0,0);
            }
        }

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; Vector3D ProjectToTrackball(&lt;span style="color: blue;"&gt;double&lt;/span&gt; width, &lt;span style="color: blue;"&gt;double&lt;/span&gt; height, Point point)
        {
            &lt;span style="color: blue;"&gt;if&lt;/span&gt;(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.Camera==&lt;span style="color: blue;"&gt;null&lt;/span&gt;)
                &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; Vector3D(0,0,0);
            &lt;span style="color: blue;"&gt;double&lt;/span&gt; x = point.X / (width / 2);    &lt;span style="color: green;"&gt;// Scale so bounds map to [0,0] - [2,2]&lt;/span&gt;
            &lt;span style="color: blue;"&gt;double&lt;/span&gt; y = point.Y / (height / 2);

            x = x - 1;                           &lt;span style="color: green;"&gt;// Translate 0,0 to the center&lt;/span&gt;
            y = 1 - y;                           &lt;span style="color: green;"&gt;// Flip so +Y is up instead of down&lt;/span&gt;

            &lt;span style="color: blue;"&gt;double&lt;/span&gt; z2 = 1 - x * x - y * y;       &lt;span style="color: green;"&gt;// z^2 = 1 - x^2 - y^2&lt;/span&gt;
            &lt;span style="color: blue;"&gt;double&lt;/span&gt; z = z2 &amp;gt; 0 ? Math.Sqrt(z2) : 0;

            &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; Vector3D(x, y, z);
        }

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; Point _previousPosition2D;
        &lt;span style="color: blue;"&gt;private&lt;/span&gt; Vector3D _previousPosition3D = &lt;span style="color: blue;"&gt;new&lt;/span&gt; Vector3D(0, 0, 1);

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; Border _eventSource;        
    }
}

&lt;/pre&gt;
&lt;/div&gt;
&lt;/p&gt;&lt;/div&gt;</description><author>Johan20D</author><pubDate>Fri, 11 May 2012 05:36:03 GMT</pubDate><guid isPermaLink="false">New Post: WheelZoom 20120511053603A</guid></item><item><title>New Post: WheelZoom</title><link>http://3dtools.codeplex.com/discussions/355203</link><description>&lt;div style="line-height: normal;"&gt;&lt;p&gt;I rewrote the TrackBallDecorator to have Pan on left button, rotate on right and zoom on wheel.&lt;/p&gt;
&lt;p&gt;The rotation is a bit strange but the rest works ok:&lt;/p&gt;
&lt;p&gt;
&lt;div style="color: black; background-color: white;"&gt;
&lt;pre&gt;&lt;span style="color: green;"&gt;//---------------------------------------------------------------------------&lt;/span&gt;
&lt;span style="color: green;"&gt;//&lt;/span&gt;
&lt;span style="color: green;"&gt;// (c) Copyright Microsoft Corporation.&lt;/span&gt;
&lt;span style="color: green;"&gt;// This source is subject to the Microsoft Limited Permissive License.&lt;/span&gt;
&lt;span style="color: green;"&gt;// See http://www.microsoft.com/resources/sharedsource/licensingbasics/limitedpermissivelicense.mspx&lt;/span&gt;
&lt;span style="color: green;"&gt;// All other rights reserved.&lt;/span&gt;
&lt;span style="color: green;"&gt;//&lt;/span&gt;
&lt;span style="color: green;"&gt;// This file is part of the 3D Tools for Windows Presentation Foundation&lt;/span&gt;
&lt;span style="color: green;"&gt;// project.  For more information, see:&lt;/span&gt;
&lt;span style="color: green;"&gt;// &lt;/span&gt;
&lt;span style="color: green;"&gt;// http://CodePlex.com/Wiki/View.aspx?ProjectName=3DTools&lt;/span&gt;
&lt;span style="color: green;"&gt;//&lt;/span&gt;
&lt;span style="color: green;"&gt;// The following article discusses the mechanics behind this&lt;/span&gt;
&lt;span style="color: green;"&gt;// trackball implementation: http://viewport3d.com/trackball.htm&lt;/span&gt;
&lt;span style="color: green;"&gt;//&lt;/span&gt;
&lt;span style="color: green;"&gt;// Reading the article is not required to use this sample code,&lt;/span&gt;
&lt;span style="color: green;"&gt;// but skimming it might be useful.&lt;/span&gt;
&lt;span style="color: green;"&gt;//&lt;/span&gt;
&lt;span style="color: green;"&gt;//---------------------------------------------------------------------------&lt;/span&gt;

&lt;span style="color: blue;"&gt;using&lt;/span&gt; System;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Collections;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Controls;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Data;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Documents;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Media;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Media.Imaging;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Media.Media3D;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Shapes;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Input;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Markup; &lt;span style="color: green;"&gt;// IAddChild, ContentPropertyAttribute&lt;/span&gt;

&lt;span style="color: blue;"&gt;namespace&lt;/span&gt; _3DTools
{
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; TrackballDecorator : Viewport3DDecorator
    {
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; TrackballDecorator()
        {
            &lt;span style="color: green;"&gt;// used so that we always get events while activity occurs within&lt;/span&gt;
            &lt;span style="color: green;"&gt;// the viewport3D&lt;/span&gt;
            _eventSource = &lt;span style="color: blue;"&gt;new&lt;/span&gt; Border();
            _eventSource.Background = Brushes.Transparent;
            
            PreViewportChildren.Add(_eventSource);
        }

        &lt;span style="color: gray;"&gt;///&lt;/span&gt; &lt;span style="color: gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt;     A transform to move the camera or scene to the trackball's&lt;/span&gt;
        &lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt;     current orientation and scale.&lt;/span&gt;
        &lt;span style="color: gray;"&gt;///&lt;/span&gt; &lt;span style="color: gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; Transform3D Transform
        {
            &lt;span style="color: blue;"&gt;get&lt;/span&gt;
            {
                &lt;span style="color: blue;"&gt;if&lt;/span&gt; (&lt;span style="color: blue;"&gt;this&lt;/span&gt;.Viewport3D == &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
                    &lt;span style="color: blue;"&gt;return&lt;/span&gt; Transform3D.Identity;
                &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Viewport3D.Camera.Transform;
            }
        }

        &lt;span style="color: blue;"&gt;#region&lt;/span&gt; Event Handling

        &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnMouseDown(MouseButtonEventArgs e)
        {
            &lt;span style="color: blue;"&gt;base&lt;/span&gt;.OnMouseDown(e);

            _previousPosition2D = e.GetPosition(&lt;span style="color: blue;"&gt;this&lt;/span&gt;);
            _previousPosition3D = ProjectToTrackball(ActualWidth, ActualHeight, _previousPosition2D);
            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (Mouse.Captured == &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
            {
                Mouse.Capture(&lt;span style="color: blue;"&gt;this&lt;/span&gt;, CaptureMode.Element);
            }
        }

        &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnMouseUp(MouseButtonEventArgs e)
        {
            &lt;span style="color: blue;"&gt;base&lt;/span&gt;.OnMouseUp(e);

            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (IsMouseCaptured)
            {
                Mouse.Capture(&lt;span style="color: blue;"&gt;this&lt;/span&gt;, CaptureMode.None);
            }
        }

        &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnMouseWheel(MouseWheelEventArgs e)
        {
            &lt;span style="color: blue;"&gt;base&lt;/span&gt;.OnMouseWheel(e);
            &lt;span style="color: blue;"&gt;double&lt;/span&gt; zoomValue;
            &lt;span style="color: blue;"&gt;const&lt;/span&gt; &lt;span style="color: blue;"&gt;double&lt;/span&gt; zoomFactor = 1.1;
            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (e.Delta &amp;lt; 0)
            {
                zoomValue = zoomFactor;
            }
            &lt;span style="color: blue;"&gt;else&lt;/span&gt;
            {
                zoomValue = 1 / zoomFactor;
            }
           
            &lt;span style="color: blue;"&gt;var&lt;/span&gt; scaleTransform3D = &lt;span style="color: blue;"&gt;new&lt;/span&gt; ScaleTransform3D(&lt;span style="color: blue;"&gt;new&lt;/span&gt; Vector3D(zoomValue, zoomValue, zoomValue), ScreenToWorld(e.GetPosition(&lt;span style="color: blue;"&gt;this&lt;/span&gt;)));
            UpdateCameraTransform(scaleTransform3D);

        }

        &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnMouseMove(MouseEventArgs e)
        {
            &lt;span style="color: blue;"&gt;base&lt;/span&gt;.OnMouseMove(e);

            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (IsMouseCaptured)
            {
                Point currentPosition = e.GetPosition(&lt;span style="color: blue;"&gt;this&lt;/span&gt;);

                &lt;span style="color: green;"&gt;// avoid any zero axis conditions&lt;/span&gt;
                &lt;span style="color: blue;"&gt;if&lt;/span&gt; (currentPosition == _previousPosition2D) &lt;span style="color: blue;"&gt;return&lt;/span&gt;;

                &lt;span style="color: green;"&gt;// Prefer tracking to zooming if both buttons are pressed.&lt;/span&gt;
                &lt;span style="color: blue;"&gt;if&lt;/span&gt; (e.LeftButton == MouseButtonState.Pressed)
                {
                    TranslateTransform3D translateTransform3D = Pan(currentPosition);
                    UpdateCameraTransform(translateTransform3D);
                }
                &lt;span style="color: blue;"&gt;else&lt;/span&gt; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (e.RightButton == MouseButtonState.Pressed)
                {
                    RotateTransform3D rotateTransform3D = Track(currentPosition);
                    UpdateCameraTransform(rotateTransform3D);
                }

                _previousPosition2D = currentPosition;
                _previousPosition3D = ProjectToTrackball(ActualWidth, ActualHeight, currentPosition);
            }
        }

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; UpdateCameraTransform(Transform3D transform3D)
        {
            Viewport3D viewport3D = &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Viewport3D;
            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (viewport3D != &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
            {
                &lt;span style="color: blue;"&gt;if&lt;/span&gt; (viewport3D.Camera != &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
                {
                    &lt;span style="color: blue;"&gt;if&lt;/span&gt; (viewport3D.Camera.IsFrozen)
                    {
                        viewport3D.Camera = viewport3D.Camera.Clone();
                    }
                    &lt;span style="color: blue;"&gt;var&lt;/span&gt; transform3DGroup = &lt;span style="color: blue;"&gt;new&lt;/span&gt; Transform3DGroup();
                    transform3DGroup.Children.Add(viewport3D.Camera.Transform);
                    transform3DGroup.Children.Add(transform3D);
                    viewport3D.Camera.Transform = transform3DGroup;
                }
            }
        }

        &lt;span style="color: blue;"&gt;#endregion&lt;/span&gt; Event Handling

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; TranslateTransform3D Pan(Point currentPosition)
        {
            &lt;span style="color: green;"&gt;//Vector3D currentPosition3D = ProjectToTrackball(ActualWidth, ActualHeight, currentPosition);&lt;/span&gt;
            Vector3D panVector3D = ScreenToWorld(_previousPosition2D) - ScreenToWorld(currentPosition);
            &lt;span style="color: blue;"&gt;var&lt;/span&gt; translateTransform3D = &lt;span style="color: blue;"&gt;new&lt;/span&gt; TranslateTransform3D(panVector3D);
            &lt;span style="color: blue;"&gt;return&lt;/span&gt; translateTransform3D;
        }

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; RotateTransform3D Track(Point currentPosition)
        {
            Vector3D currentPosition3D = ProjectToTrackball(ActualWidth, ActualHeight, currentPosition);

            Vector3D axis = Vector3D.CrossProduct(_previousPosition3D, currentPosition3D);
            &lt;span style="color: blue;"&gt;double&lt;/span&gt; angle = Vector3D.AngleBetween(_previousPosition3D, currentPosition3D);

            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (axis.Length == 0) 
                &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; RotateTransform3D();
            Quaternion delta = &lt;span style="color: blue;"&gt;new&lt;/span&gt; Quaternion(axis, -angle);
            &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; RotateTransform3D(&lt;span style="color: blue;"&gt;new&lt;/span&gt; QuaternionRotation3D(delta),ScreenToWorld(currentPosition));
        }

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; Camera Camera
        {
            &lt;span style="color: blue;"&gt;get&lt;/span&gt;
            {
                &lt;span style="color: blue;"&gt;if&lt;/span&gt; (&lt;span style="color: blue;"&gt;this&lt;/span&gt;.Viewport3D == &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
                    &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;null&lt;/span&gt;;
                &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Viewport3D.Camera;
            }
        }

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; Point3D ScreenToWorld(Point point)
        {
            &lt;span style="color: blue;"&gt;bool&lt;/span&gt; success = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;
            Matrix3D worldToViewportTransform = MathUtils.TryWorldToViewportTransform((Viewport3DVisual) VisualTreeHelper.GetParent(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.Viewport3D.Children[0]), &lt;span style="color: blue;"&gt;out&lt;/span&gt; success);
            &lt;span style="color: blue;"&gt;if&lt;/span&gt;(success &amp;amp;&amp;amp; worldToViewportTransform.HasInverse)
            {
                &lt;span style="color: blue;"&gt;var&lt;/span&gt; point3D = &lt;span style="color: blue;"&gt;new&lt;/span&gt; Point3D(point.X, point.Y, 0);
                worldToViewportTransform.Invert();
                Point3D transformed = worldToViewportTransform.Transform(point3D);
                &lt;span style="color: blue;"&gt;return&lt;/span&gt; transformed;
            }
            &lt;span style="color: blue;"&gt;else&lt;/span&gt;
            {
                &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; Point3D(0,0,0);
            }
        }

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; Vector3D ProjectToTrackball(&lt;span style="color: blue;"&gt;double&lt;/span&gt; width, &lt;span style="color: blue;"&gt;double&lt;/span&gt; height, Point point)
        {
            &lt;span style="color: blue;"&gt;if&lt;/span&gt;(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.Camera==&lt;span style="color: blue;"&gt;null&lt;/span&gt;)
                &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; Vector3D(0,0,0);
            &lt;span style="color: blue;"&gt;double&lt;/span&gt; x = point.X / (width / 2);    &lt;span style="color: green;"&gt;// Scale so bounds map to [0,0] - [2,2]&lt;/span&gt;
            &lt;span style="color: blue;"&gt;double&lt;/span&gt; y = point.Y / (height / 2);

            x = x - 1;                           &lt;span style="color: green;"&gt;// Translate 0,0 to the center&lt;/span&gt;
            y = 1 - y;                           &lt;span style="color: green;"&gt;// Flip so +Y is up instead of down&lt;/span&gt;

            &lt;span style="color: blue;"&gt;double&lt;/span&gt; z2 = 1 - x * x - y * y;       &lt;span style="color: green;"&gt;// z^2 = 1 - x^2 - y^2&lt;/span&gt;
            &lt;span style="color: blue;"&gt;double&lt;/span&gt; z = z2 &amp;gt; 0 ? Math.Sqrt(z2) : 0;

            &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; Vector3D(x, y, z);
        }

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; Point _previousPosition2D;
        &lt;span style="color: blue;"&gt;private&lt;/span&gt; Vector3D _previousPosition3D = &lt;span style="color: blue;"&gt;new&lt;/span&gt; Vector3D(0, 0, 1);

        &lt;span style="color: blue;"&gt;private&lt;/span&gt; Border _eventSource;        
    }
}

&lt;/pre&gt;
&lt;/div&gt;
&lt;/p&gt;&lt;/div&gt;</description><author>Johan20D</author><pubDate>Fri, 11 May 2012 05:36:03 GMT</pubDate><guid isPermaLink="false">New Post: WheelZoom 20120511053603A</guid></item><item><title>New Post: WheelZoom</title><link>http://3dtools.codeplex.com/discussions/355203</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;In the TrackBallDecorator class&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="color:black; background-color:white"&gt;
&lt;pre&gt;        &lt;span style="color:blue"&gt;protected&lt;/span&gt; &lt;span style="color:blue"&gt;override&lt;/span&gt; &lt;span style="color:blue"&gt;void&lt;/span&gt; OnMouseWheel(MouseWheelEventArgs e)
        {
            &lt;span style="color:blue"&gt;double&lt;/span&gt; zoomValue;
            &lt;span style="color:blue"&gt;double&lt;/span&gt; zoomFactor = 1.1;
            &lt;span style="color:blue"&gt;if&lt;/span&gt;(e.Delta&amp;lt;0)
            {
                zoomValue = zoomFactor;
            }
            &lt;span style="color:blue"&gt;else&lt;/span&gt;
            {
                zoomValue = 1/zoomFactor;
            }
            Viewport3D viewport3D = &lt;span style="color:blue"&gt;this&lt;/span&gt;.Viewport3D;
            &lt;span style="color:blue"&gt;if&lt;/span&gt; (viewport3D != &lt;span style="color:blue"&gt;null&lt;/span&gt;)
            {
                &lt;span style="color:blue"&gt;if&lt;/span&gt; (viewport3D.Camera != &lt;span style="color:blue"&gt;null&lt;/span&gt;)
                {
                    &lt;span style="color:blue"&gt;if&lt;/span&gt; (viewport3D.Camera.IsFrozen)
                    {
                        viewport3D.Camera = viewport3D.Camera.Clone();
                    }
                    &lt;span style="color:blue"&gt;var&lt;/span&gt; transform3DGroup = &lt;span style="color:blue"&gt;new&lt;/span&gt; Transform3DGroup();
                    transform3DGroup.Children.Add(viewport3D.Camera.Transform);
                    Vector3D projectToTrackball = ProjectToTrackball(ActualWidth, ActualHeight, e.GetPosition(&lt;span style="color:blue"&gt;this&lt;/span&gt;));
                    transform3DGroup.Children.Add(&lt;span style="color:blue"&gt;new&lt;/span&gt; ScaleTransform3D(&lt;span style="color:blue"&gt;new&lt;/span&gt; Vector3D(zoomValue, zoomValue, zoomValue), &lt;span style="color:blue"&gt;new&lt;/span&gt; Point3D(projectToTrackball.X,projectToTrackball.Y,projectToTrackball.Z)));
                    viewport3D.Camera.Transform = transform3DGroup;
                }
            }

        }
&lt;/pre&gt;
&lt;/div&gt;
I dont know if this is a ggod way
&lt;p&gt;&lt;/p&gt;
&lt;/div&gt;</description><author>Johan20D</author><pubDate>Thu, 10 May 2012 04:33:41 GMT</pubDate><guid isPermaLink="false">New Post: WheelZoom 20120510043341A</guid></item><item><title>New Post: WheelZoom</title><link>http://3dtools.codeplex.com/discussions/355203</link><description>&lt;div style="line-height: normal;"&gt;
&lt;p&gt;In the TrackBallDecorator class&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="color:black; background-color:white"&gt;
&lt;pre&gt;        &lt;span style="color:blue"&gt;protected&lt;/span&gt; &lt;span style="color:blue"&gt;override&lt;/span&gt; &lt;span style="color:blue"&gt;void&lt;/span&gt; OnMouseWheel(MouseWheelEventArgs e)
        {
            &lt;span style="color:blue"&gt;double&lt;/span&gt; zoomValue;
            &lt;span style="color:blue"&gt;double&lt;/span&gt; zoomFactor = 1.1;
            &lt;span style="color:blue"&gt;if&lt;/span&gt;(e.Delta&amp;lt;0)
            {
                zoomValue = zoomFactor;
            }
            &lt;span style="color:blue"&gt;else&lt;/span&gt;
            {
                zoomValue = 1/zoomFactor;
            }
            Viewport3D viewport3D = &lt;span style="color:blue"&gt;this&lt;/span&gt;.Viewport3D;
            &lt;span style="color:blue"&gt;if&lt;/span&gt; (viewport3D != &lt;span style="color:blue"&gt;null&lt;/span&gt;)
            {
                &lt;span style="color:blue"&gt;if&lt;/span&gt; (viewport3D.Camera != &lt;span style="color:blue"&gt;null&lt;/span&gt;)
                {
                    &lt;span style="color:blue"&gt;if&lt;/span&gt; (viewport3D.Camera.IsFrozen)
                    {
                        viewport3D.Camera = viewport3D.Camera.Clone();
                    }
                    &lt;span style="color:blue"&gt;var&lt;/span&gt; transform3DGroup = &lt;span style="color:blue"&gt;new&lt;/span&gt; Transform3DGroup();
                    transform3DGroup.Children.Add(viewport3D.Camera.Transform);
                    Vector3D projectToTrackball = ProjectToTrackball(ActualWidth, ActualHeight, e.GetPosition(&lt;span style="color:blue"&gt;this&lt;/span&gt;));
                    transform3DGroup.Children.Add(&lt;span style="color:blue"&gt;new&lt;/span&gt; ScaleTransform3D(&lt;span style="color:blue"&gt;new&lt;/span&gt; Vector3D(zoomValue, zoomValue, zoomValue), &lt;span style="color:blue"&gt;new&lt;/span&gt; Point3D(projectToTrackball.X,projectToTrackball.Y,projectToTrackball.Z)));
                    viewport3D.Camera.Transform = transform3DGroup;
                }
            }

        }
&lt;/pre&gt;
&lt;/div&gt;
I dont know if this is a ggod way
&lt;p&gt;&lt;/p&gt;
&lt;/div&gt;</description><author>Johan20D</author><pubDate>Thu, 10 May 2012 04:33:41 GMT</pubDate><guid isPermaLink="false">New Post: WheelZoom 20120510043341A</guid></item><item><title>New Post: Connot add ScreenSpaceLines3D to Model3DGroup</title><link>http://3dtools.codeplex.com/discussions/274104</link><description>&lt;div style="line-height: normal;"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;ScreenSpaceLines3D is Visual3D--&amp;gt;couldn't be added into Model3D like Model3DGroup or GeometryModel3D. However you can add it directly into Viewport3D.&lt;/p&gt;&lt;/div&gt;</description><author>kzoko</author><pubDate>Wed, 29 Feb 2012 16:10:59 GMT</pubDate><guid isPermaLink="false">New Post: Connot add ScreenSpaceLines3D to Model3DGroup 20120229041059P</guid></item></channel></rss>