<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="http://www.codeplex.com/rss.xsl"?><rss version="2.0"><channel><title>3D Tools for the Windows Presentation Foundation</title><link>http://www.codeplex.com/3DTools/Project/ProjectRss.aspx</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 ...</description><item><title>New Post: ScreenSpaceLines3D.OnRender bug?</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=13889</link><description>&lt;div style="line-height: normal;"&gt;&lt;p&gt;Thanks for the info.&amp;nbsp; I have tried both patches and still get a memory leak when using&amp;nbsp;ScreenSpaceLines3D.&lt;span style="font-size:13px;color:#2b91af"&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;br&gt;
&lt;/div&gt;</description><author>kbeal2k</author><pubDate>Thu, 26 Jun 2008 15:34:57 GMT</pubDate><guid isPermaLink="false">New Post: ScreenSpaceLines3D.OnRender bug? 20080626033457P</guid></item><item><title>New Post: ScreenSpaceLines3D.OnRender bug?</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=13889</link><description>&lt;div style="line-height: normal;"&gt;Have a look at&amp;nbsp;&lt;a href="http://www.codeplex.com/3DTools/SourceControl/PatchList.aspx"&gt;http://www.codeplex.com/3DTools/SourceControl/PatchList.aspx&lt;/a&gt;.
&lt;/div&gt;</description><author>rolfik</author><pubDate>Thu, 26 Jun 2008 05:50:10 GMT</pubDate><guid isPermaLink="false">New Post: ScreenSpaceLines3D.OnRender bug? 20080626055010A</guid></item><item><title>New Post: ScreenSpaceLines3D.OnRender bug?</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=13889</link><description>&lt;div style="line-height: normal;"&gt;Where can this patch be found?&lt;br&gt;
&lt;div style="border-right:medium none;padding-right:0.2em;border-top:#aaa 0.1em dotted;padding-left:0.2em;padding-bottom:0.2em;margin:1em 0em 2.5em 3em;border-left:medium none;padding-top:0.2em;border-bottom:#aaa 0.1em dotted;font-style:italic"&gt;&lt;br&gt;
rolfik wrote:&lt;br&gt;
Yes, you are right.&lt;br&gt;
I have added IDisposable to ScrenSpaceLine3D to disconnect OnRender when disposed.&lt;br&gt;
I have uploaded it to Patches, but then I have found there is already the same patch ;-)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;</description><author>kbeal2k</author><pubDate>Tue, 24 Jun 2008 18:48:11 GMT</pubDate><guid isPermaLink="false">New Post: ScreenSpaceLines3D.OnRender bug? 20080624064811P</guid></item><item><title>NEW POST: Rotating the trackball in code</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=27662</link><description>&lt;div style="line-height: normal;"&gt;Hello everyone!&lt;br&gt;
&lt;br&gt;
I am using this tool in a university project, to make a 3D Explorer (for my undergraduate course &amp;quot;Human Computer Interaction&amp;quot;)&lt;br&gt;
&lt;br&gt;
So I will have a cube, with different information on each side of the cube..&lt;br&gt;
&lt;br&gt;
I want to rotate the trackball smoothly to some fixed positions (each facet of the cube) using some buttons.&lt;br&gt;
&lt;br&gt;
Any ideas?&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;</description><author>M1ke</author><pubDate>Tue, 13 May 2008 22:35:04 GMT</pubDate><guid isPermaLink="false">NEW POST: Rotating the trackball in code 20080513103504P</guid></item><item><title>NEW POST: Roaming camera implementation</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=22310</link><description>&lt;div class="wikidoc"&gt;
Fantastic!  Thanks so much, I was just in need of camera panning ability and this works great.&lt;br /&gt;
&lt;/div&gt;</description><author>garethconner</author><pubDate>Wed, 30 Apr 2008 16:06:12 GMT</pubDate><guid isPermaLink="false">NEW POST: Roaming camera implementation 20080430040612P</guid></item><item><title>NEW POST: programatically using ScreenSpaceLines3D?</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=7237</link><description>&lt;div class="wikidoc"&gt;
I think it has something to do with redrawing the scene. I was able to get it to do this by calling the Viewport3D.InvalidateVisual() method. Of course I am not sure if this is the proper way to refresh the scene, let me know if there is a better way of handling this.&lt;br /&gt;
&lt;/div&gt;</description><author>wldcrd2001</author><pubDate>Wed, 30 Apr 2008 15:57:40 GMT</pubDate><guid isPermaLink="false">NEW POST: programatically using ScreenSpaceLines3D? 20080430035740P</guid></item><item><title>NEW POST: programatically using ScreenSpaceLines3D?</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=7237</link><description>&lt;div class="wikidoc"&gt;
I meet the same problem, I can't see any line too... Can somebody offer some available codes, thanks!&lt;br /&gt;
&lt;/div&gt;</description><author>tczyp</author><pubDate>Fri, 28 Mar 2008 13:48:11 GMT</pubDate><guid isPermaLink="false">NEW POST: programatically using ScreenSpaceLines3D? 20080328014811P</guid></item><item><title>NEW POST: Sphere/cone/cyl mesh generation, why not add support?</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=21165</link><description>&lt;div class="wikidoc"&gt;
There's a good Microsoft Press book &amp;quot;3D Programming For Windows&amp;quot; by Charles Petzold that supplies such a library.  It's downloadable from {url:http://www.charlespetzold.com/3d}, although licence to use the library commercially only comes if you purchase the book.&lt;br /&gt;
&lt;/div&gt;</description><author>Electromorph</author><pubDate>Wed, 26 Mar 2008 14:21:01 GMT</pubDate><guid isPermaLink="false">NEW POST: Sphere/cone/cyl mesh generation, why not add support? 20080326022101P</guid></item><item><title>NEW POST: 3D form manager</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=24203</link><description>&lt;div class="wikidoc"&gt;
The following class can be used to keep UI forms (or any models) relative to the camera.&lt;br /&gt; &lt;br /&gt;The class is a Model3DVisual, so it can have children (models).  Don't set its transform, as that's done automatically by the class as the camera moves.&lt;br /&gt; &lt;br /&gt;As the camera changes position and orientation, the class changes its own coordinate space (via a transform) so that the origin is always centered at the camera.  The X and Y axes point right and up, respectively, relative to the camera, and the Z axis extends negatively into the scene.&lt;br /&gt; &lt;br /&gt;To use the class, you'll need a Viewport3D and a perspective camera:&lt;br /&gt; &lt;br /&gt;  Form3DManager formMgr = new Form3DManager(camera);&lt;br /&gt;  viewport3D.Children.Add(formMgr);&lt;br /&gt; &lt;br /&gt;Once the form manager's added to the viewport, you can add models to it:&lt;br /&gt; &lt;br /&gt;  formMgr.Children.Add(mymodel);&lt;br /&gt; &lt;br /&gt;When you set your model's transform, your model moves relative to the camera, and maintains its position relative to the camera, as the camera moves and changes orientation.  Remember that negative Z values are in front of the camera.&lt;br /&gt; &lt;br /&gt;Here's the class:&lt;br /&gt; &lt;br /&gt;namespace Km.Olap.ThreeD.Scene&lt;br /&gt;{&lt;br /&gt;    public class Form3DManager : ModelVisual3D&lt;br /&gt;    {&lt;br /&gt;        public Form3DManager(PerspectiveCamera camera)&lt;br /&gt;        {&lt;br /&gt;            camera.Changed += new EventHandler(camera_Changed);&lt;br /&gt;            camera_Changed(camera, null);&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        private void camera_Changed(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            PerspectiveCamera camera = sender as PerspectiveCamera;&lt;br /&gt; &lt;br /&gt;            // Get the inverse of the camera's view matrix.&lt;br /&gt;            Matrix3D inverseViewMatrix = MathUtils.GetViewMatrix(camera);&lt;br /&gt;            inverseViewMatrix.Invert();&lt;br /&gt; &lt;br /&gt;            // Build a transform (matrix) to transform this ModelVisual3D&lt;br /&gt;            // into the camera's coordinate system.&lt;br /&gt;            MatrixTransform3D transformToCameraSpace =&lt;br /&gt;                new MatrixTransform3D(inverseViewMatrix * camera.Transform.Value);&lt;br /&gt; &lt;br /&gt;            this.Transform = transformToCameraSpace;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;Notice the class uses the GetViewMatrix() method from the WPF 3D Tools MathUtils class.&lt;br /&gt; &lt;br /&gt;Kary&lt;br /&gt; &lt;br /&gt;
&lt;/div&gt;</description><author>karymcfadden</author><pubDate>Mon, 17 Mar 2008 17:37:41 GMT</pubDate><guid isPermaLink="false">NEW POST: 3D form manager 20080317053741P</guid></item><item><title>CREATED ISSUE: Combobox does not render in 3D</title><link>http://www.codeplex.com/3DTools/WorkItem/View.aspx?WorkItemId=15524</link><description>Hi,  if you add a combo box to the Visual which is referenced by the InteractiveVisual3D class, then when you click on the combo box the drop down is shown in 2D not 3D.&lt;br /&gt;</description><author>themightycoder</author><pubDate>Sun, 09 Mar 2008 07:05:06 GMT</pubDate><guid isPermaLink="false">CREATED ISSUE: Combobox does not render in 3D 20080309070506A</guid></item><item><title>NEW POST: Resolving 3D Coordinates from 2D Visual Coordinates</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=9476</link><description>&lt;div class="wikidoc"&gt;
Many thanks for this Jesus.&lt;br /&gt; &lt;br /&gt;I actually abandoned that part of the project I was working on due to time.&lt;br /&gt; &lt;br /&gt;I hope that this code serves as a handy guide to those who follow us here...&lt;br /&gt; &lt;br /&gt;Respect&lt;br /&gt;SegFault&lt;br /&gt;
&lt;/div&gt;</description><author>simonjohnroberts</author><pubDate>Thu, 06 Mar 2008 19:19:59 GMT</pubDate><guid isPermaLink="false">NEW POST: Resolving 3D Coordinates from 2D Visual Coordinates 20080306071959P</guid></item><item><title>NEW POST: Resolving 3D Coordinates from 2D Visual Coordinates</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=9476</link><description>&lt;div class="wikidoc"&gt;
Hi, I expect this code helps you (and others)&lt;br /&gt; &lt;br /&gt;Be aware, host window should be maximized, camera looking straight towards -Z direction, upVector = 0,1,0.&lt;br /&gt; &lt;br /&gt;I use this code to convert from Mouse coordinates to 3d World coordinates for Drag&amp;amp;Drop objects in scene, I believe is buggy as is first implementation, so check it and feel free to fix it. :)&lt;br /&gt; &lt;br /&gt;PositionX, PositionY, PositionZ represents object world coordinates, (not local coordinates, or offsets in local space)&lt;br /&gt; &lt;br /&gt;            // How this routine works&lt;br /&gt;            // At certain Z relative from Camera Position and certaing FoV  (in radians)&lt;br /&gt;            // the plane where element lies has certain dimensions (width and height in 3d Space)&lt;br /&gt;            // so calculate this width and height in 3d and scale 2D mouse displacement on viewport to this relative coordinates&lt;br /&gt; &lt;br /&gt;           &lt;br /&gt;            Point position = e.GetPosition(Scene.Viewport3D); // e is MouseEventArgs&lt;br /&gt; &lt;br /&gt;            double width  = Scene.Viewport3D.ActualWidth;&lt;br /&gt;            double height = Scene.Viewport3D.ActualHeight;&lt;br /&gt; &lt;br /&gt;            double xx, yy;&lt;br /&gt; &lt;br /&gt;            xx = position.X - width / 2;           // centered mouse X&lt;br /&gt;            yy = (position.Y - height / 2 ) * -1; // positive Y is up, invert centered mouse Y&lt;br /&gt; &lt;br /&gt;            double aspectRatio = width / height; // aspectRatio on Screen&lt;br /&gt; &lt;br /&gt;            double zPlane = this.PositionZ - Scene.ActiveCamera.Position.Z; // object position in 3D Space relative from camera, Z axis fixed.&lt;br /&gt; &lt;br /&gt;            zPlane = zPlane + zPlane * 0.155; // arbitrary adjustment, why? (I don't know) :) (seems calculations are buggy.&lt;br /&gt; &lt;br /&gt;            double fov = Math3D.Deg2Rad(Scene.ActiveCamera.FieldOfView); // convert to radians&lt;br /&gt; &lt;br /&gt;            double Height_3DAtZ = Math.Abs(System.Math.Tan(fov / 2) * zPlane); // Calculate height at z Position&lt;br /&gt; &lt;br /&gt;            double Width&lt;i&gt;3DAtZ = Height&lt;/i&gt;3DAtZ * aspectRatio; // calculate width from height and aspect ratio&lt;br /&gt;       &lt;br /&gt; &lt;br /&gt;            // calculate position&lt;br /&gt; &lt;br /&gt;            double x = xx / (width / 2);&lt;br /&gt; &lt;br /&gt;            x = (Width_3DAtZ / 2) * x;&lt;br /&gt;            &lt;br /&gt;            //double y = yy / (Height_3DAtZ / 2);&lt;br /&gt; &lt;br /&gt;            double y = yy / (height / 2);&lt;br /&gt; &lt;br /&gt;            y = (Height_3DAtZ / 2) * y;&lt;br /&gt; &lt;br /&gt;            // Set current object current position&lt;br /&gt;            this.PositionX = x;&lt;br /&gt;            this.PositionY = y;&lt;br /&gt; &lt;br /&gt;Regards,&lt;br /&gt; jes&amp;#250;s &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;
&lt;/div&gt;</description><author>JesusSalas</author><pubDate>Wed, 05 Mar 2008 12:37:36 GMT</pubDate><guid isPermaLink="false">NEW POST: Resolving 3D Coordinates from 2D Visual Coordinates 20080305123736P</guid></item><item><title>NEW POST: Sky box implementation</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=23367</link><description>&lt;div class="wikidoc"&gt;
If you know what a sky box is, this is it.  If not, search around the net; it's easy to find good explanations.&lt;br /&gt; &lt;br /&gt;Here's the code:&lt;br /&gt; &lt;br /&gt;    public class SkyBox : ModelVisual3D&lt;br /&gt;    {&lt;br /&gt;        #region Fields&lt;br /&gt; &lt;br /&gt;        private ScaleTransform3D scale;&lt;br /&gt; &lt;br /&gt;        #endregion&lt;br /&gt; &lt;br /&gt;        #region Dependency Properties&lt;br /&gt; &lt;br /&gt;        public double Size&lt;br /&gt;        {&lt;br /&gt;            get { return (double)GetValue(SizeProperty); }&lt;br /&gt;            set { SetValue(SizeProperty, value); }&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        public static readonly DependencyProperty SizeProperty =&lt;br /&gt;            DependencyProperty.Register(&amp;quot;Size&amp;quot;, typeof(double),&lt;br /&gt;            typeof(SkyBox),&lt;br /&gt;            new FrameworkPropertyMetadata(OnSizeChanged)&lt;br /&gt;            );&lt;br /&gt; &lt;br /&gt;        private static void OnSizeChanged(DependencyObject sender,&lt;br /&gt;            DependencyPropertyChangedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            SkyBox sb = sender as SkyBox;&lt;br /&gt; &lt;br /&gt;            double size = sb.Size;&lt;br /&gt; &lt;br /&gt;            sb.scale.ScaleX = size;&lt;br /&gt;            sb.scale.ScaleY = size;&lt;br /&gt;            sb.scale.ScaleZ = size;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        #endregion&lt;br /&gt; &lt;br /&gt;        #region Constructor&lt;br /&gt; &lt;br /&gt;        public SkyBox()&lt;br /&gt;        {&lt;br /&gt;            Model3DGroup sides = new Model3DGroup();&lt;br /&gt; &lt;br /&gt;            Point3D [] p = new Point3D [] {&lt;br /&gt;                new Point3D(-1, 1, -1),&lt;br /&gt;                new Point3D(-1, -1, -1),&lt;br /&gt;                new Point3D(1, -1, -1),&lt;br /&gt;                new Point3D(1, 1, -1),&lt;br /&gt;                new Point3D(1, 1, 1),&lt;br /&gt;                new Point3D(1, -1, 1),&lt;br /&gt;                new Point3D(-1, -1, 1),&lt;br /&gt;                new Point3D(-1, 1, 1)&lt;br /&gt;            };&lt;br /&gt; &lt;br /&gt;            Int32Collection triangleIndices = new Int32Collection(&lt;br /&gt;                new int[] { 0, 1, 2, 2, 3, 0 });&lt;br /&gt; &lt;br /&gt;            PointCollection textCoords = new PointCollection(&lt;br /&gt;                new Point [] {&lt;br /&gt;                    new Point(0,0),&lt;br /&gt;                    new Point(0,1),&lt;br /&gt;                    new Point(1,1),&lt;br /&gt;                    new Point(1,0)&lt;br /&gt;                });&lt;br /&gt; &lt;br /&gt;            MeshGeometry3D quad = new MeshGeometry3D();&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=0"&gt;0&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=1"&gt;1&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=2"&gt;2&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=3"&gt;3&lt;/a&gt;);&lt;br /&gt;            quad.TriangleIndices = triangleIndices;&lt;br /&gt;            quad.TextureCoordinates = textCoords;&lt;br /&gt;            sides.Children.Add(new GeometryModel3D(quad, GetSideMaterial(&amp;quot;north&amp;quot;)));&lt;br /&gt; &lt;br /&gt;            quad = new MeshGeometry3D();&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=4"&gt;4&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=5"&gt;5&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=6"&gt;6&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=7"&gt;7&lt;/a&gt;);&lt;br /&gt;            quad.TriangleIndices = triangleIndices;&lt;br /&gt;            quad.TextureCoordinates = textCoords;&lt;br /&gt;            sides.Children.Add(new GeometryModel3D(quad, GetSideMaterial(&amp;quot;south&amp;quot;)));&lt;br /&gt; &lt;br /&gt;            quad = new MeshGeometry3D();&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=1"&gt;1&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=6"&gt;6&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=5"&gt;5&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=2"&gt;2&lt;/a&gt;);&lt;br /&gt;            quad.TriangleIndices = triangleIndices;&lt;br /&gt;            quad.TextureCoordinates = textCoords;&lt;br /&gt;            sides.Children.Add(new GeometryModel3D(quad, GetSideMaterial(&amp;quot;down&amp;quot;)));&lt;br /&gt; &lt;br /&gt;            quad = new MeshGeometry3D();&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=7"&gt;7&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=6"&gt;6&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=1"&gt;1&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=0"&gt;0&lt;/a&gt;);&lt;br /&gt;            quad.TriangleIndices = triangleIndices;&lt;br /&gt;            quad.TextureCoordinates = textCoords;&lt;br /&gt;            sides.Children.Add(new GeometryModel3D(quad, GetSideMaterial(&amp;quot;west&amp;quot;)));&lt;br /&gt; &lt;br /&gt;            quad = new MeshGeometry3D();&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=3"&gt;3&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=2"&gt;2&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=5"&gt;5&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=4"&gt;4&lt;/a&gt;);&lt;br /&gt;            quad.TriangleIndices = triangleIndices;&lt;br /&gt;            quad.TextureCoordinates = textCoords;&lt;br /&gt;            sides.Children.Add(new GeometryModel3D(quad, GetSideMaterial(&amp;quot;east&amp;quot;)));&lt;br /&gt; &lt;br /&gt;            quad = new MeshGeometry3D();&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=7"&gt;7&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=0"&gt;0&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=3"&gt;3&lt;/a&gt;);&lt;br /&gt;            quad.Positions.Add(p&lt;a href="http://www.codeplex.com/3DTools/Wiki/View.aspx?title=4"&gt;4&lt;/a&gt;);&lt;br /&gt;            quad.TriangleIndices = triangleIndices;&lt;br /&gt;            quad.TextureCoordinates = textCoords;&lt;br /&gt;            sides.Children.Add(new GeometryModel3D(quad, GetSideMaterial(&amp;quot;up&amp;quot;)));&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;            this.scale = new ScaleTransform3D(1, 1, 1);&lt;br /&gt;            this.Transform = this.scale;&lt;br /&gt;            this.Content = sides;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        private Material GetSideMaterial(string sideFilename)&lt;br /&gt;        {&lt;br /&gt;            ImageBrush ib = new ImageBrush(&lt;br /&gt;                new BitmapImage(&lt;br /&gt;                    new Uri(&lt;br /&gt;                        &amp;quot;pack://application:,,,/MyAssemblyName;&amp;quot;&lt;br /&gt;                        + &amp;quot;component/SkyBoxImages/&amp;quot; + sideFilename + &amp;quot;.jpg&amp;quot;,&lt;br /&gt;                        UriKind.Absolute)&lt;br /&gt;                    ));&lt;br /&gt; &lt;br /&gt;            ib.ViewportUnits = BrushMappingMode.Absolute;&lt;br /&gt;            ib.TileMode = TileMode.None;&lt;br /&gt;            return new DiffuseMaterial(ib);&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        #endregion&lt;br /&gt;    }&lt;br /&gt; &lt;br /&gt;VERY IMPORTANT NOTES:&lt;br /&gt; &lt;br /&gt;You need skybox images.  I used six images from this thread:&lt;br /&gt; &lt;br /&gt;http://blenderartists.org/forum/showthread.php?t=96131&lt;br /&gt; &lt;br /&gt;The images start halfway down the page.  There are six of them, named &amp;quot;up,&amp;quot; &amp;quot;north,&amp;quot; &amp;quot;east,&amp;quot; and so on.&lt;br /&gt; &lt;br /&gt;Also, check out Terragen; it's a fantastic, amazing tool for creating sky boxes and terrain.&lt;br /&gt; &lt;br /&gt;Place these images in a folder in your project, and set the Build Action to &amp;quot;Resource.&amp;quot;&lt;br /&gt; &lt;br /&gt;Next, you must change the URI used by this code to point to the correct folder in your assembly.  In the code above, see &amp;quot;MyAssemblyName.&amp;quot;  This URI must be changed to match not only your assembly name, but the path to the folder in which you place the six image files.  In my example, I placed the image files in a folder called &amp;quot;SkyBoxImages.&amp;quot;&lt;br /&gt; &lt;br /&gt;To use the skybox in your app, assuming you have a Viewport3D called viewport3D:&lt;br /&gt; &lt;br /&gt;  SkyBox sb = new SkyBox();&lt;br /&gt;  sb.Size = 10000;  // or whatever you'd like.  This sets the bounds of the box.&lt;br /&gt;  viewport3D.Children.Add(sb);&lt;br /&gt; &lt;br /&gt;Make sure your viewport's FarPlaneDistance isn't less than your sky box's size.&lt;br /&gt; &lt;br /&gt;One more thing: If your app uses the WPF 3D Tools' Trackball or TrackballDecorator, you may see distortion of the skybox as you zoom in and out.  This is because the trackball implementation, rather than move the camera about the 3D world, changes a scale transformation to zoom in and out.  Instead, try the skybox in conjunction with the Roam3DDecorator that I provided in a previous thread.  That decorator actually moves the camera around in the 3D world, and does not affect the scale factor, so the skybox won't be distorted.&lt;br /&gt; &lt;br /&gt;Enjoy!&lt;br /&gt; &lt;br /&gt;Kary&lt;br /&gt;
&lt;/div&gt;</description><author>karymcfadden</author><pubDate>Wed, 05 Mar 2008 02:12:42 GMT</pubDate><guid isPermaLink="false">NEW POST: Sky box implementation 20080305021242A</guid></item><item><title>NEW POST: Using RotateTransform3D </title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=23292</link><description>&lt;div class="wikidoc"&gt;
Greetings all, I'm new here.&lt;br /&gt; &lt;br /&gt;Looking at Petzold's AxisRotationExperimenter.xaml in his #D book, I would like to see some sample code implementing this mostly in C#. I'd like to know how to take my 3D rectangle with an image on it and rotate in using something like:&lt;br /&gt; &lt;br /&gt;RotateTransform3D myRotateTransform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 1));&lt;br /&gt; &lt;br /&gt;Thanks, Theron&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;
&lt;/div&gt;</description><author>twiereng</author><pubDate>Tue, 04 Mar 2008 01:22:41 GMT</pubDate><guid isPermaLink="false">NEW POST: Using RotateTransform3D  20080304012241A</guid></item><item><title>NEW POST: Roaming camera implementation</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=22310</link><description>&lt;div class="wikidoc"&gt;
Great work! Thanks for sharing!!&lt;br /&gt;
&lt;/div&gt;</description><author>broszkiet</author><pubDate>Mon, 03 Mar 2008 22:11:43 GMT</pubDate><guid isPermaLink="false">NEW POST: Roaming camera implementation 20080303101143P</guid></item><item><title>NEW POST: assign Storyboard to a InteractiveVisual3D</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=22944</link><description>&lt;div class="wikidoc"&gt;
Solved&lt;br /&gt; &lt;br /&gt;Made my object a UserControl. This simplified a lot of things.&lt;br /&gt; &lt;br /&gt;Storyboard _storyboard = (Storyboard)FindResource(&amp;quot;FloorActiveStory&amp;quot;);&lt;br /&gt; _storyboard.Begin(this);&lt;br /&gt;
&lt;/div&gt;</description><author>elazzal</author><pubDate>Fri, 29 Feb 2008 15:10:19 GMT</pubDate><guid isPermaLink="false">NEW POST: assign Storyboard to a InteractiveVisual3D 20080229031019P</guid></item><item><title>NEW POST: assign Storyboard to a InteractiveVisual3D</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=22944</link><description>&lt;div class="wikidoc"&gt;
Assigning a simple animation to a IV3D (InteractiveVisual3D) seems to be quite simple:&lt;br /&gt; &lt;br /&gt;RotateTransform3D rotateTransform = (RotateTransform3D) _interactiveVisual3D.Transform;&lt;br /&gt;Rotation3DAnimation animation = new Rotation3DAnimation(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 40), TimeSpan.FromSeconds(2));&lt;br /&gt;rotateTransform.BeginAnimation(RotateTransform3D.RotationProperty, animation);&lt;br /&gt;_interactiveVisual3D.Transform = rotateTransform;&lt;br /&gt; &lt;br /&gt;The code above performs a simple Rotation3D.&lt;br /&gt; &lt;br /&gt;However, i would like to create a complex set of animations (in Blend).  I.e. rotation and scaling, with easing concurrently.&lt;br /&gt;Therefore i would probably need to use Storyboards.  The problem is however, I can not seem to get this work with c#.&lt;br /&gt;In Blend I can manipulate a IV3D easily using a Storyboard.  In C#, VS complains that I cannot Animate a non FrameworkElement object. (Strangely it DOES works in Blend with XAML)&lt;br /&gt; &lt;br /&gt;The code I am trying to get to work is:&lt;br /&gt; &lt;br /&gt;Storyboard storyboard = new Storyboard();&lt;br /&gt;Rotation3DAnimation &lt;i&gt;rotationAnimation = (Rotation3DAnimation)&lt;/i&gt;floor.FindResource(&amp;quot;someLocalAnimation -- see XAML code below&amp;quot;);&lt;br /&gt;Storyboard.SetTargetName(_rotationAnimation, ??);&lt;br /&gt;Storyboard.SetTargetProperty(_rotationAnimation, new PropertyPath(RotateTransform3D.RotationProperty));&lt;br /&gt;storyboard.Children.Add(_rotationAnimation);&lt;br /&gt;storyboard.Begin(_interactiveVisual3D,true);  // &amp;lt;= here he complains!!&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;Resource Dictionary&lt;br /&gt;-------------------------&lt;br /&gt;&amp;lt;Rotation3DAnimation x:Key=&amp;quot;someLocalAnimation&amp;quot;&amp;gt;&lt;br /&gt;            &amp;lt;Rotation3DAnimation.To&amp;gt;&lt;br /&gt;                &amp;lt;AxisAngleRotation3D Axis=&amp;quot;1,0,0&amp;quot; Angle=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;            &amp;lt;/Rotation3DAnimation.To&amp;gt;&lt;br /&gt;&amp;lt;/Rotation3DAnimation&amp;gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;
&lt;/div&gt;</description><author>elazzal</author><pubDate>Wed, 27 Feb 2008 13:43:10 GMT</pubDate><guid isPermaLink="false">NEW POST: assign Storyboard to a InteractiveVisual3D 20080227014310P</guid></item><item><title>NEW POST: ScreenSpaceLines3D ScaleTransform bug?</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=22615</link><description>&lt;div class="wikidoc"&gt;
When performing a ScaleTransform on a ScreenSpaceLines3D from 1 to 0 and back again it disappears.  See attached code.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;b&gt;XAML&lt;/b&gt;&lt;br /&gt;&amp;lt;Window x:Class=&amp;quot;_3DPreviewer.Window1&amp;quot;&lt;br /&gt;    xmlns=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;br /&gt;    xmlns:x=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;br /&gt;        xmlns:tool3d=&amp;quot;clr-namespace:_3DTools;assembly=3DTools&amp;quot;&lt;br /&gt;    Title=&amp;quot;Window1&amp;quot; Height=&amp;quot;488&amp;quot; Width=&amp;quot;940&amp;quot; x:Name=&amp;quot;MainWindow1&amp;quot; Loaded=&amp;quot;MainWindow1_Loaded&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;DockPanel&amp;gt;&lt;br /&gt;        &amp;lt;ToggleButton x:Name=&amp;quot;theBtn&amp;quot; Click=&amp;quot;Button_Click&amp;quot;&amp;gt;Scale&amp;lt;/ToggleButton&amp;gt;&lt;br /&gt;        &amp;lt;Viewport3D x:Name=&amp;quot;theView3D&amp;quot; OpacityMask=&amp;quot;{x:Null}&amp;quot; Grid.ColumnSpan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;            &amp;lt;Viewport3D.Camera&amp;gt;&lt;br /&gt;                &amp;lt;PerspectiveCamera Position=&amp;quot;6,6,6&amp;quot; LookDirection=&amp;quot;-4,-4,-4&amp;quot;&lt;br /&gt;							UpDirection=&amp;quot;0,1,0&amp;quot; /&amp;gt;&lt;br /&gt;            &amp;lt;/Viewport3D.Camera&amp;gt;&lt;br /&gt; &lt;br /&gt;            &amp;lt;ModelVisual3D x:Name=&amp;quot;theModel&amp;quot;&amp;gt;&lt;br /&gt;                &amp;lt;ModelVisual3D.Content&amp;gt;&lt;br /&gt;                    &amp;lt;Model3DGroup&amp;gt;&lt;br /&gt; &lt;br /&gt;                        &amp;lt;DirectionalLight Direction=&amp;quot;0,-5,-2&amp;quot; /&amp;gt;&lt;br /&gt;                        &amp;lt;DirectionalLight Direction=&amp;quot;3,2,2&amp;quot; /&amp;gt;&lt;br /&gt; &lt;br /&gt;                        &amp;lt;GeometryModel3D x:Name=&amp;quot;theGeometry&amp;quot;&amp;gt;&lt;br /&gt;                            &amp;lt;GeometryModel3D.Geometry&amp;gt;&lt;br /&gt;                                &amp;lt;MeshGeometry3D Positions=&amp;quot;0,1,0 1,-1,1 -1,-1,1 1,-1,-1 -1,-1,-1&amp;quot;&lt;br /&gt;											Normals=&amp;quot;0,1,0 -1,0,1 1,0,1 -1,0,-1 1,0,-1&amp;quot;&lt;br /&gt;											TriangleIndices=&amp;quot;0,2,1  0,3,1  0,3,4  0,2,4&amp;quot; /&amp;gt;&lt;br /&gt;                            &amp;lt;/GeometryModel3D.Geometry&amp;gt;&lt;br /&gt; &lt;br /&gt;                            &amp;lt;GeometryModel3D.Material&amp;gt;&lt;br /&gt;                                &amp;lt;DiffuseMaterial Brush=&amp;quot;Red&amp;quot; /&amp;gt;&lt;br /&gt;                            &amp;lt;/GeometryModel3D.Material&amp;gt;&lt;br /&gt; &lt;br /&gt;                            &amp;lt;GeometryModel3D.BackMaterial&amp;gt;&lt;br /&gt;                                &amp;lt;DiffuseMaterial Brush=&amp;quot;Green&amp;quot; /&amp;gt;&lt;br /&gt;                            &amp;lt;/GeometryModel3D.BackMaterial&amp;gt;&lt;br /&gt;                        &amp;lt;/GeometryModel3D&amp;gt;&lt;br /&gt; &lt;br /&gt;                    &amp;lt;/Model3DGroup&amp;gt;&lt;br /&gt;                &amp;lt;/ModelVisual3D.Content&amp;gt;&lt;br /&gt;            &amp;lt;/ModelVisual3D&amp;gt;&lt;br /&gt;            &lt;br /&gt;            &amp;lt;tool3d:ScreenSpaceLines3D Points=&amp;quot;-6,0,0 6,0,0&amp;quot; Color=&amp;quot;Red&amp;quot; x:Name=&amp;quot;theLine&amp;quot; /&amp;gt;&lt;br /&gt;        &amp;lt;/Viewport3D&amp;gt;&lt;br /&gt;    &amp;lt;/DockPanel&amp;gt;&lt;br /&gt;&amp;lt;/Window&amp;gt;&lt;br /&gt; &lt;br /&gt;&lt;b&gt;Code behind&lt;/b&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Windows;&lt;br /&gt;using System.Windows.Controls;&lt;br /&gt;using System.Windows.Data;&lt;br /&gt;using System.Windows.Documents;&lt;br /&gt;using System.Windows.Input;&lt;br /&gt;using System.Windows.Media;&lt;br /&gt;using System.Windows.Media.Media3D;&lt;br /&gt;using System.Windows.Media.Imaging;&lt;br /&gt;using System.Windows.Navigation;&lt;br /&gt;using System.Windows.Shapes;&lt;br /&gt; &lt;br /&gt;namespace _3DPreviewer&lt;br /&gt;{&lt;br /&gt;   /// &amp;lt;summary&amp;gt;&lt;br /&gt;   /// Interaction logic for Window1.xaml&lt;br /&gt;   /// &amp;lt;/summary&amp;gt;&lt;br /&gt;   public partial class Window1 : Window&lt;br /&gt;   {&lt;br /&gt;      ScaleTransform3D scaleTransform = new ScaleTransform3D( 1.0, 1.0, 1.0 );&lt;br /&gt;      public Window1 ()&lt;br /&gt;      {&lt;br /&gt;         InitializeComponent();&lt;br /&gt;         theLine.Transform = scaleTransform;&lt;br /&gt;         theModel.Transform = scaleTransform;&lt;br /&gt; &lt;br /&gt;      }&lt;br /&gt; &lt;br /&gt;      private void MainWindow1_Loaded ( object sender, RoutedEventArgs e )&lt;br /&gt;      {&lt;br /&gt; &lt;br /&gt;      }&lt;br /&gt; &lt;br /&gt;      private void Button_Click ( object sender, RoutedEventArgs e )&lt;br /&gt;      {&lt;br /&gt;         if ( theBtn.IsChecked == true )&lt;br /&gt;         {&lt;br /&gt;            scaleTransform.ScaleX = scaleTransform.ScaleY = scaleTransform.ScaleZ = 0.0;&lt;br /&gt;         }&lt;br /&gt;         else&lt;br /&gt;         {&lt;br /&gt;            scaleTransform.ScaleX = scaleTransform.ScaleY = scaleTransform.ScaleZ = 1.0;&lt;br /&gt;         }&lt;br /&gt; &lt;br /&gt;      }&lt;br /&gt; &lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;
&lt;/div&gt;</description><author>kbeal2k</author><pubDate>Thu, 21 Feb 2008 20:31:56 GMT</pubDate><guid isPermaLink="false">NEW POST: ScreenSpaceLines3D ScaleTransform bug? 20080221083156P</guid></item><item><title>NEW POST: Roaming camera implementation</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=22310</link><description>&lt;div class="wikidoc"&gt;
The following is based on the TrackballDecorator, and is a drop-in replacement for it.  Create a new class in the 3DTools project, paste in this code and compile.  Replace your project's &amp;lt;TrackballDecorator&amp;gt; xaml tag(s) w/ &amp;lt;Roam3DDecorator&amp;gt; and run.&lt;br /&gt; &lt;br /&gt;Rather than the camera be on a trackball that orbits about the origin, the camera will be free-roaming.&lt;br /&gt; &lt;br /&gt;Hold the left mouse button to spin, the right mouse button to move forward and back, and hold the left+right mouse buttons to slide left/right/up/down.&lt;br /&gt; &lt;br /&gt;All movements are relative to the camera's current location, so the camera moves around the 3D world, rather than just orbiting about the origin.&lt;br /&gt; &lt;br /&gt;NOTE: The code assumes the use of a PerspectiveCamera.&lt;br /&gt; &lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Windows.Input;&lt;br /&gt;using System.Windows.Media.Media3D;&lt;br /&gt;using System.Windows;&lt;br /&gt;using System.Windows.Controls;&lt;br /&gt;using System.Windows.Media;&lt;br /&gt; &lt;br /&gt;namespace _3DTools&lt;br /&gt;{&lt;br /&gt;    public class Roam3DDecorator : Viewport3DDecorator&lt;br /&gt;    {&lt;br /&gt;        #region Fields&lt;br /&gt; &lt;br /&gt;        private Point _previousPosition2D;&lt;br /&gt;        private Border _eventSource;&lt;br /&gt; &lt;br /&gt;        #endregion&lt;br /&gt; &lt;br /&gt;        public Roam3DDecorator()&lt;br /&gt;        {&lt;br /&gt;            _eventSource = new Border();&lt;br /&gt;            _eventSource.Background = Brushes.Transparent;&lt;br /&gt;            &lt;br /&gt;            PreViewportChildren.Add(_eventSource);&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        #region Event Handling&lt;br /&gt; &lt;br /&gt;        protected override void OnMouseDown(MouseButtonEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            base.OnMouseDown(e);&lt;br /&gt; &lt;br /&gt;            _previousPosition2D = e.GetPosition(this);&lt;br /&gt; &lt;br /&gt;            if (Mouse.Captured == null)&lt;br /&gt;            {&lt;br /&gt;                Mouse.Capture(this, CaptureMode.Element);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        protected override void OnMouseUp(MouseButtonEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            base.OnMouseUp(e);&lt;br /&gt; &lt;br /&gt;            if (IsMouseCaptured)&lt;br /&gt;            {&lt;br /&gt;                Mouse.Capture(this, CaptureMode.None);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        protected override void OnMouseMove(MouseEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            base.OnMouseMove(e);&lt;br /&gt; &lt;br /&gt;            if (IsMouseCaptured)&lt;br /&gt;            {&lt;br /&gt;                Point currentPosition = e.GetPosition(this);&lt;br /&gt; &lt;br /&gt;                // avoid any zero axis conditions&lt;br /&gt;                if (currentPosition == _previousPosition2D) return;&lt;br /&gt; &lt;br /&gt;                if (e.RightButton == MouseButtonState.Pressed&lt;br /&gt;                    &amp;amp;&amp;amp; e.LeftButton == MouseButtonState.Pressed)&lt;br /&gt;                {&lt;br /&gt;                    SlideCamera(currentPosition);&lt;br /&gt;                }&lt;br /&gt;                else if (e.LeftButton == MouseButtonState.Pressed)&lt;br /&gt;                {&lt;br /&gt;                    RotateCamera(currentPosition);&lt;br /&gt;                }&lt;br /&gt;                else if (e.RightButton == MouseButtonState.Pressed)&lt;br /&gt;                {&lt;br /&gt;                    ZoomCamera(currentPosition);&lt;br /&gt;                }&lt;br /&gt; &lt;br /&gt;                _previousPosition2D = currentPosition;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        #endregion Event Handling&lt;br /&gt; &lt;br /&gt;        #region Camera movement&lt;br /&gt; &lt;br /&gt;        private void RotateCamera(Point currentPosition)&lt;br /&gt;        {&lt;br /&gt;            PerspectiveCamera camera = (PerspectiveCamera)FindCamera();&lt;br /&gt; &lt;br /&gt;            Vector3D camZ = camera.LookDirection;&lt;br /&gt;            camZ.Normalize();&lt;br /&gt;            Vector3D camX = -Vector3D.CrossProduct(camZ, camera.UpDirection);&lt;br /&gt;            Vector3D camY = Vector3D.CrossProduct(camZ, camX);&lt;br /&gt; &lt;br /&gt;            double dX = currentPosition.X - _previousPosition2D.X;&lt;br /&gt;            double dY = currentPosition.Y - _previousPosition2D.Y;&lt;br /&gt; &lt;br /&gt;            dX /= -5;&lt;br /&gt;            dY /= 5;&lt;br /&gt; &lt;br /&gt;            AxisAngleRotation3D aarY = new AxisAngleRotation3D(&lt;br /&gt;                camY, dX);&lt;br /&gt;            AxisAngleRotation3D aarX = new AxisAngleRotation3D(&lt;br /&gt;                camX, dY);&lt;br /&gt; &lt;br /&gt;            RotateTransform3D rotY = new RotateTransform3D(aarY);&lt;br /&gt;            RotateTransform3D rotX = new RotateTransform3D(aarX);&lt;br /&gt; &lt;br /&gt;            camZ = camZ * rotY.Value * rotX.Value;&lt;br /&gt;            camZ.Normalize();&lt;br /&gt;            camY = camY * rotX.Value * rotY.Value;&lt;br /&gt;            camY.Normalize();&lt;br /&gt; &lt;br /&gt;            camera.LookDirection = camZ;&lt;br /&gt;            camera.UpDirection = camY;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        private void ZoomCamera(Point currentPosition)&lt;br /&gt;        {&lt;br /&gt;            double yDelta = currentPosition.Y - _previousPosition2D.Y;&lt;br /&gt; &lt;br /&gt;            yDelta /= 3;&lt;br /&gt;            &lt;br /&gt;            PerspectiveCamera camera = (PerspectiveCamera)FindCamera();&lt;br /&gt; &lt;br /&gt;            Point3D position = camera.Position;&lt;br /&gt; &lt;br /&gt;            position -= camera.LookDirection * yDelta;&lt;br /&gt; &lt;br /&gt;            camera.Position = position;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        private void SlideCamera(Point currentPosition)&lt;br /&gt;        {&lt;br /&gt;            PerspectiveCamera camera = (PerspectiveCamera)FindCamera();&lt;br /&gt; &lt;br /&gt;            Vector3D camZ = camera.LookDirection;&lt;br /&gt;            camZ.Normalize();&lt;br /&gt;            Vector3D camX = -Vector3D.CrossProduct(camZ, camera.UpDirection);&lt;br /&gt;            Vector3D camY = Vector3D.CrossProduct(camZ, camX);&lt;br /&gt; &lt;br /&gt;            double dX = currentPosition.X - _previousPosition2D.X;&lt;br /&gt;            double dY = currentPosition.Y - _previousPosition2D.Y;&lt;br /&gt; &lt;br /&gt;            dX /= -30;&lt;br /&gt;            dY /= -30;&lt;br /&gt; &lt;br /&gt;            Vector3D vSlide = (camX * dX) + (camY * dY);&lt;br /&gt; &lt;br /&gt;            Point3D cameraPos = camera.Position;&lt;br /&gt;            cameraPos += vSlide;&lt;br /&gt;            camera.Position = cameraPos;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        private Camera FindCamera()&lt;br /&gt;        {&lt;br /&gt;            Viewport3D viewport3D = this.Viewport3D;&lt;br /&gt;            if (viewport3D != null)&lt;br /&gt;            {&lt;br /&gt;                if (viewport3D.Camera != null)&lt;br /&gt;                {&lt;br /&gt;                    if (viewport3D.Camera.IsFrozen)&lt;br /&gt;                    {&lt;br /&gt;                        viewport3D.Camera = viewport3D.Camera.Clone();&lt;br /&gt;                    }&lt;br /&gt;                    return viewport3D.Camera;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            return null;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        #endregion&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;
&lt;/div&gt;</description><author>karymcfadden</author><pubDate>Sat, 16 Feb 2008 22:02:55 GMT</pubDate><guid isPermaLink="false">NEW POST: Roaming camera implementation 20080216100255P</guid></item><item><title>NEW POST: Fix camera trackball</title><link>http://www.codeplex.com/3DTools/Thread/View.aspx?ThreadId=21850</link><description>&lt;div class="wikidoc"&gt;
May not be a problem for others, but the way the camera tracks seems odd to me.  To see this, place the camera at Position=0,3,0, LookDirection=0,-1,0, and UpDirection=0,0,-1.  This will place the camera 3 units up the Y axis, looking down the Y axis.  Create some unit-length ScreenSpaceLines on the X,Y,Z axes to see what's happening.&lt;br /&gt; &lt;br /&gt;Run your app; you'll see the X and Z axes, since you're looking down the Y axis.  Place the cursor at the center, hold the mouse, and drag left or right.  Instead of rotating the ScreenSpaceLines (or model or whatever you're viewing) about the Z axis, they rotate about the Y axis.&lt;br /&gt; &lt;br /&gt;This is due to the way the ProjectToTrackball works, which assumes the camera is placed on the Z axis, looking at the origin.  It doesn't take into account the camera's current position.&lt;br /&gt; &lt;br /&gt;To change this, insert the following in the Track() method in the TrackballDecorator class, just after the line &amp;quot;double angle = ...&amp;quot;:&lt;br /&gt; &lt;br /&gt;            // Get the viewport's camera.&lt;br /&gt;            Camera vpCamera = this.Viewport3D.Camera;&lt;br /&gt;            if (vpCamera.IsFrozen)&lt;br /&gt;                vpCamera = vpCamera.Clone();&lt;br /&gt; &lt;br /&gt;            // Assume it's a perspective camera.&lt;br /&gt;            PerspectiveCamera camera = vpCamera as PerspectiveCamera;&lt;br /&gt; &lt;br /&gt;            // Build a rotation matrix using camera's LookDirection as the Z&lt;br /&gt;            // axis, its UpDirection as the Y axis, and the cross product&lt;br /&gt;            // of the two as its X axis.&lt;br /&gt;            Vector3D camZ = camera.LookDirection;&lt;br /&gt;            camZ.Normalize();&lt;br /&gt;            Vector3D camY = camera.UpDirection;&lt;br /&gt;            camY.Normalize();&lt;br /&gt;            Vector3D camX = Vector3D.CrossProduct(camZ, camY);&lt;br /&gt;            camX.Normalize();&lt;br /&gt; &lt;br /&gt;            camY = Vector3D.CrossProduct(camX, camZ);&lt;br /&gt;            camY.Normalize();&lt;br /&gt; &lt;br /&gt;            // Build a rotational matrix using the axes specified by&lt;br /&gt;            // the camera's position.&lt;br /&gt;            Matrix3D m = new Matrix3D(&lt;br /&gt;                camX.X, camX.Y, camX.Z, 0,&lt;br /&gt;                camY.X, camY.Y, camY.Z, 0,&lt;br /&gt;                camZ.X, camZ.Y, camZ.Z, 0,&lt;br /&gt;                0, 0, 0, 1&lt;br /&gt;                );&lt;br /&gt;            m.Invert();&lt;br /&gt; &lt;br /&gt;            // Transform the trackball rotational axis to be relative to&lt;br /&gt;            // the camera's position.&lt;br /&gt;            axis = m.Transform(axis);&lt;br /&gt; &lt;br /&gt;Give it a whirl, and see if the trackball doesn't seem more natural.&lt;br /&gt; &lt;br /&gt;Kary&lt;br /&gt;
&lt;/div&gt;</description><author>karymcfadden</author><pubDate>Sun, 10 Feb 2008 02:47:38 GMT</pubDate><guid isPermaLink="false">NEW POST: Fix camera trackball 20080210024738A</guid></item></channel></rss>