<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Daniel Lehenbauer's Blog</title><subtitle type="html">Exploring 3D graphics with the Windows Presentation Foundation, and other topics occasionally of interest to .NET developers.</subtitle><id>http://blogs.msdn.com/danlehen/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/danlehen/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2004-11-23T00:39:00Z</updated><entry><title>My not-so new opportunity...</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2009/05/13/my-not-so-new-opportunity.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2009/05/13/my-not-so-new-opportunity.aspx</id><published>2009-05-13T13:13:00Z</published><updated>2009-05-13T13:13:00Z</updated><content type="html">&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;It is perhaps an understatement to say it's been a while since I blogged.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;As is commonly the case with Microsoft blogs, the reason for going dark is that I left the WPF team almost two years ago for an opportunity I couldn't&amp;nbsp;pass by&amp;nbsp;to join&amp;nbsp;a systems incubation startup.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;We're a small team with big ambitions, and as you might expect, my role involves the&amp;nbsp;exploration&amp;nbsp;of a radically different approach to the&amp;nbsp;UI/Graphics&amp;nbsp;platform which guarantees security, responsiveness, and leverages modern GPUs and manycore.&amp;nbsp; To deliver on this vision, we are revisiting every layer of the stack from device drivers, through rendering engines, up to application frameworks and programming/computation models.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;While we’re not specifically seeking to fill headcount on our team, we are always on the lookout for luminaries with insight, experience, and who love to write code.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If you are interested in joining a deep systems incubation that believes in small, hand-picked teams of truly outstanding developers, please do &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/danlehen/contact.aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;contact me&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;While much is demanded of everyone in this group, we also get to participate in what I personally believe is the most exciting and revolutionary work to happen in the industry since PARC.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9609334" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry><entry><title>New Blender Exporter Features: Double Sided &amp; Solid (Flat) Shading</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2006/06/22/new-blender-exporter-features-double-sided-solid-flat-shading.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2006/06/22/new-blender-exporter-features-double-sided-solid-flat-shading.aspx</id><published>2006-06-23T04:33:00Z</published><updated>2006-06-23T04:33:00Z</updated><content type="html">&lt;P&gt;[&lt;STRONG&gt;UPDATE:&lt;/STRONG&gt; The Xaml Exporter now is hosted on CodePlex (&lt;A class="" href="http://codeplex.com/xamlexporter" mce_href="http://codeplex.com/xamlexporter"&gt;here&lt;/A&gt;)]&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I checked in an updated&amp;nbsp;Blender&amp;nbsp;exporter&amp;nbsp;to&amp;nbsp;&lt;A href="http://workspaces.gotdotnet.com/3dtools" mce_href="http://workspaces.gotdotnet.com/3dtools"&gt;3D Tools for Windows Presentation Foundation&lt;/A&gt;&amp;nbsp;which adds support for double sided materials and flat shaded geometry.&amp;nbsp; I have not yet package a new release, so for the moment you’ll need to grab xaml_export.py from &lt;A href="http://www.gotdotnet.com/workspaces/messageboard/thread.aspx?id=2ce2a6b8-2085-4839-a001-1c539525f5fa&amp;amp;threadid=251954b2-5f3e-4ea2-8aa4-f4202bc588a3" mce_href="http://www.gotdotnet.com/workspaces/messageboard/thread.aspx?id=2ce2a6b8-2085-4839-a001-1c539525f5fa&amp;amp;threadid=251954b2-5f3e-4ea2-8aa4-f4202bc588a3"&gt;source control&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://viewport3d.com/Blog_files/Blender_Smooth_2Sided.PNG" border=0 mce_src="http://viewport3d.com/Blog_files/Blender_Smooth_2Sided.PNG"&gt;&lt;/P&gt;
&lt;P&gt;These features are accessible via the circled buttons on the material and mesh panels during editing.&amp;nbsp; Thanks to SEISENBERG for reporting this in the &lt;A href="http://www.gotdotnet.com/workspaces/messageboard/thread.aspx?id=2ce2a6b8-2085-4839-a001-1c539525f5fa&amp;amp;threadid=251954b2-5f3e-4ea2-8aa4-f4202bc588a3" mce_href="http://www.gotdotnet.com/workspaces/messageboard/thread.aspx?id=2ce2a6b8-2085-4839-a001-1c539525f5fa&amp;amp;threadid=251954b2-5f3e-4ea2-8aa4-f4202bc588a3"&gt;message board&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=643677" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry><entry><title> Looking for ScreenSpaceLines3D? -- 3D Tools v0.4 released</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2006/05/29/610310.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2006/05/29/610310.aspx</id><published>2006-05-29T22:08:13Z</published><updated>2006-05-29T22:08:13Z</updated><content type="html">&lt;p&gt;I have posted a &lt;a href="http://www.gotdotnet.com/workspaces/releases/viewuploads.aspx?id=2ce2a6b8-2085-4839-a001-1c539525f5fa"&gt;new release&lt;/a&gt; of the &lt;a href="http://workspaces.gotdotnet.com/3dtools"&gt;3D Tools for the Windows Presentation Foundation&lt;/a&gt; targeting &lt;a href="http://msdn.microsoft.com/windowsvista/downloads/products/getthebeta/default.aspx#developWinFXApps"&gt;the Beta 2 release of the WinFX runtime&lt;/a&gt;.&amp;nbsp; The big addition in this release is a community owned implementation of the ScreenSpaceLines3D class.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;ScreenSpaceLines3D&amp;nbsp;is&amp;nbsp;a 3D line primitive whose thickness&amp;nbsp;is constant in 2D space post projection.*&amp;nbsp; This means that the lines do not become &amp;ldquo;skinnier&amp;rdquo; as they receded from&amp;nbsp;a perspective&amp;nbsp;camera.&amp;nbsp; ScreenSpaceLines3D are most frequently used to implement bounding boxes, wireframe mode, or visualization of normals for editors.&amp;nbsp; Occasionally they are used in 3D scenes to represent telephone wires and similar objects that are too thin to be rendered reliably under a perspective projection.&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img src="http://viewport3d.com/Blog_files/Wireframe1p.PNG" /&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="http://viewport3d.com/Blog_files/Wireframe2p.PNG" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;I also started a MathUtils class which contains some generally useful utility methods, such as getting the View/Projection matrices from any camera and a method which returns the 3D -&amp;gt; 2D transform (useful for positioning 2D content, like text labels,&amp;nbsp;relative to&amp;nbsp;3D content.)&amp;nbsp; I&amp;rsquo;ve also added a wireframe mode to the ModelViewer sample to test ScreenSpaceLines3D.&lt;/p&gt;
&lt;p&gt;The project has been refactored into just two assemblies: 3DTools.dll which contains the reusable runtime components and the ModelViewer.exe sample.&amp;nbsp; Enjoy!&lt;/p&gt;
&lt;p&gt;* The name ScreenSpaceLines3D was a bit of a misnomer.&amp;nbsp; The lines were actually of constant thickness in the post-projective space of the Viewport3DVisual, not &amp;ldquo;device space&amp;rdquo; or &amp;ldquo;screen space&amp;rdquo; as the name implied.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=610310" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry><entry><title>Sphere, Cone, and Cylinder Sample Updated</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2006/02/11/530361.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2006/02/11/530361.aspx</id><published>2006-02-12T04:23:00Z</published><updated>2006-02-12T04:23:00Z</updated><content type="html">&lt;P&gt;&lt;STRONG&gt;Minor update:&lt;/STRONG&gt; The "&lt;A HREF="/danlehen/archive/2005/10/16/481597.aspx"&gt;Extending Visual3D - Sphere, Cone, and Cylinder&lt;/A&gt;" sample has been updated to the &lt;A HREF="/danlehen/archive/2005/12/19/505647.aspx"&gt;December&lt;/A&gt;&amp;nbsp;and &lt;A HREF="/danlehen/archive/2006/01/18/514574.aspx"&gt;January CTP&lt;/A&gt; (either will work).&amp;nbsp; Thanks to Barry Briggs for doing this and sending me the updated source.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=530361" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry><entry><title>Xaml Export Script for Blender</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2006/01/14/xaml-export-script-for-blender.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2006/01/14/xaml-export-script-for-blender.aspx</id><published>2006-01-15T04:13:00Z</published><updated>2006-01-15T04:13:00Z</updated><content type="html">&lt;P&gt;&lt;STRONG&gt;[UPDATE:&lt;/STRONG&gt; The Xaml Exporter now is hosted on CodePlex (&lt;A class="" href="http://codeplex.com/xamlexporter" mce_href="http://codeplex.com/xamlexporter"&gt;here&lt;/A&gt;)&lt;STRONG&gt;]&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 3D features in the Windows Presentation Foundation make it easier than ever&amp;nbsp;to&amp;nbsp;integrate 3D content into your applications.&amp;nbsp; However, unless you are satisfied with &lt;A href="http://blogs.msdn.com/danlehen/archive/2005/10/16/481597.aspx" mce_href="http://blogs.msdn.com/danlehen/archive/2005/10/16/481597.aspx"&gt;basic solid geometry&lt;/A&gt; you are going to need more than just the WPF.&amp;nbsp; You’re going to need 3D authoring tools to create interesting content.&lt;/P&gt;
&lt;P&gt;Unfortunately 3D tools tend to use their own proprietary file formats with limited import/export support for other formats.&amp;nbsp; Xaml, being new to the scene (no pun intended), is not yet supported by most tools.&amp;nbsp; However, some modeling programs&amp;nbsp;feature an add-in architecture that allows custom exporters to be written by 3rd parties.&amp;nbsp; The free 3D software package &lt;A href="http://en.wikipedia.org/wiki/Blender_%28software%29" mce_href="http://en.wikipedia.org/wiki/Blender_%28software%29"&gt;Blender&lt;/A&gt; is such a tool.&lt;/P&gt;
&lt;P&gt;All very interesting you say, but where is this going?&lt;/P&gt;
&lt;P&gt;I&amp;nbsp;have posted a&amp;nbsp;new release&amp;nbsp;of the &lt;A href="http://workspaces.gotdotnet.com/3dtools" mce_href="http://workspaces.gotdotnet.com/3dtools"&gt;3D Tools for the WPF&lt;/A&gt;&amp;nbsp;which&amp;nbsp;includes a Python script to export Blender scenes as Xaml.&amp;nbsp; The Xaml can then be dynamically loaded or compiled into your WPF applications.&amp;nbsp; Figure 1a shows a 3D model being edited with Blender.&amp;nbsp; Figure 1b shows the final exported Xaml as viewed with the &lt;A href="http://blogs.msdn.com/danlehen/archive/2005/12/20/506058.aspx" mce_href="http://blogs.msdn.com/danlehen/archive/2005/12/20/506058.aspx"&gt;WPF Model Viewer&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class="" id=table1 cellSpacing=1 width="59%" border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" width=301&gt;&lt;A href="http://viewport3d.com/XamlExporter/ReadMe_files/ReadMe1.jpg" mce_href="http://viewport3d.com/XamlExporter/ReadMe_files/ReadMe1.jpg"&gt;&lt;IMG height=223 src="http://viewport3d.com/XamlExporter/ReadMe_files/ReadMe1.jpg" width=300 border=0 mce_src="http://viewport3d.com/XamlExporter/ReadMe_files/ReadMe1.jpg"&gt;&lt;/A&gt;&lt;/TD&gt;
&lt;TD class=""&gt;&lt;A href="http://viewport3d.com/XamlExporter/ReadMe_files/ReadMe2.jpg" mce_href="http://viewport3d.com/XamlExporter/ReadMe_files/ReadMe2.jpg"&gt;&lt;IMG height=222 src="http://viewport3d.com/XamlExporter/ReadMe_files/ReadMe2.jpg" width=300 border=0 mce_src="http://viewport3d.com/XamlExporter/ReadMe_files/ReadMe2.jpg"&gt;&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top align=left width=301&gt;&lt;B&gt;Figure 1a&lt;BR&gt;&lt;/B&gt;&lt;I&gt;The&amp;nbsp;Steve Ballmer model*&amp;nbsp;is authored in Blender and then exported to Xaml.&lt;/I&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top align=left&gt;&lt;B&gt;Figure 1b&lt;BR&gt;&lt;/B&gt;&lt;I&gt;The final model as it appears in the WPF Model Viewer.&lt;/I&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top align=left colSpan=2&gt;
&lt;P align=center&gt;&lt;BR&gt;(Click for full sized images)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;Because the WPF and Blender have different goals for their rendering engines&amp;nbsp;their feature sets do not match precisely.&amp;nbsp; Specifically, the WPF uses the hardware accelerated real-time rendering capabilities of your GPU.&amp;nbsp; Blender is a software based rendering engine not targeted at real-time applications.&amp;nbsp; However, the results of the export are frequently quite good.&amp;nbsp; Figure 2a is the same 3D model as rendered by Blender.&amp;nbsp; Figure 2b is the exported model viewed from a similar angle with the same lighting configuration in the WPF Model Viewer.&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class="" id=table1 cellSpacing=1 width="59%" border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" width=301&gt;&lt;A href="http://viewport3d.com/XamlExporter/XamlExporter_Blender.jpg" mce_href="http://viewport3d.com/XamlExporter/XamlExporter_Blender.jpg"&gt;&lt;IMG height=223 src="http://viewport3d.com/XamlExporter/XamlExporter_Blender.jpg" width=300 border=0 mce_src="http://viewport3d.com/XamlExporter/XamlExporter_Blender.jpg"&gt;&lt;/A&gt;&lt;/TD&gt;
&lt;TD class=""&gt;&lt;A href="http://viewport3d.com/XamlExporter/XamlExporter_WPF.jpg" mce_href="http://viewport3d.com/XamlExporter/XamlExporter_WPF.jpg"&gt;&lt;IMG height=222 src="http://viewport3d.com/XamlExporter/XamlExporter_WPF.jpg" width=300 border=0 mce_src="http://viewport3d.com/XamlExporter/XamlExporter_WPF.jpg"&gt;&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top align=left width=301&gt;&lt;B&gt;Figure 2a&lt;BR&gt;&lt;/B&gt;&lt;I&gt;Steve Ballmer model* rendered using Blender’s internal&amp;nbsp;software engine.&lt;/I&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top align=left&gt;&lt;B&gt;Figure 2b&lt;BR&gt;&lt;/B&gt;&lt;I&gt;Exported model rendered using the WPF.&amp;nbsp; The blue background is not part of the scene.&lt;/I&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top align=left colSpan=2&gt;
&lt;P align=center&gt;&lt;BR&gt;(Click for full sized images)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;To get the Xaml Export Script for Blender and the WPF Model Viewer download the latest version of the 3D Tools for WPF (&lt;A href="http://www.gotdotnet.com/workspaces/releases/viewuploads.aspx?id=2ce2a6b8-2085-4839-a001-1c539525f5fa" mce_href="http://www.gotdotnet.com/workspaces/releases/viewuploads.aspx?id=2ce2a6b8-2085-4839-a001-1c539525f5fa"&gt;available here&lt;/A&gt;).&amp;nbsp; Copy the xaml_export.py script to your Blender scripts directory.&amp;nbsp; Blender will automatically add the script to the ~File~Export menu the next time it is started.&amp;nbsp; More detailed instructions and a list of known issues are included in &lt;A href="http://viewport3d.com/XamlExporter/ReadMe.htm" mce_href="http://viewport3d.com/XamlExporter/ReadMe.htm"&gt;the Read-Me&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;* Steve Ballmer model courtesy of Bonnie Lehenbauer&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=513012" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry><entry><title>Why did we change LookAtPoint to LookDirection?</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2006/01/03/509092.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2006/01/03/509092.aspx</id><published>2006-01-04T06:43:44Z</published><updated>2006-01-04T06:43:44Z</updated><content type="html">&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;Ernie &lt;a href="http://blogs.msdn.com/ebooth/archive/2005/12/07/500796.aspx"&gt;posted&lt;/a&gt; about the differences between the old LookAtPoint property and the new LookDirection property on ProjectionCamera (via &lt;a href="http://blogs.msdn.com/karstenj/archive/2005/12/08/501828.aspx"&gt;KarstenJ&lt;/a&gt;.)&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The quick summary is that LookAtPoint caused the camera to look at a fixed point in space (Figure 1a).&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The new LookDirection property causes the camera to look in a fixed direction (Figure 1b).&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix ="" o ns ="" "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;table class="MsoTableGrid" style="BORDER-COLLAPSE: collapse; mso-yfti-tbllook: 480; mso-padding-alt: 0in 5.4pt 0in 5.4pt" cellspacing="0" cellpadding="0" border="0"&gt;
&lt;tbody&gt;
&lt;tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes"&gt;
&lt;td style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #ece9d8; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" valign="top" width="295"&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: center" align="center"&gt;&lt;?xml:namespace prefix ="" v ns ="" "urn:schemas-microsoft-com:vml" /&gt;&lt;v:shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"&gt;&lt;v:stroke joinstyle="miter"&gt;&lt;/v:stroke&gt;&lt;v:formulas&gt;&lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 1 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum 0 0 @1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @2 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 0 1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @6 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @8 21600 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @10 21600 0"&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;&lt;v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"&gt;&lt;/v:path&gt;&lt;o:lock aspectratio="t" v:ext="edit"&gt;&lt;img height="190" alt="LookDirection-1" src="http://viewport3d.com/Blog_files/LookDirection_2D1.png" width="190" border="0" /&gt;&lt;/o:lock&gt;&lt;/v:shapetype&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #ece9d8; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" valign="top" width="295"&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: center" align="center"&gt;&lt;img height="190" alt="LookDirection-2" src="http://viewport3d.com/Blog_files/LookDirection_2D2.png" width="190" border="0" /&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 1; mso-yfti-lastrow: yes"&gt;
&lt;td style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #ece9d8; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" valign="top" width="295"&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Figure 1a&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;When the camera&amp;rsquo;s position moves from point A to point B it is automatically re-orientated so that the LookAtPoint remains centered in its view.&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #ece9d8; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" valign="top" width="295"&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Figure 1b&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;When the camera&amp;rsquo;s position moves from point A to point B it continues to face in the direction specified by the LookDirection.&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;In terms of the camera configurations that can be represented the two properties are equally expressive.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;It is easy to convert between the two using the following equation:&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: center; mso-outline-level: 1" align="center"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;LookDirection = LookAtPoint - Position&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: center" align="center"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;However, there are some pragmatic advantages to choosing LookDirection.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;One is that LookDirection is similar to other properties in the system (e.g., SpotLight.Direction.)&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Another is that LookAtPoint leads to a common misunderstanding that the camera can be rotated by simply updating the camera&amp;rsquo;s position.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Unless you also transform the UpDirection this will lead to (usually) unexpected flipping behavior at the poles.&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;It was the addition of Camera.Transform, however, that&amp;nbsp;was the largest motivation to&amp;nbsp;switch to LookDirection.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Being able to apply Transform3Ds to Cameras simplifies a lot of animation scenarios.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;In fact, it&amp;rsquo;s currently the only way to animate a MatrixCamera.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Also, the ability to share Transform3Ds between Cameras and nodes in the Visual tree enables scenarios where the Camera follows an object in the scene.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;(Incidentally, this is how the headlight feature of the &lt;a href="http://blogs.msdn.com/danlehen/archive/2005/12/20/506058.aspx"&gt;ModelViewer sample&lt;/a&gt; works.)&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;The addition of Camera.Transform raised questions about LookAtPoint.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Should LookAtPoint be affected by the transform or should it continue to be defined in world space?&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;If LookAtPoint is in world space, as most people initially suppose, it breaks the illusion that the camera is a physical object in the scene because rotating the camera 180 degrees does not necessarily mean that the camera is looking in the opposite direction since it will continue to look in the direction of the same fixed point in world space.&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;On the other hand, if the camera&amp;rsquo;s transform LookAtPoint is affected by the transform then users need to convert into the camera&amp;rsquo;s coordinate system to specify the LookAtPoint.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;This is no less difficult than calculating the LookDirection and more error prone.&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;When all these things were considered: the difficulty in reconciling LookAtPoint with Camera.Transform, the fact that the perceived simplicity of LookAtPoint is negated by the need to handle the UpDirection, and that elsewhere in the system we have consistently specified orientation with direction vectors, we decided that in the long term our customers will be happier with LookDirection.&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=509092" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry><entry><title>3D Tools Workspace updated to December CTP bits</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2005/12/20/506058.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2005/12/20/506058.aspx</id><published>2005-12-20T19:58:00Z</published><updated>2005-12-20T19:58:00Z</updated><content type="html">&lt;P&gt;I've packaged &lt;A href="http://www.gotdotnet.com/workspaces/releases/viewuploads.aspx?id=2ce2a6b8-2085-4839-a001-1c539525f5fa"&gt;a new release&lt;/A&gt; of the &lt;A href="http://workspaces.gotdotnet.com/3dtools"&gt;3D Tools workspace&lt;/A&gt; targeting the December CTP WinFX bits.&amp;nbsp; This release&amp;nbsp;adds&amp;nbsp;two&amp;nbsp;requested features&amp;nbsp;to the ModelViewer sample.&amp;nbsp;&amp;nbsp;The first is the ability to light the scene.&amp;nbsp; This is&amp;nbsp;convenient&amp;nbsp;if you are viewing a model which does not contain lights.&amp;nbsp; There are two options for lighting:&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp; Headlight&amp;nbsp;– This will add a white directional light which follows the viewing direction of the camera (imagine a flashlight duct-taped to the front of your camera.)&amp;nbsp; The headlight is now on by default.&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; Ambient Light – This will add a white ambient light which will fully illuminate the scene.&amp;nbsp; The lack of depth cues this causes will make the scene appear “flat”, but this mode can be useful for examining a model for correctness.&amp;nbsp; The ambient light is off by default.&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;IMG height=114 alt=MV-None src="http://viewport3d.com/Blog_files/MV_2DNone_small.jpg" width=200 border=0&gt; 
&lt;TD&gt;&lt;IMG height=114 alt=MV-Headlight src="http://viewport3d.com/Blog_files/MV_2DHeadlight_small.jpg" width=200 border=0&gt; 
&lt;TD&gt;&lt;IMG height=114 alt=MV-Ambient src="http://viewport3d.com/Blog_files/MV_2DAmbient_small.jpg" width=200 border=0&gt; &lt;/TD&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;EM&gt;No lights&lt;/EM&gt; 
&lt;TD&gt;&lt;EM&gt;Headlight&lt;/EM&gt; 
&lt;TD&gt;&lt;EM&gt;Ambient Light&lt;/EM&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;Changing the lighting options in the ModelViewer does not change the model (i.e., it is non-destructive.)&lt;/P&gt;
&lt;P&gt;The other new feature is the ability to reload the currently open file to view any changes since the file was last opened.&amp;nbsp; Both new features are available via the View menu.&lt;/P&gt;
&lt;P&gt;The release contains both binary and sources.&amp;nbsp; To run the ModelViewer, you need &lt;A href="http://msdn.microsoft.com/netframework/downloads/updates/default.aspx"&gt;.NET Framework 2.0 Redist&lt;/A&gt; and the &lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=BD3BA2D5-6ADB-4FB2-A3AA-E16A9EA5603F&amp;amp;displaylang=en"&gt;December CTP WinFX Runtime&lt;/A&gt;.&amp;nbsp; To build the solution you also need the &lt;a href="http://blogs.msdn.com/danlehen/archive/2005/12/19/505647.aspx"&gt;Windows SDK and optionally VS 2005 and the VS Extensions for WinFX&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=506058" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry><entry><title>Rotating the Camera with the Mouse</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2005/12/15/504548.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2005/12/15/504548.aspx</id><published>2005-12-16T05:29:00Z</published><updated>2005-12-16T05:29:00Z</updated><content type="html">&lt;P&gt;Possibly the most common 3D UI paradigm is to rotate an object with the mouse in order to view it from all angles.&amp;nbsp; This is illustrated by the images of the tiger model below:&amp;nbsp; &lt;/P&gt;
&lt;P&gt;
&lt;TABLE class=MsoTableGrid style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #ece9d8; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" width=295&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: center" align=center&gt;&lt;IMG height=216 src="http://viewport3d.com/Trackball_files/image001.gif" width=289&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #ece9d8; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" width=295&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: center" align=center&gt;&lt;IMG height=214 src="http://viewport3d.com/Trackball_files/image002.gif" width=287&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #ece9d8; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=295&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B&gt;Figure 1a&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;I&gt;Tiger model in its original configuration&lt;/I&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #ece9d8; WIDTH: 221.4pt; PADDING-TOP: 0in; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=295&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B&gt;Figure 1b&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;I&gt;Tiger model after the mouse has been dragged to the left and slightly down.&lt;/I&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;This UI technique is known as a "virtual trackball" and it has been a staple of interactive computer graphics since the 80s.&amp;nbsp; It has applications ranging from CAD to department store kiosks to gaming.&lt;/P&gt;
&lt;P&gt;To help developers working with the Windows Presentation Foundation get a jump-start using 3D in their&amp;nbsp;applications I have added a sample trackball implementation to the &lt;A href="http://workspaces.gotdotnet.com/3DTools"&gt;3DTools workspace&lt;/A&gt; with an &lt;A href="http://viewport3d.com/trackball.htm"&gt;accompanying article&lt;/A&gt; which discusses the mechanics of how a trackball works.&lt;/P&gt;
&lt;P&gt;Reading&amp;nbsp;the full article is not required to successfully use the sample code in your own applications, but skimming it might be useful.&amp;nbsp; You do not&amp;nbsp;need to be a member of the workspace in order to download releases which include both binaries and source (&lt;A href="http://www.gotdotnet.com/workspaces/releases/viewuploads.aspx?id=2ce2a6b8-2085-4839-a001-1c539525f5fa"&gt;here&lt;/A&gt;).&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=504548" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry><entry><title>WinFX November CTP Released!</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2005/11/30/498505.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2005/11/30/498505.aspx</id><published>2005-11-30T18:54:00Z</published><updated>2005-11-30T18:54:00Z</updated><content type="html">&lt;P&gt;If you are like me and have been &lt;a href="http://blogs.msdn.com/danlehen/archive/2005/11/10/491407.aspx"&gt;holding off&lt;/A&gt; on installing the final version of the .NET Framework 2.0 and Visual Studio 2005 until you had Windows Presentation Foundation (formerly code-named Avalon) bits to work with then the wait is over.&amp;nbsp; The November CTP of the WPF works with the final .NET/VS bits.&lt;/P&gt;
&lt;P&gt;&lt;a href="http://blogs.msdn.com/tims/default.aspx"&gt;Tim Sneath&lt;/A&gt; posted &lt;a href="http://blogs.msdn.com/tims/archive/2005/11/18/494526.aspx"&gt;links to the downloads&lt;/A&gt;.&lt;BR&gt;&lt;a href="http://blogs.msdn.com/karstenj"&gt;Karsten Januszewski&lt;/A&gt; has&amp;nbsp;&lt;a href="http://blogs.msdn.com/karstenj/archive/2005/11/18/494551.aspx"&gt;a summary changes&lt;/A&gt;&amp;nbsp;in this release.&lt;/P&gt;
&lt;P&gt;Not having to reinstall VS for each WinFX release&amp;nbsp;should make it a&amp;nbsp;lot easier to keep up with future CTPs.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=498505" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry><entry><title>3D for the Rest of Us: Texture Coordinates</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2005/11/06/489627.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2005/11/06/489627.aspx</id><published>2005-11-06T23:05:00Z</published><updated>2005-11-06T23:05:00Z</updated><content type="html">&lt;P&gt;&lt;STRONG&gt;Introduction&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;People new to 3D are frequently confused by the extra level of indirection introduced by texture coordinates.&amp;nbsp; 3D veterans familiar with texture coordinates from other platforms are sometimes surprised&amp;nbsp;that the default behavior in the Windows Presentation Foundation (formerly code-named Avalon) is a bit different than what they are accustomed to in other 3D APIs.&amp;nbsp; Below is a quick overview of what texture coordinates are and how they are specified.&amp;nbsp; The last section talks about the default behavior in the WPF and how the tradition behavior can be attained by tweaking Brush properties.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What are Texture Coordinates?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Texture coordinates specify which part of the Material shows up&amp;nbsp;an which part of the&amp;nbsp;&lt;A href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/T_System_Windows_Media_Media3D_MeshGeometry3D.asp"&gt;MeshGeometry3D&lt;/A&gt;.&amp;nbsp; Developers from a 2D background are&amp;nbsp;usually surprised that this is necessary.&amp;nbsp; Most 2D graphics APIs give the users drawing primitives like Ellipses, Rectangles,&amp;nbsp;Paths, etc.&amp;nbsp;with a predefined fill behavior that stretches the brush to the bounds of the given geometry.&amp;nbsp; This is the default in WPF as well.&amp;nbsp; Consider the&amp;nbsp;following diagonal GradientBrush which is white in the upper left corner, red in the middle, and black in the lower right corner:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&amp;lt;&lt;FONT color=#800000 size=2&gt;LinearGradientBrush&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;x:Key&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;MyGrad&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;StartPoint&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;0,0&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;EndPoint&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;1,1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;LinearGradientBrush.GradientStops&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;GradientStopCollection&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;GradientStop&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Color&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;#FFFFFF&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Offset&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;0&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;GradientStop&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Color&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;#FF0000&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Offset&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;0.5&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;GradientStop&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Color&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;#000000&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Offset&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;GradientStopCollection&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;LinearGradientBrush.GradientStops&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;LinearGradientBrush&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;By default when a brush is used to fill a 2D geometry the brush is applied relative to the bounding box of the shape.&amp;nbsp; If applied to a Rectangle like the 100x100 square below the entire brush will be visible.&amp;nbsp; If the geometry does not entirely fill it’s bounding box parts of the brush will not be visible.&amp;nbsp; For example, the non-rectangular parallelogram below does not show the extreme white and black corners of the brush.&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;IMG height=204 alt=TextureCoord hspace=0 src="http://blargh.com/~danlehen/TextureCoord.jpg" width=607 border=0&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;People working with 3D for the first time often expect that materials will be similarly stretched to fit the shape of their geometry.&amp;nbsp; Indeed, in my &lt;a href="http://blogs.msdn.com/danlehen/archive/2005/10/16/481597.aspx"&gt;last post&lt;/A&gt; my sample 3D primitives have default texture coordinates which mimic this behavior:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;IMG alt="" src="http://blargh.com/~danlehen/Visual3DSample.jpg" border=0&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;However, there is no single mapping which provides a reasonable default for all 3D geometry.&amp;nbsp; Even with simple geometry like the 3 quadrics depicted above the method for generating the texture coordinates of the sphere differ from that of the cone and cylinder.&amp;nbsp; In order to make the material wrap sensibly around each primitive I had to&amp;nbsp;explicitly specify&amp;nbsp;a 2D texture coordinate for each 3D position.&amp;nbsp; For example, the cone primitive generates a mesh similar to the one depicted below.&amp;nbsp;&amp;nbsp;Each 3D position in the mesh has a corresponding 2D texture coordinate which&amp;nbsp;maps that 3D position to a 2D coordinate in the material.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;IMG height=306 alt=TextureCoord-2 hspace=0 src="http://blargh.com/~danlehen/TextureCoord-2.jpg" width=756 border=0&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Specifying Texture Coordinates&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;You specify texture coordinates by adding 2D Points to the MeshGeometry3D.TextureCoordinates collection.&amp;nbsp; For example, the following MeshGeometry3D maps the lower right half portion of the material to a triangle:&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;MeshGeometry3D&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Positions&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;-1,1,0 -1,-1,0 1,-1,0&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;TextureCoordinates&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;0,0 0,1 1,1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;TriangleIndices&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;0,1,2&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/FONT&gt;
&lt;P&gt;The &lt;EM&gt;i&lt;/EM&gt;th entry in the TextureCoordinates list corresponds to the &lt;EM&gt;i&lt;/EM&gt;th entry in the Positions list, so texture coordinate 0,0 is associated with the vertex at position -1,1,0.&amp;nbsp; The mapping between texture coordinates and positions is depicted below:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Texture Coordinates&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rendered Triangle&lt;BR&gt;&lt;/STRONG&gt;&lt;IMG height=274 alt=TextureCoord-3 hspace=0 src="http://blargh.com/~danlehen/TextureCoord-3.jpg" width=596 border=0&gt;&lt;/P&gt;
&lt;P&gt;Of course, this is not the only possibly mapping.&amp;nbsp; If we change the 2nd texture coordinate from 0,1 to 0,0.5 we produce the following image:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Texture Coordinates&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Rendered Triangle&lt;BR&gt;&lt;/STRONG&gt;&lt;IMG height=271 alt=TextureCoord-4 hspace=0 src="http://blargh.com/~danlehen/TextureCoord-4.jpg" width=600 border=0&gt;&lt;/P&gt;
&lt;P&gt;Notice that the area of the triangle specified by the texture coordinates on the left is stretched to fit the render triangle.&lt;/P&gt;
&lt;P&gt;Texture coordinates are required when using a material with an ImageBrush, DrawingBrush, VisualBrush, LinearGradientBrush,&amp;nbsp;or RadialGradientBrush (i.e., any Brush other than a SolidColorBrush in which case every position in the mesh maps to the same color.)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Texture Coordinates in the Windows Presentation Foundation&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;There are a couple of behavior differences that 3D veterans should be aware of when working with texture coordinates in the Windows Presentation Foundation.&amp;nbsp; These differences arise from the fact that 3D Materials leverage 2D Brushes as the source of their textures.&amp;nbsp; The wins from being able to take any arbitrary 2D brush and use it to paint a 3D mesh are enormous.&amp;nbsp; However brushes default to behavior which, while traditional for 2D, is sometimes surprising for 3D developers.&amp;nbsp; Fortunately brushes are highly configurable and it is easy to get the typical&amp;nbsp;3D behavior.&lt;/P&gt;
&lt;P&gt;The first difference is that the +Y axis in brush space (and consequently texture coordinate space)&amp;nbsp;points down by default.&amp;nbsp; This is consistent with 2D but different from the traditional 3D coordinate system where the +Y axis points up.&amp;nbsp; In order to get the +Y axis pointing up apply a Y scale of -1 and Y translation of +1:&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;ImageBrush&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Transform&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;scale(1,-1) translate(0,1)&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;ImageSource&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;…&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The second difference is that the brushes default to relative units.&amp;nbsp; At the beginning of this article I discussed how by default the brush maps to the relative bounding box of the 2D geometry it is being used to fill.&amp;nbsp; The same thing happens by default with the bounding box of your texture coordinates.&amp;nbsp; In the above samples I happened to use texture coordinates in the range of 0..1, but texture coordinates&amp;nbsp;of “-20,-20 -20,10 10,10” would have also filled the triangle with the same part of the image.&amp;nbsp; TileBrush’s Viewport property defaults to the rect (0,0)-(1,1) so to get the standard behavior where the bounds of the texture source maps to 0..1 you just need to&amp;nbsp;specify you are using&amp;nbsp;absolute units:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&amp;lt;&lt;FONT color=#800000 size=2&gt;ImageBrush&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;FONT color=#ff0000 size=2&gt;ViewportUnits&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Absolute&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;" &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Transform&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;scale(1,-1) translate(0,1)&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;ImageSource&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;…&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P dir=ltr&gt;These 2 settings should configure brush / texture space to be identical to what you are probably used to from other APIs.&amp;nbsp; (Incidently, all of these Brush settings have the same&amp;nbsp;affect in 2D as well.)&amp;nbsp; Finally, if you need tiling&amp;nbsp;you turn it on with&amp;nbsp;TileMode=”Tile”.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=489627" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry><entry><title>Extending Visual3D - Sphere, Cone, and Cylinder</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2005/10/16/481597.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2005/10/16/481597.aspx</id><published>2005-10-16T17:38:00Z</published><updated>2005-10-16T17:38:00Z</updated><content type="html">&lt;P&gt;&lt;STRONG&gt;Update: &lt;/STRONG&gt;The source has been updated for the &lt;A HREF="/danlehen/archive/2005/12/19/505647.aspx"&gt;December&lt;/A&gt; or &lt;A HREF="/danlehen/archive/2006/01/18/514574.aspx"&gt;January CTP&lt;/A&gt; (either will work).&lt;/P&gt;
&lt;P&gt;In my&amp;nbsp;&lt;A HREF="/danlehen/archive/2005/10/09/478923.aspx"&gt;previous post&lt;/A&gt; I mentioned that one of the motivations for Visual3D was sub-classing.&amp;nbsp; Prior to the September CTP of the Windows Presentation Foundation (formerly code-named Avalon) there was no extensibility point for creating your own 3D scene nodes.&amp;nbsp; One of the many possible uses for this new extensibility point is to build a library of 3D primitives.&amp;nbsp; I put together a short sample which derives a Sphere, a Cone, and a Cylinder primitive from ModelVisual3D.&amp;nbsp; (Source available &lt;A href="http://viewport3d.com/blog_files/Visual3DSample.zip"&gt;here&lt;/A&gt;.)&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blargh.com/~danlehen/Visual3DSample.jpg"&gt;&lt;/P&gt;
&lt;P&gt;You will notice that these primitives are directly usable from Xaml:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&amp;lt;&lt;FONT color=#800000&gt;Viewport3D Camera=”{Camera}” &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp; &amp;lt;&lt;FONT color=#800000&gt;my:Sphere3D Transform=”{XForm1}” Material=”{Azul}” /&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;my:Cone3D Transform=”{XForm2}” Material=”{Tulips}” /&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;my:Cylinder3D Transform=”{XForm3}” Material=”{Autumn}” /&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;Viewport3D&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The&amp;nbsp;primitives are centered at the origin and have a natural size of Radius=1 and Height=2 (i.e., they&amp;nbsp;are bounded by&amp;nbsp;(-1,-1,-1) – (1,1,1)).&lt;/P&gt;
&lt;P&gt;This sample does not constitute a terribly complete or expressive library of 3D primitives, but it does illustrate how one could be built.&amp;nbsp; More compelling examples&amp;nbsp;include deriving from Visual3Ds to add new events and behavior (like collision detection) or surfacing properties like databindable properties which dynamically generate 3D charts and graphs.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=481597" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry><entry><title>ModelVisual3D vs. Model3DGroup -- When to use which?</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2005/10/09/478923.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2005/10/09/478923.aspx</id><published>2005-10-09T22:44:00Z</published><updated>2005-10-09T22:44:00Z</updated><content type="html">&lt;P&gt;(&lt;STRONG&gt;NOTE:&lt;/STRONG&gt; You might find &lt;a href="http://blogs.msdn.com/karstenj/archive/2005/10/11/479924.aspx"&gt;Karsten's pragmatic perspective&lt;/A&gt;&amp;nbsp;a useful prelude&amp;nbsp;before we dive into the artictural underpinnings.)&lt;/P&gt;
&lt;P&gt;In the&amp;nbsp;September CTP release of the Windows Presentation Foundation (formerly code-named Avalon) we made 3D a first class citizen in the Visual tree with the introducion of&amp;nbsp;Visual3D.&amp;nbsp; Up until this point 3D existed solely as content attached to a 2D Visual .&amp;nbsp; 3D users migrating to the September CTP&amp;nbsp;will encounter the Visual/Content split for the first time.&amp;nbsp; This has lead to some confusion about when&amp;nbsp;nested ModelVisual3Ds should be used to group models together vs. a Model3DGroup.&amp;nbsp; Below is a short description of Visuals and Content and how they fit together.&amp;nbsp; At the end is a concrete example&amp;nbsp;with guidelines on&amp;nbsp;when to use a ModelVisual3D vs. a Model3DGroup.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What is a Visual?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;A &lt;A href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/T_System_Windows_Media_Visual.asp?frame=true"&gt;Visual&lt;/A&gt; (or Visual3D) is a low-level node in the composition tree.&amp;nbsp; For people coming from a Win32 background a Visual is frequently compared to an HWND:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;A Visual has a graphical representation. 
&lt;LI&gt;A Visual keeps track of its dirty regions. 
&lt;LI&gt;If dirty, a Visual automatically re-renders each frame. 
&lt;LI&gt;Visuals can be composed into trees. 
&lt;LI&gt;A Visual can only be parented once.&amp;nbsp; (i.e., you can not share/reuse Visuals) 
&lt;LI&gt;Visuals can be positioned relative to their parent via a Transform. 
&lt;LI&gt;You can hit test a Visual.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;There are however some notable differences between Visuals and HWNDs.&amp;nbsp; Probably the most notable is that WPF is a retained graphics architecture.&amp;nbsp; Visuals do not call back to user code to repaint when invalidated.&amp;nbsp; Instead you specify a Visual’s content (i.e., a description of what it should render).&amp;nbsp; If the Visual is dirtied for any reason it automatically repaints the dirty portion from the content specification on the next frame.&amp;nbsp; A sample Visual tree is pictured below:&lt;/P&gt;
&lt;P&gt;&lt;IMG alt=VisualTree[1] src="http://blargh.com/~danlehen/VisualTree.png" border=0&gt;&lt;/P&gt;
&lt;P&gt;Most anything that renders in the WPF derives from&amp;nbsp;Visual.&amp;nbsp; For example,&amp;nbsp;&lt;A href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/T_System_Windows_Controls_Control.asp"&gt;Control&lt;/A&gt;s derive from &lt;A href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/T_System_Windows_FrameworkElement.asp"&gt;FrameworkElement&lt;/A&gt; which derives from &lt;A href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/T_System_Windows_UIElement.asp"&gt;UIElement&lt;/A&gt; which derives from Visual.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What is Content?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Content is a description of what a Visual should render.&amp;nbsp; There are a few different APIs for specifying 2D content.&amp;nbsp; Currently in 3D the only way to specify content is via a graph of Model3Ds attached to a ModelVisual3D.&amp;nbsp; Like Visuals, you can build graphs of content using DrawingGroup (2D) or Model3DGroup (3D).&amp;nbsp; You can also position content via a Transform.&amp;nbsp; However, despite these superficial similarities there are important differences between Visuals and content:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Visuals are optimized to be scene nodes.&amp;nbsp; Content are serialized rendering instructions for scene nodes. 
&lt;LI&gt;Visuals are the base class for Shapes and Controls.&amp;nbsp; Content classes are sealed. 
&lt;LI&gt;Visuals are single-use.&amp;nbsp; Content can be shared/reused between Visuals. 
&lt;LI&gt;Visuals support services like hit testing.&amp;nbsp; Content are serialized rendering instructions and&amp;nbsp;nothing else.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Where Do Visuals End and Content Begin?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The distinction between Visuals and content is usually clear.&amp;nbsp; The one area which&amp;nbsp;can be a bit subjective&amp;nbsp;is whether a set of drawing primitives should be grouped together in content or by a tree of Visuals.&amp;nbsp; To give a concrete example, lets say you have a spaceship mesh that you need to appear three places on screen.&amp;nbsp; Should you use a single Visual that renders 3 spaceships?&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blargh.com/~danlehen/Content1.png"&gt; &lt;/P&gt;
&lt;P&gt;Or 3 Visuals which render one spaceship each?&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blargh.com/~danlehen/Content2.png"&gt;&lt;/P&gt;
&lt;P&gt;The answer depends.&amp;nbsp; If&amp;nbsp;a cluster of&amp;nbsp;3 spaceships are&amp;nbsp;flying together in tight formation&amp;nbsp;then treating them as a single&amp;nbsp;model may be reasonable, especially if you want several of these clusters cruising around the screen.&amp;nbsp; Or if you have a piece of clip-art featuring three tiny animated spaceships dog fighting around the 3D logo of your&amp;nbsp;BSG fan site you might want to treat the clip-art, spaceships and all, as a single piece of content.&lt;/P&gt;
&lt;P&gt;More typically you will want to each spaceship to be a separate node in the Visual tree.&amp;nbsp; Although you could use DrawingGroup and Model3DGroup to compose everything in your scene (assuming you do not need any Visual services like hit testing), this was not really&amp;nbsp;the intent of DrawingGroup and Model3DGroup.&amp;nbsp; The purpose of DrawingGroup and Model3DGroup is to group together the pieces of a single shareable/reusable drawing or model.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=478923" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry><entry><title>Mantis 3D Space Shooter</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2005/10/03/476733.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2005/10/03/476733.aspx</id><published>2005-10-04T05:36:00Z</published><updated>2005-10-04T05:36:00Z</updated><content type="html">&lt;P&gt;
&lt;DIV class=Section1&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;When we decided to integrate 3D into the Windows Presentation Foundation (Avalon) the scenarios we were targeting for v1 were:&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;UL style="MARGIN-TOP: 0in" type=disc&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;3D effects, like a “Next Page” transition that looks like the turning of a page in a book&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt; 
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Data visualization (charts, graphs, etc.)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt; 
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Catalogs where you can rotate items in 3D&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt; 
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;3D icons and vector graphics styled on to 2D controls (Buttons, ListViewItems, etc.)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt; 
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;A mall kiosk which shows an interactive floor plan in 3D&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;…and related scenarios which add a bit of sizzle to traditional applications excluding games.&amp;nbsp; However, while gaming was not a targeted scenario for v1 there is some coincidental overlap which makes WPF a decent option for certain types of games.&amp;nbsp; (Mostly games where you are clicking with the mouse instead of madly staffing. :)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;One example is &lt;a href="http://blogs.msdn.com/mitchw/archive/2005/09/13/465200.aspx"&gt;Mantis&lt;/A&gt;, a polished looking 3D space shooter that &lt;a href="http://blogs.msdn.com/mitchw"&gt;Mitch Walker&lt;/A&gt; has been building using the Windows Presentation Foundation (Avalon) and Windows Communication Foundation (Indigo).&amp;nbsp; Follow the links to his blog for a description of the project, future directions, and a video snippet of actual game play.&amp;nbsp; Here are a couple of screenshots from Mitch’s blog to entice you:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE class=MsoTableGrid style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; WIDTH: 221.4pt; PADDING-TOP: 0in" vAlign=top width=295&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;&lt;A href="http://www.mitchw.net/mantis/menu_large.png"&gt;&lt;SPAN style="TEXT-DECORATION: none"&gt;&lt;IMG id=_x0000_i1028 height=180 src="http://www.mitchw.net/mantis/menu_thumb.png" width=240 border=0&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; WIDTH: 221.4pt; PADDING-TOP: 0in" vAlign=top width=295&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;&lt;A href="http://www.mitchw.net/mantis/game_large.png"&gt;&lt;SPAN style="TEXT-DECORATION: none"&gt;&lt;IMG id=_x0000_i1030 height=180 src="http://www.mitchw.net/mantis/game_thumb.png" width=240 border=0&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P class=MsoNormal&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=476733" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry><entry><title>Minor Boing Update for Channel 9 Interview...</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2005/01/04/346731.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2005/01/04/346731.aspx</id><published>2005-01-05T03:10:00Z</published><updated>2005-01-05T03:10:00Z</updated><content type="html">&lt;p&gt;I have discovered&amp;nbsp;an effective way to make sure you follow up on your promises: arrange to have them &lt;a href="http://channel9.msdn.com/ShowPost.aspx?PostID=34528#34528"&gt;captured on video&lt;/a&gt;.&amp;nbsp; I&amp;nbsp;had not&amp;nbsp;been&amp;nbsp;able to find the&amp;nbsp;15 minutes to try&amp;nbsp;&lt;a href="http://www.longhornblogs.com/rrelyea/"&gt;Rob&amp;rsquo;s&lt;/a&gt; suggestion for inserting a&amp;nbsp;resource into a collection&amp;nbsp;&lt;a href="http://blogs.msdn.com/danlehen/archive/2004/11/23/268252.aspx"&gt;since November&lt;/a&gt;, but somehow tonight was different.&amp;nbsp; I actually heard from the community before I received the internal email notifying me that the segment had been posted.&amp;nbsp; :)&lt;/p&gt;&lt;p&gt;Here is the &lt;a href="http://blargh.com/~danlehen/Boing-NoCode.zip"&gt;updated source&lt;/a&gt; which no longer uses the WindowsLoaded event.&amp;nbsp; It&amp;rsquo;s now 100% Xaml.&amp;nbsp; The trick I was missing was the &lt;font color="#0000ff" size="2"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#800000" size="2"&gt;x:Include&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; &lt;/font&gt;&lt;font color="#ff0000" size="2"&gt;x:Content&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;=&lt;/font&gt;&lt;font size="2"&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;{ball}&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; /&amp;gt;&lt;/font&gt;&amp;nbsp;which is a Xaml element that evaluates to a reference to the resource named &amp;ldquo;ball&amp;rdquo;.&amp;nbsp; This allows me to take the same&amp;nbsp;animated bouncing ball model and insert it into two Viewport3Ds to efficiently create the mirroring effect in Xaml which I was previously falling back to C# in the code-behind to do.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=346731" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry><entry><title>Bouncing Back...</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/danlehen/archive/2004/11/23/268252.aspx" /><id>http://blogs.msdn.com/danlehen/archive/2004/11/23/268252.aspx</id><published>2004-11-23T05:39:00Z</published><updated>2004-11-23T05:39:00Z</updated><content type="html">&lt;div class="Section1"&gt; &lt;p&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;span style="FONT-SIZE: 12pt"&gt;Trying to ease back into the community after a short hiatus, I ported the &lt;span class="SpellE"&gt;Boing&lt;/span&gt; demo that &lt;A href="http://blogs.msdn.com/danlehen/archive/2004/06/01/146259.aspx"&gt;I &lt;span class="SpellE"&gt;blogged&lt;/span&gt; about back in June&lt;/a&gt;&amp;nbsp;to the &lt;A href="http://blogs.msdn.com/danlehen/archive/2004/11/21/267581.aspx"&gt;Avalon CTP build&lt;/a&gt;.&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;span style="FONT-SIZE: 12pt"&gt;You can get the updated &lt;a href="http://blargh.com/~danlehen/Boing-CTP.zip"&gt;source here&lt;/a&gt;.&amp;nbsp; Just load the solution in to the VS.NET Whidbey Beta and press F5.&amp;nbsp; If you are using &lt;a href="http://lab.msdn.microsoft.com/express/vcsharp/default.aspx"&gt;Visual C# Express&lt;/a&gt;, see RRelyea's notes (&lt;a href="http://www.simplegeek.com/PermaLink.aspx/99113e3e-6d68-4595-ba1a-2b89206a15a9"&gt;via ChrisAn&lt;/a&gt;).&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;span style="FONT-SIZE: 12pt"&gt;You will probably notice that the demo hasn't changed much since WinHEC:&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;/div&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;&lt;img src="http://blargh.com/~danlehen/Boing.PNG" width="320" /&gt;&lt;/td&gt; &lt;td&gt;&lt;img src="http://blargh.com/~danlehen/Boing-CTP.PNG" width="320" /&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;But there &lt;em&gt;are&lt;/em&gt; some&amp;nbsp;differences (mostly in the code):&lt;/p&gt; &lt;ul&gt; &lt;li&gt;It's running on Windows XP (note the Luna theme with blue color scheme - &lt;a href="http://www.msdn.net/Longhorn/understanding/pillars/avalon/avnov04ctp/default.aspx#intro_avalon_ctp_topic5"&gt;blue is very important&lt;/a&gt;!) &lt;li&gt;The source comes in the form of a VS.NET solution. &lt;li&gt;Window1.xaml's code behind is almost empty: &lt;ul&gt; &lt;li&gt;The ball is now animated entirely using the platform animation features instead of a Timer. &lt;li&gt;The ball's geometry is shared via &amp;lt;Application.Resources&amp;gt; in MyApp.xaml instead of being parsed from a string at runtime.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;If you want to have some fun with the animation, try moving the animated RotateTransform3D to the end of the Transform3DCollection to get an effect that looks less like physics and more like poltergeist activity:&lt;/p&gt; &lt;p&gt;&lt;img src="http://blargh.com/~danlehen/Poltergeist.PNG" /&gt;&lt;/p&gt; &lt;p&gt;(If you're not sure what is going on, &lt;A href="http://blogs.msdn.com/danlehen/archive/2004/08/08/210961.aspx"&gt;this might help&lt;/a&gt;.)&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=268252" width="1" height="1"&gt;</content><author><name>danlehen</name><uri>http://blogs.msdn.com/members/danlehen.aspx</uri></author></entry></feed>