<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>IRhetoric - Karsten Januszewski   : 3D</title><link>http://blogs.msdn.com/karstenj/archive/tags/3D/default.aspx</link><description>Tags: 3D</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>New Lab Posted: Creating 3D Content with Windows Presentation Foundation</title><link>http://blogs.msdn.com/karstenj/archive/2007/03/28/new-lab-posted-creating-3d-content-with-windows-presentation-foundation.aspx</link><pubDate>Wed, 28 Mar 2007 23:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1980187</guid><dc:creator>karstenj</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1980187.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1980187</wfw:commentRss><description>&lt;P&gt;I just posted a &lt;A class="" href="http://wpf.netfx3.com/files/folders/labs/entry9680.aspx" mce_href="http://wpf.netfx3.com/files/folders/labs/entry9680.aspx"&gt;new lab for learning how to use 3D&lt;/A&gt; in WPF.&amp;nbsp; This is a great lab that I would highly recommend if you are learning WPF 3D. It shows how to do dynamic animation of 3D content as well as how to do 2D on 3D using the &lt;A class="" href="http://www.codeplex.com/3DTools" mce_href="http://www.codeplex.com/3DTools"&gt;3DTools&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH: 425px; HEIGHT: 419px" height=419 src="http://inlinethumb49.webshots.com/4592/2918638560100818464S425x425Q85.jpg" width=425 mce_src="http://inlinethumb49.webshots.com/4592/2918638560100818464S425x425Q85.jpg"&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1980187" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category></item><item><title>3D Cloth Source Code Posted: Technique for WPF 3D Morph Mesh</title><link>http://blogs.msdn.com/karstenj/archive/2007/02/26/3d-cloth-source-code-posted-technique-for-wpf-3d-morph-mesh.aspx</link><pubDate>Mon, 26 Feb 2007 22:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1765227</guid><dc:creator>karstenj</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1765227.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1765227</wfw:commentRss><description>&lt;P&gt;There is a great 3D cloth demo that has been floating around interally for awhile and shown at conferences, talks, channel 9 interviews, etc. However, we haven't ever posted the source code . . . until now.&amp;nbsp; You can &lt;A target=_blank href="http://rhizohm.net/download/netfx3/apps/publish.htm" mce_href="http://rhizohm.net/download/netfx3/apps/publish.htm"&gt;run it from here&lt;/A&gt; and download the &lt;A href="http://rhizohm.net/download/netfx3/3dcloth.zip" mce_href="http://rhizohm.net/download/netfx3/3dcloth.zip"&gt;source code here&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;I didn't write this code; David Teitlebaum, from the WPF team,&amp;nbsp;did. He was hesitant to release it as the code&amp;nbsp;isn't factored to his liking, but I convinced him otherwise.&amp;nbsp;&amp;nbsp;His code is interesting to read: &lt;STRONG&gt;Thing3D&lt;/STRONG&gt; is my personal&amp;nbsp;favorite&amp;nbsp;class.&amp;nbsp;It is also worth calling out&amp;nbsp;that he uses no XAML and he also uses&amp;nbsp;a &lt;STRONG&gt;MatrixCamera&lt;/STRONG&gt; instead of&amp;nbsp;the&amp;nbsp;more easy-to-grok&amp;nbsp;&lt;STRONG&gt;PerspectiveCamera&lt;/STRONG&gt; and &lt;STRONG&gt;OrthographicCamera&lt;/STRONG&gt;.&amp;nbsp; And&amp;nbsp;the technique he uses for morphing the mesh is to swap out vertices on the fly using a timer, again not for the feint of heart. But, if you already know 3D paradigms and are wondering how to create stunning effects like this in WPF, this source code will be illuminating for you.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;If you can't run the application because you either aren't on Vista or haven't installed .NET 3.0 on XP, here are some pics to give you a sense of the effect as the cloth, which is really just a 20 x 20 vertice plane, drops onto a sphere, bounces and slides onto a cube:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG style="WIDTH: 855px; HEIGHT: 737px" src="http://rhizohm.net/download/netfx3/cloth1.png" width=855 height=737 mce_src="http://rhizohm.net/download/netfx3/cloth1.png"&gt;&lt;/P&gt;
&lt;P&gt;You can &lt;A target=_blank href="http://wpf.netfx3.com/direct/3dcloth2/mysecondprogram.application" mce_href="http://wpf.netfx3.com/direct/3dcloth2/mysecondprogram.application"&gt;run it from here&lt;/A&gt; and download the &lt;A href="http://wpf.netfx3.com/files/folders/code_snippets/entry9068.aspx" mce_href="http://wpf.netfx3.com/files/folders/code_snippets/entry9068.aspx"&gt;source code here&lt;/A&gt;. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1765227" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category></item><item><title>Inspired By Flash Math Creativity #2: WPF Planets</title><link>http://blogs.msdn.com/karstenj/archive/2007/02/23/inspired-by-flash-math-creativity-2-wpf-planets.aspx</link><pubDate>Sat, 24 Feb 2007 00:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1749785</guid><dc:creator>karstenj</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1749785.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1749785</wfw:commentRss><description>&lt;P&gt;My next inspiration from the algorithms introduced in &lt;A target=_blank href="http://www.friendsofed.com/fmc/FMCv2/FMC.html" mce_href="http://www.friendsofed.com/fmc/FMCv2/FMC.html"&gt;Flash Math Creativity&lt;/A&gt;&amp;nbsp;was based on the work of &lt;A target=_blank href="http://www.nooflat.nu/" mce_href="http://www.nooflat.nu/"&gt;Jamie MacDonald&lt;/A&gt;. In looking at his work,&amp;nbsp; I quickly realized that I was going to need to brush up on my trigonometry skills. This led me to another great Friend of Ed book, &lt;A target=_blank href="http://www.friendsofed.com/book.html?isbn=1590595181" mce_href="http://www.friendsofed.com/book.html?isbn=1590595181"&gt;Foundation ActionScript Animation: Making Things Move&lt;/A&gt;, which has some great trigonometry for animation explanations.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;You can see the&amp;nbsp;results of my latest experiment &lt;A target=_blank href="http://rhizohm.net/download/netfx3/apps/planets.xbap" mce_href="http://rhizohm.net/download/netfx3/apps/planets.xbap"&gt;here&lt;/A&gt; and the code is &lt;A href="http://rhizohm.net/download/netfx3/planets/planets.zip" mce_href="http://rhizohm.net/download/netfx3/planets/planets.zip"&gt;here&lt;/A&gt;. Just to make sure I was up an running with basic trig, I created a sine wave in 01 as follows:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://wpf.netfx3.com/direct/planets"&gt;&lt;IMG style="MARGIN: 0px 10px 10px" border=0 align=left src="http://rhizohm.net/download/netfx3/p1.jpg"&gt;&lt;/A&gt;double x = 0;&lt;BR&gt;double y = 0;&lt;BR&gt;double angle = 0;&lt;BR&gt;for (int i = 0; i &amp;lt; 500; i++)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x += 1;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = 200 + Math.Sin(angle) * 50;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ellipse el = new Ellipse();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; el.Width = 2;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; el.Height = 2;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; el.Fill = Brushes.Red;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Canvas.SetLeft(el, x);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Canvas.SetTop(el, y);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stage.Children.Add(el);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; angle += .05;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;Nothing fancy here.&amp;nbsp; To make a circle, I changed the x to be x = Math.Cos(angle) * 50.&amp;nbsp; This is the basis for doing circle and ellipse animations.&amp;nbsp; Now, instead of trying to do animations using &lt;STRONG&gt;CompositionTarget.Rendering&lt;/STRONG&gt;, I remembered that the SDK has a great sample called &lt;A target=_blank href="http://msdn2.microsoft.com/en-us/library/ms771715.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms771715.aspx"&gt;CustomAnimations&lt;/A&gt;, in which a CircleAnimation exists already using this formula.&amp;nbsp; Here's the key code where it overrides&amp;nbsp;the &lt;STRONG&gt;GetCurrentValueCore&lt;/STRONG&gt; method to create the circle effect using basic trig:&lt;/P&gt;
&lt;P&gt;protected override double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue, AnimationClock clock)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double returnValue;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double time = clock.CurrentProgress.Value;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // math magic: calculate new coordinates using polar coordinate equations. This requires two &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // animations to be wired up in order to move in a circle, since we don't make any assumptions&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // about what we're animating (e.g. a TranslateTransform). &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (Direction == DirectionEnum.XDirection)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnValue = Math.Cos(2 * Math.PI * time);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnValue = Math.Sin(2 * Math.PI * time);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Need to add the defaultOriginValue so that composition works.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return returnValue * Radius + defaultOriginValue;&lt;BR&gt;}&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;At first, I used this in code to create the effect of these circles circling toward you using BeginAnimation, based on the TowardUs sample in the Flash Math Creativity book (the very first sample):&lt;/P&gt;
&lt;P&gt;&lt;A href="http://wpf.netfx3.com/direct/planets"&gt;&lt;IMG style="MARGIN: 0px 10px 10px" border=0 align=right src="http://rhizohm.net/download/netfx3/p2.jpg"&gt;&lt;/A&gt;CircleAnimation cx = new CircleAnimation();&lt;BR&gt;cx.Duration = new Duration(TimeSpan.FromSeconds(1.5));&lt;BR&gt;cx.Direction = CircleAnimation.DirectionEnum.XDirection;&lt;BR&gt;cx.Radius = 150;&lt;BR&gt;cx.RepeatBehavior = RepeatBehavior.Forever;&lt;/P&gt;
&lt;P&gt;CircleAnimation cy = new CircleAnimation();&lt;BR&gt;cy.Duration = new Duration(TimeSpan.FromSeconds(1.5));&lt;BR&gt;cy.Direction = CircleAnimation.DirectionEnum.YDirection;&lt;BR&gt;cy.Radius = 150;&lt;BR&gt;cy.RepeatBehavior = RepeatBehavior.Forever;&lt;/P&gt;
&lt;P&gt;stage.Children.Add(el);&lt;BR&gt;el.BeginAnimation(Ellipse.OpacityProperty, opacityAnimation);&lt;BR&gt;st.BeginAnimation(ScaleTransform.ScaleXProperty, d);&lt;BR&gt;st.BeginAnimation(ScaleTransform.ScaleYProperty, d);&lt;BR&gt;tt.BeginAnimation(TranslateTransform.XProperty, cx);&lt;BR&gt;tt.BeginAnimation(TranslateTransform.YProperty, cy);&lt;/P&gt;
&lt;P&gt;This resulted in 03.&amp;nbsp; It worked, but the code started getting ugly as far as getting each circle to fire when I wanted it to.&amp;nbsp; I found myself using a timer&amp;nbsp;and wiring up an anonymous delegate.&amp;nbsp;I realized &lt;STRONG&gt;Storyboards&lt;/STRONG&gt; and &lt;STRONG&gt;ParallelTimelines&lt;/STRONG&gt; would serve me much better, which are much easier to wire up in XAML than in code.&amp;nbsp; So,&amp;nbsp; 04 is the same thing, but a XAML solution instead:&lt;/P&gt;
&lt;P&gt;&amp;lt;ParallelTimeline BeginTime="0:0:0"&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;DoubleAnimation&amp;nbsp; Duration="0:0:1.5" To="25" Storyboard.TargetName="ellipse0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"/&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;DoubleAnimation Duration="0:0:1.5"&amp;nbsp; To="25" Storyboard.TargetName="ellipse0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"/&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;DoubleAnimation Duration="0:0:1.5" From="1"&amp;nbsp; To="0" Storyboard.TargetName="ellipse0" Storyboard.TargetProperty="(UIElement.Opacity)"/&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;CustomAnimations:CircleAnimation Duration="0:0:1.5" Radius="150" Direction="YDirection" Storyboard.TargetName="ellipse0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(TranslateTransform.Y)"/&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;CustomAnimations:CircleAnimation Duration="0:0:1.5" Radius="150" Direction="XDirection" Storyboard.TargetName="ellipse0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(TranslateTransform.X)"/&amp;gt;&lt;BR&gt;&amp;lt;/ParallelTimeline&amp;gt;&lt;/P&gt;
&lt;P&gt;By using parallel timelines I could structure my animations and when they fired. &lt;/P&gt;
&lt;P&gt;A nice thing about this CustomAnimation is that it can be applied to 3D animations as well, applied to the &lt;STRONG&gt;TranslateTransform3D&lt;/STRONG&gt; which I did 05, changing the &lt;STRONG&gt;Radius&lt;/STRONG&gt; property to be much smaller to fit the coordinates I was using for my ViewPort.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;A href="http://wpf.netfx3.com/direct/planets"&gt;&lt;IMG style="MARGIN: 0px 10px 10px" border=0 align=left src="http://rhizohm.net/download/netfx3/p3.jpg"&gt;&lt;/A&gt;void towardus3d_Loaded(object sender, RoutedEventArgs e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sphere = new GeometryModel3D(sphereFactory.Mesh, materialGreen);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ModelVisual3D mv3d = myViewPort3D.Children[1] as ModelVisual3D;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mv3d.Content = sphere;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CircleAnimation ca3d_y = new CircleAnimation();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_y.Duration = TimeSpan.FromSeconds(5);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_y.RepeatBehavior = RepeatBehavior.Forever;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_y.Radius = .5;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_y.Direction = CircleAnimation.DirectionEnum.YDirection;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CircleAnimation ca3d_x = new CircleAnimation();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_x.Duration = TimeSpan.FromSeconds(5);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_x.RepeatBehavior = RepeatBehavior.Forever;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_x.Radius = .5;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca3d_x.Direction = CircleAnimation.DirectionEnum.XDirection;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ModelTranslate.BeginAnimation(TranslateTransform3D.OffsetYProperty, ca3d_y);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ModelTranslate.BeginAnimation(TranslateTransform3D.OffsetXProperty, ca3d_x);&lt;BR&gt;}&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It then dawned on me, as I looked at 05, an orbiting sphere, that it&amp;nbsp;would make for great planets.&amp;nbsp;&amp;nbsp;I went out to &lt;A target=_blank href="http://maps.jpl.nasa.gov/jupiter.html" mce_href="http://maps.jpl.nasa.gov/jupiter.html"&gt;NASA&lt;/A&gt; and found the texture&amp;nbsp;maps for Jupiter and its moons.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;I also wanted to do all of this 3D work in XAML, so I made a class called &lt;STRONG&gt;SphereModelVisual3D&lt;/STRONG&gt; that I could instantiate Jupiter, for example, like this:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://wpf.netfx3.com/direct/planets"&gt;&lt;IMG style="MARGIN: 0px 10px 10px" border=0 align=right src="http://rhizohm.net/download/netfx3/p4.jpg"&gt;&lt;/A&gt;&amp;lt;mv3d:SphereModelVisual3D x:Name="Jupiter" &amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;mv3d:SphereModelVisual3D.Material&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DiffuseMaterial&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DiffuseMaterial.Brush &amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ImageBrush ImageSource="&lt;A href="http://maps.jpl.nasa.gov/pix/jup0vss1.jpg%22/"&gt;http://maps.jpl.nasa.gov/pix/jup0vss1.jpg%22/&lt;/A&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/DiffuseMaterial.Brush&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/DiffuseMaterial&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/mv3d:SphereModelVisual3D.Material&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mv3d:SphereModelVisual3D.Transform&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Transform3DGroup &amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ScaleTransform3D ScaleX="2" ScaleY="2"&amp;nbsp; ScaleZ="2" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RotateTransform3D&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RotateTransform3D.Rotation&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;AxisAngleRotation3D Angle="0" Axis="0 1 0" x:Name="Jupiter_rotation"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/AxisAngleRotation3D&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/RotateTransform3D.Rotation&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/RotateTransform3D&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Transform3DGroup&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/mv3d:SphereModelVisual3D.Transform&amp;gt;&lt;BR&gt;&amp;lt;/mv3d:SphereModelVisual3D&amp;gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The animation that handles the elliptical orbits needs to transform the Z property the TranslateTransform3D.&amp;nbsp; It then looks like this:&lt;/P&gt;
&lt;P&gt;&amp;lt;ParallelTimeline RepeatBehavior="Forever"&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;DoubleAnimation Duration="0:0:10"&amp;nbsp; To="360"&amp;nbsp; Storyboard.TargetName="Jupiter_rotation" Storyboard.TargetProperty="Angle"/&amp;gt;&lt;BR&gt;&amp;lt;/ParallelTimeline&amp;gt;&lt;BR&gt;&amp;lt;ParallelTimeline RepeatBehavior="Forever"&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;CustomAnimations:CircleAnimation Duration="0:0:2"&amp;nbsp; Radius="9" Direction="YDirection" Storyboard.TargetName="Io" Storyboard.TargetProperty="(ModelVisual3D.Transform).(Transform3DGroup.Children)[2].(TranslateTransform3D.OffsetZ)"/&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;CustomAnimations:CircleAnimation Duration="0:0:2"&amp;nbsp; Radius="2" Direction="XDirection" Storyboard.TargetName="Io" Storyboard.TargetProperty="(ModelVisual3D.Transform).(Transform3DGroup.Children)[2].(TranslateTransform3D.OffsetX)"/&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;DoubleAnimation Duration="0:0:2"&amp;nbsp; To="360"&amp;nbsp; Storyboard.TargetName="Io_rotation" Storyboard.TargetProperty="Angle"/&amp;gt;&lt;BR&gt;&amp;lt;/ParallelTimeline&amp;gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result is in 06. It is not astronomically correct as far as scale&amp;nbsp;-- I'll leave that for someone with some more time on their hands, but I liked the end result.&amp;nbsp; I also threw in the TrackBall control from the &lt;A target=_blank href="http://www.codeplex.com/3DTools" mce_href="http://www.codeplex.com/3DTools"&gt;3d tools project&lt;/A&gt; so you can trackball the whole model. &lt;/P&gt;
&lt;P mce_keep="true"&gt;The code is &lt;A href="http://wpf.netfx3.com/direct/planets/planets.zip" mce_href="http://wpf.netfx3.com/direct/planets/planets.zip"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1749785" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Flash/default.aspx">Flash</category></item><item><title>Doninoken: WPF XBAP Piece by Bascule</title><link>http://blogs.msdn.com/karstenj/archive/2007/01/25/doninoken-wpf-xbap-piece-by-bascule.aspx</link><pubDate>Thu, 25 Jan 2007 23:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1531418</guid><dc:creator>karstenj</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1531418.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1531418</wfw:commentRss><description>&lt;P&gt;Check out &lt;A class="" href="http://www.microsoft.com/japan/windowsvista/webshowcase/domino.htm" target=_blank mce_href="http://www.microsoft.com/japan/windowsvista/webshowcase/domino.htm"&gt;Doninoken&lt;/A&gt;, an amazing WPF piece that is part of the Japanese Vista launch, done by the design agency &lt;A class="" href="http://bascule.co.jp/" target=_blank mce_href="http://bascule.co.jp/"&gt;Bascule&lt;/A&gt;.&amp;nbsp;&amp;nbsp; The aesthetic is amazing.&amp;nbsp; I love how they use WPF 3D, mapping images on planes and animating the planes.&amp;nbsp;(Watch for the small camera that pops up after the title screen that lets you interact with the app and zoom the camera around.) &amp;nbsp;Still, how did they do it?&amp;nbsp; Maya exports? Hand tweaking XAML?&amp;nbsp; It is very impressive. And makes you want some sushi...&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://www.microsoft.com/japan/windowsvista/webshowcase/domino.htm" target=_blank mce_href="http://www.microsoft.com/japan/windowsvista/webshowcase/domino.htm" border="0"&gt;&lt;IMG style="WIDTH: 750px; HEIGHT: 650px" height=650 src="http://www.microsoft.com/japan/windowsvista/webshowcase/images/domino.jpg" width=750 border=0 mce_src="http://www.microsoft.com/japan/windowsvista/webshowcase/images/domino.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1531418" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category></item><item><title>Woodgrove Finance Application Source Code Posted</title><link>http://blogs.msdn.com/karstenj/archive/2006/12/05/woodgrove-finance-application-source-code-posted.aspx</link><pubDate>Wed, 06 Dec 2006 04:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1214472</guid><dc:creator>karstenj</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/1214472.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=1214472</wfw:commentRss><description>&lt;P&gt;The Woodgrove Finance Application is a great demo of how WPF can be used to create better data visualization, in this case for financial data.&amp;nbsp; I've posted &lt;A href="http://windowsclient.net/downloads/folders/wpfsamples/entry3756.aspx" target=_blank mce_href="http://windowsclient.net/downloads/folders/wpfsamples/entry3756.aspx"&gt;the source code&lt;/A&gt; -- there are some good nuggets in here worth exploring.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;A href="http://scorbs.com/workapps/woodgrove/FinanceApplication.xbap" border="0"&gt;&lt;IMG border=0 src="http://static.flickr.com/54/167900350_9c83993e0d_m.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://scorbs.com/workapps/woodgrove/FinanceApplication.xbap" target=_blank mce_href="http://scorbs.com/workapps/woodgrove/FinanceApplication.xbap"&gt;Click Here&amp;nbsp;To Run It&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Using The Finance Application&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The application provides a 3D visualization into a hypothetical, static porfolio. It is important to note that this application is not bound to live data.&amp;nbsp; To the left is a 2D list of stocks, grouped by Small Cap, Mid Cap and Large Cap stocks.&amp;nbsp; By clicking on a stock in this list, detailed information about the stock can be seen in the far right column.&amp;nbsp; If you hover over the 2D stock chart, it will expand for an easier reading experience.&lt;/P&gt;
&lt;P&gt;Hovering over a stock will group it with other stocks of the same sector within that market size.&amp;nbsp; For example, hovering over ArvinMeritor will also highlight Men's Wearhouse, both part of the consumer segment.&amp;nbsp; This becomes interesting in terms of the 3D chart, in the center of the application.&amp;nbsp; You can see how the labels for the X and Y axis update when different stocks are hovered over.&amp;nbsp; The hover action pinpoints that particular grouping of sector and market cap, aggregating the results.&amp;nbsp; So, one can immediately get a sense of how Mid Cap stocks in the consumer sector are doing -- in this case, not well, as can seen from the long red bar. &lt;/P&gt;
&lt;P&gt;The application is two way, in that you can also interact with the 3D bar chart and see the corresponding 2D areas become highlighted.&amp;nbsp; If you leave the mouse over a given bar for 1 second, you will get information about that bar as well, letting you know what aggregate of stocks that bar represents as well as the market cap and sector.&lt;/P&gt;
&lt;P&gt;If you click on the the Woodgrove logo, the 2D section will animate away, allowing you to focus on the 3D.&amp;nbsp; Holding the right click button down of the mouse will allow you to trackball the graph.&amp;nbsp; In addition, you can compare stocks against the DJIA if you click that button.&amp;nbsp; (The other comparison buttons aren't wired up.)&amp;nbsp; If you then move the slider, you will see an animation between the current data and a date in the past. &lt;/P&gt;
&lt;P&gt;Lastly, by switching in the drop down from Day % Change to Dollar change, the bars turn to columns.&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;STRONG&gt;Decomposing The Finance Application&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;While all of the data is static, the application is designed to support databinding to live data and could be done with a nominal amount of effort.&amp;nbsp; Right now, everything is databound to the static equity.xml file.&amp;nbsp; However, changing the databinding to a webservice would allow for this application to show real data.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;You'll notice that the project is factored into multiple components.&amp;nbsp; The WoodgroveFinanceApplication doesn't really do anything but hold the WoodgroveFinanceHost, which sets up the layout and handles the interaction between the 2D and the 3D.&amp;nbsp; The WoodgroveFinanceStockChartFrame then holds the 2D pieces and the WoodgroveFinanceStockChart3D holds the 3D pieces. By doing this componentization, all of the functionality is really contained in controls, such that they can be added to a different project quite easily.&amp;nbsp; If just the 3D section were desired, it is already isolated from the rest of the application.&lt;/P&gt;
&lt;P&gt;You can open the project in Expression Blend, which is very cool.&amp;nbsp; One could customize the look and feel from within Blend.&amp;nbsp; It also demonstrates how Expression Blend supports opening .sln files and working with multiple projects.&lt;/P&gt;
&lt;P&gt;Lastly, it is worth commenting that the 3D graph is based on work done by Robert Hogue (&lt;A href="http://www.therhogue.com/WinFX/" mce_href="http://www.therhogue.com/WinFX/"&gt;http://www.therhogue.com/WinFX/&lt;/A&gt;).&amp;nbsp; Some of the explanation in his download pack is germaine to the code in the 3D part of the application.&lt;/P&gt;
&lt;P&gt;Enjoy! &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1214472" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category></item><item><title>WPF Vista Gadgets - Part 1: Using XBAP and IFRAME</title><link>http://blogs.msdn.com/karstenj/archive/2006/10/04/WPF-Vista-Gadgets-_2D00_-Part-1_3A00_-Using-XBAP-and-IFRAME.aspx</link><pubDate>Thu, 05 Oct 2006 06:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:792801</guid><dc:creator>karstenj</dc:creator><slash:comments>18</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/792801.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=792801</wfw:commentRss><description>&lt;P&gt;If you are following Vista, you are probably aware of the Sidebar, real estate on the desktop that can be used to host gadgets.&amp;nbsp; And, if you are aware of Sidebar, you might be aware that the platform for gadgets is DHTML + Javascript.&amp;nbsp; And, if you are a WPF designer/developer, you might be asking yourself if there are any ways to get WPF content into a gadget.&amp;nbsp; It turns out that there are some workarounds that will allow you to get WPF into the Sidebar.&amp;nbsp; However, there are drawbacks and limitations with using WPF in the Sidebar as the Sidebar does not officially support WPF for gadgets.&amp;nbsp; In this post, I'm going to enumerate one way you could host WPF in a gadget which is to use XBAP and IFRAMEs. In a later post, I will talk about the other option, which is to use ActiveX controls.&lt;/P&gt;
&lt;P&gt;Before even going down the path of writing a WPF gadget, it&amp;nbsp;is to decide if the cost is worth it.&amp;nbsp; Can you achieve the visual effect you are seeking without WPF?&amp;nbsp; If the answer is no, read on and find out what you are getting yourself into if you choose to use an unsupported gadget technology.&lt;/P&gt;
&lt;P&gt;One of the big limitations with WPF gadgets is that WPF doesn't "play nicely" with the rules of being a gadget, because it swallows mouse events and doesn't propagate them back up to the UI.&amp;nbsp; As such, by default, WPF gadgets won't show the default gadget UI on right click.&amp;nbsp; And, also by default, WPF gadgets won't display the gadget thumb and close icons which are displayed on mouse over.&amp;nbsp; There are work arounds to these problems that I will discuss below, but you can already see that the Sidebar wasn't designed for WPF.&lt;/P&gt;
&lt;P&gt;Another limitataion is that a WPF gadget can't get at any of the Sidebar specific APIs,. So, there is going to be some clunkiness to do things like getting the flyout window to display.&amp;nbsp;&amp;nbsp; Now, some of the system APIs have a .NET equivalent, although they require a certain permission level.&amp;nbsp; When using loose XAML or XBAPs in an IFRAME, you will be sandboxed.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Another limitation has to do with performance and working set implications.&amp;nbsp; The user is going to pay a start up cost for loading the WPF engine the first time the sidebar is instantiated, assuming that WPF hasn't been instantiated yet on the system, which is most likely the case since the Sidebar, by default, loads when a user logs in.&amp;nbsp; Additionally, because of the working set required by WPF and the CLR, the working set of the sidebar itself is also going to creep up.&amp;nbsp; Lastly, when the sidebar closes, either at log off or when closed by the user, it has to unload WPF and the CLR.&amp;nbsp; I've seen some unsavory behavior here if your WPF has opened resources that the sidebar has trouble unloading, the result making for an icky user experience when the sidebar unloads.&amp;nbsp; At this point, I haven't isolated exactly what the behaviors are that cause this problem, but I've seen it. Now, all of these problems are tractable, but they are costs that need to be known up front. You certainly don't want to write a gadget that causes problems or makes for a crummy experience.&lt;/P&gt;
&lt;P&gt;With these problems in mind, let's look at the first technique: using IFRAMEs&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://winfx.members.winisp.net/files/gadgetwpf.jpg"&gt;&lt;/P&gt;
&lt;P&gt;All three of the gadgets pictured above are &lt;A class="" href="http://winfx.members.winisp.net/files/wpf_gadgets.zip" target=_blank mce_href="http://winfx.members.winisp.net/files/wpf_gadgets.zip"&gt;available w/ source&lt;/A&gt;.&amp;nbsp; To install the gadgets, just double click the .gadget files.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Gadgets support the IFRAME tag, which means that you can reference loose xaml or XBAPs from within a gadget.&amp;nbsp; There are a few downsides to this techniques. First, IE has to install the XBAP (or, in the case of loose XAML, the XAMLReader) into the IE application cache.&amp;nbsp; There is no way to preload your XBAP and no way to override the default load UI.&amp;nbsp; So, the user experience is a little funky.&amp;nbsp; Second, if for some reason the IE application cache gets cleared, the XBAP will have to be reloaded the next time the gadget is run.&amp;nbsp; The more likely scenario here is that the gadget's XBAP could be bumped out of the cache due to space limitataions by another XBAP getting installed.&amp;nbsp; The moral of the story being that when using this technique you lose some control over the experience as a whole.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Here's a gadget that hosts a loose XAML file of a rotating 3D cube displaying different images:&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&amp;lt;html&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;head&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;style&amp;gt;&lt;/P&gt;
&lt;P&gt;body { &lt;/P&gt;
&lt;P&gt;width:130;&lt;/P&gt;
&lt;P&gt;height:130;&lt;/P&gt;
&lt;P&gt;padding:5;&lt;/P&gt;
&lt;P&gt;margin:0;&lt;/P&gt;
&lt;P&gt;background:black;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;lt;/style&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;/head&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;body&amp;gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;iframe height="130" &lt;/P&gt;
&lt;P&gt;width="130" &lt;/P&gt;
&lt;P&gt;src="3d_animation.xaml" /&amp;gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;/body&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;To use an XBAP, you simply replace the .xaml file with an .xbap file. The main difference between an XBAP and loose XAML is functionality.&amp;nbsp; You'll notice that the XBAP supports a trackball control, allowing the user to rotate the cube and scale it with the mouse wheel.&amp;nbsp; This was made possible by writing C# code, as can be seen in the source.&lt;/P&gt;
&lt;P&gt;Remember early I mentioned some workarounds for the mouse propagation problem.&amp;nbsp; You can see the workaround to the mouse hover problem where I set the padding of the gadget to 5&amp;nbsp;pixels.&amp;nbsp; Another technique would be to put the IFRAME in an html table. I then make the background color of the padding identical to the background color of the WPF airspace.&amp;nbsp; I lose some screen real estate, but at least I get the thumb and minimize UI to show up on the gadget, although if you move the mouse really fast, it doesn't work.&amp;nbsp; I haven't figured out a workaround to the righ click problem yet.&amp;nbsp; (If anyone does, let me know!)&lt;/P&gt;
&lt;P&gt;One interesting technique that you could do is reference your loose XAML or XBAP on a server.&amp;nbsp; However, this ties the gadget to the internet, which means you'd have to do some checking from Javascript to make sure the user was online before even showing the IFRAME.&amp;nbsp; This is certainly doable: many of the gadgets that ship with Vista do this already.&amp;nbsp; The appeal of this option is that the gadget could be auto-updated on a server and automatically the client would get the new version.&amp;nbsp; Also, XBAPs deployed from a server are allowed to get back to that server for new data, incremental downloads, etc.&lt;/P&gt;
&lt;P&gt;Another interesting fact about XBAP gadgets is that, if they are run from the local filesystem, they can be full trust. However, if they are deployed from a server, they would have to be partial trust unless the cert that signed the XBAP is registered in the user's trusted publishers certificate store.&lt;/P&gt;
&lt;P&gt;[&lt;A class="" href="http://winfx.members.winisp.net/files/wpf_gadgets.zip" target=_blank mce_href="http://winfx.members.winisp.net/files/wpf_gadgets.zip"&gt;Source and Gadgets&lt;/A&gt;]&lt;/P&gt;
&lt;P&gt;(Note: thanks to the &lt;A class="" href="http://www.maureenlanza.com/" mce_href="http://www.maureenlanza.com"&gt;artistry of Maureen Lanza&lt;/A&gt; for the images.)&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=792801" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category></item><item><title>3D Integration in Windows Presentation Foundation: Daniel Lehenbauer Does It Again</title><link>http://blogs.msdn.com/karstenj/archive/2006/06/15/632676.aspx</link><pubDate>Thu, 15 Jun 2006 22:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:632676</guid><dc:creator>karstenj</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/632676.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=632676</wfw:commentRss><description>How did I miss this?&amp;nbsp; Daniel's show on 3D Integration in Windows Presentation Foundation is really nice.&amp;nbsp; Even better, he shares some &lt;A href="http://viewport3d.com/Blog_Files/MSDN_TV_Source.htm"&gt;great code samples&lt;/A&gt;, which indirectly&amp;nbsp;lead me to &lt;A href="http://viewport3d.com/"&gt;http://viewport3d.com&lt;/A&gt; which has a nifty article -- nice domain name snag, Daniel!&amp;nbsp; I think I need a seperate 5 day course on 3D and WPF...&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=632676" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category></item><item><title>Thoughts On Video on 3D in WPF </title><link>http://blogs.msdn.com/karstenj/archive/2006/06/14/631453.aspx</link><pubDate>Thu, 15 Jun 2006 00:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:631453</guid><dc:creator>karstenj</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/631453.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=631453</wfw:commentRss><description>&lt;P&gt;I have uploaded &lt;A href="http://wpf.netfx3.com/files/folders/applications/entry3377.aspx"&gt;Sandbox3D&lt;/A&gt; into the WPF Gallery.&amp;nbsp;&amp;nbsp;I added back&amp;nbsp;the X, Y and Z axes using ScreenSpaceLines3D from Daniel Lehenbauer.&amp;nbsp; Most interestingly,&amp;nbsp;I show two different techniques for mapping video on 3D.&amp;nbsp; One is using the &lt;STRONG&gt;VideoDrawing&lt;/STRONG&gt; with a &lt;STRONG&gt;MediaPlayer&lt;/STRONG&gt;, like this:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;private void DrawVideoOnMesh(VideoDrawing vd, GeometryModel3D gm3d, Uri uri)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MediaPlayer mp = new MediaPlayer();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mp.Open(uri);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mp.MediaEnded += new EventHandler(mp_MediaEnded);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vd.Player = mp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vd.Rect = new Rect(0, 0, 5, 10);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DrawingBrush db = new DrawingBrush();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; db.Drawing = vd;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Brush br = db as Brush;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MaterialGroup mg = new MaterialGroup();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mg.Children.Add(new DiffuseMaterial(br));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gm3d.Material = mg;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vd.Player.Play();&lt;BR&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Times New Roman"&gt;The other uses&amp;nbsp;a &lt;STRONG&gt;VisualBrush&lt;/STRONG&gt; with a &lt;STRONG&gt;MediaElement&lt;/STRONG&gt;:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;private void DrawVisualBrushOnMesh(GeometryModel3D gm3d, Uri uri)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myMedia.Source = uri;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myMedia.MediaEnded += new RoutedEventHandler(myMedia_MediaEnded);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VisualBrush vb = new VisualBrush(myMedia);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MaterialGroup mg = new MaterialGroup();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mg.Children.Add(new DiffuseMaterial(vb));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gm3d.Material = mg;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myMedia.Play();&lt;BR&gt;}&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Times New Roman"&gt;Because there are two ways to acheive the effect (gee, being able to do something more than one way &lt;EM&gt;never &lt;/EM&gt;happens in WPF), you may be wondering which you should use.&amp;nbsp; The answer is, of course, it depends.&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Times New Roman"&gt;From a performance perspective, there is very little difference between the two techiques because both techniques will require WPF to create an intermediary render surface to be able to correctly map the video to 3D.&amp;nbsp; (This intermediary step always happens with a &lt;STRONG&gt;VisualBrush&lt;/STRONG&gt; even in 2D, whereas it doesn't happen with the &lt;STRONG&gt;VideoDrawing&lt;/STRONG&gt; in 2D, which may be worth noting for doing tricky things with video in 2D, but that is another topic.)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Times New Roman"&gt;From a code manageability perspective, it is worth pointing out that &lt;STRONG&gt;VideoDrawing&lt;/STRONG&gt; requires using code, whereas you could create and control (using Storyboards) a &lt;STRONG&gt;VisualBrush&lt;/STRONG&gt;, &lt;STRONG&gt;MediaElement &lt;/STRONG&gt;and all the necessary 3D gunk entirely in XAML -- in fact, EID does just this.&amp;nbsp; However, there is the slight&amp;nbsp;strangeness that you have to be rendering that&amp;nbsp;&lt;STRONG&gt;MediaElement &lt;/STRONG&gt;somewhere,&amp;nbsp;even if it is offscreen or buried in z-space (which is what I did in Sandbox3D).&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Times New Roman"&gt;One other note: there are two bugs with using video on 3D in Beta2 to be aware of.&amp;nbsp; First, looping is broken,&amp;nbsp; Second, applying a MaterialGroup that has video&amp;nbsp;a second time to the same model doesn't work.&amp;nbsp; However, both of these issues are known and will be resolved for the next CTP.&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=631453" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category></item><item><title>Updated MSDN Article on Dynamic Animations in WPF</title><link>http://blogs.msdn.com/karstenj/archive/2006/06/08/622982.aspx</link><pubDate>Fri, 09 Jun 2006 01:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:622982</guid><dc:creator>karstenj</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/622982.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=622982</wfw:commentRss><description>&lt;P&gt;I've updated an MSDN article that I wrote quite awhile back called &lt;A href="http://msdn.microsoft.com/winfx/technologies/presentation/default.aspx?pull=/library/en-us/dnlong/html/avalon2d-3d.asp"&gt;Creating 2-D and 3-D Dynamic Animations in Windows Presentation Foundation&lt;/A&gt;. Basically, it is a visualization of CPU utilization, dynamically creating the animation on the fly using the WPF Animation engine.&amp;nbsp; The article shows how to do simple scale animations in 3D, of which there aren't a ton of examples out there.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://msdn.microsoft.com/library/en-us/dnlong/html/avalon2d-3d01.jpg"&gt;&lt;/P&gt;
&lt;P&gt;The most interesting update to the article&amp;nbsp;is running the application on Vista. Because of &lt;A href="http://msdn.microsoft.com/windowsvista/reference/security/default.aspx?pull=/library/en-us/dnlong/html/accprotvista.asp"&gt;User Account Control (UAC)&lt;/A&gt; in Vista, the application requires elevated permissions to get at the performance counter data.&amp;nbsp;The article explains how to have your application display the standard elevated permission dialog using a manifest -- much more user friendly than having your users right-click and run as admin:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://msdn.microsoft.com/library/en-us/dnlong/html/avalon2d-3d03.gif"&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=622982" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category></item><item><title>ScreenspaceLines3D</title><link>http://blogs.msdn.com/karstenj/archive/2006/05/30/611190.aspx</link><pubDate>Wed, 31 May 2006 02:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:611190</guid><dc:creator>karstenj</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/karstenj/comments/611190.aspx</comments><wfw:commentRss>http://blogs.msdn.com/karstenj/commentrss.aspx?PostID=611190</wfw:commentRss><description>Those lamenting the loss of ScreenSpaceLines3D -- count me as one of them as I used them in Sandbox3D which I need to post ASAP for beta 2 -- should check out Daniel Lehenbauer's &lt;A HREF="/danlehen/archive/2006/05/29/610310.aspx"&gt;community implementation&lt;/A&gt;&amp;nbsp;which also includes some other helpful 3D classes.&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=611190" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/karstenj/archive/tags/Windows+Presentation+Foundation+_2800_Avalon_2900_/default.aspx">Windows Presentation Foundation (Avalon)</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/karstenj/archive/tags/Avalon/default.aspx">Avalon</category></item></channel></rss>