<?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>WPF3D Team Blog : Geometry</title><link>http://blogs.msdn.com/wpf3d/archive/tags/Geometry/default.aspx</link><description>Tags: Geometry</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Petzold.Media3D</title><link>http://blogs.msdn.com/wpf3d/archive/2007/09/07/petzold-media3d.aspx</link><pubDate>Sat, 08 Sep 2007 07:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4822276</guid><dc:creator>wpf3d</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/wpf3d/comments/4822276.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpf3d/commentrss.aspx?PostID=4822276</wfw:commentRss><description>&lt;P&gt;Charles Petzold has &lt;A class="" href="http://www.charlespetzold.com/3D/" mce_href="http://www.charlespetzold.com/3D/"&gt;posted his WPF3D library on the web.&lt;/A&gt;&amp;nbsp;It includes sphere, cube, cylinder, torus, line, and teapot mesh generation.&lt;/P&gt;
&lt;P&gt;Buying his book&amp;nbsp;&lt;EM&gt;3D Programming for Windows&lt;/EM&gt; grants you royalty-free use of the library so be sure to check it out!&lt;/P&gt;
&lt;P&gt;-- Jordan&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4822276" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpf3d/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/wpf3d/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/wpf3d/archive/tags/Books/default.aspx">Books</category><category domain="http://blogs.msdn.com/wpf3d/archive/tags/Geometry/default.aspx">Geometry</category><category domain="http://blogs.msdn.com/wpf3d/archive/tags/Apps/default.aspx">Apps</category></item><item><title>Subclassing UIElement3D</title><link>http://blogs.msdn.com/wpf3d/archive/2007/09/05/subclassing-uielement3d.aspx</link><pubDate>Thu, 06 Sep 2007 04:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4775055</guid><dc:creator>wpf3d</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/wpf3d/comments/4775055.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpf3d/commentrss.aspx?PostID=4775055</wfw:commentRss><description>&lt;P&gt;Subclassing from UIElement3D to create your own elements that respond to input, focus and eventing is simple to do in 3.5.&amp;nbsp; In this example we'll create a Sphere class which derives from UIElement3D and will show off some new features in the process.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Deriving from UIElement3D&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The first step is to derive from UIElement3D:&lt;/P&gt;&lt;PRE class=code&gt;    &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Sphere&lt;/SPAN&gt; : &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;UIElement3D
&lt;/SPAN&gt;    {&lt;/PRE&gt;&lt;PRE class=code&gt;    }&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;Even though UIElement3D is declared abstract, there aren't any abstract methods you need to override.&amp;nbsp; The above will compile -&amp;nbsp;it just won't do anything interesting.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Rendering a Sphere&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Although the above lets us derive from UIElement3D, we still don't have anything rendering to look like a sphere.&amp;nbsp; Before going in to how to render the sphere, first we're going to want to create a couple of dependency properties to control how the sphere looks.&amp;nbsp; These will be PhiDiv and ThetaDiv, to represent the number of slices to make in the horizontal and vertical directions respectively, as well as Radius, to represent the radius of the sphere.&amp;nbsp; The code for these is below:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;        ///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;        &lt;SPAN style="COLOR: rgb(128,128,128)"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; The number of vertical slices to make on the sphere
&lt;/SPAN&gt;        &lt;SPAN style="COLOR: rgb(128,128,128)"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;readonly&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyProperty&lt;/SPAN&gt; ThetaDivProperty =
            &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyProperty&lt;/SPAN&gt;.Register(&lt;SPAN style="COLOR: rgb(163,21,21)"&gt;"ThetaDiv"&lt;/SPAN&gt;,
                                        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;),
                                        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Sphere&lt;/SPAN&gt;),
                                        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;PropertyMetadata&lt;/SPAN&gt;(15, ThetaDivPropertyChanged));

        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt; ThetaDivPropertyChanged(&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyObject&lt;/SPAN&gt; d, &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyPropertyChangedEventArgs&lt;/SPAN&gt; e)
        {
            &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Sphere&lt;/SPAN&gt; s = (&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Sphere&lt;/SPAN&gt;)d;
            s.InvalidateModel();
        }

        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt; ThetaDiv
        {
            &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;get
&lt;/SPAN&gt;            {
                &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;return&lt;/SPAN&gt; (&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;)GetValue(ThetaDivProperty);
            }

            &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;set
&lt;/SPAN&gt;            {
                SetValue(ThetaDivProperty, &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;value&lt;/SPAN&gt;);
            }
        }

        &lt;SPAN style="COLOR: rgb(128,128,128)"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;        &lt;SPAN style="COLOR: rgb(128,128,128)"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; The number of horizontal slices to make on the sphere
&lt;/SPAN&gt;        &lt;SPAN style="COLOR: rgb(128,128,128)"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;readonly&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyProperty&lt;/SPAN&gt; PhiDivProperty =
            &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyProperty&lt;/SPAN&gt;.Register(&lt;SPAN style="COLOR: rgb(163,21,21)"&gt;"PhiDiv"&lt;/SPAN&gt;,
                                        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;),
                                        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Sphere&lt;/SPAN&gt;),
                                        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;PropertyMetadata&lt;/SPAN&gt;(15, PhiDivPropertyChanged));

        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt; PhiDivPropertyChanged(&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyObject&lt;/SPAN&gt; d, &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyPropertyChangedEventArgs&lt;/SPAN&gt; e)
        {
            &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Sphere&lt;/SPAN&gt; s = (&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Sphere&lt;/SPAN&gt;)d;
            s.InvalidateModel();
        }

        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt; PhiDiv
        {
            &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;get
&lt;/SPAN&gt;            {
                &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;return&lt;/SPAN&gt; (&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;)GetValue(PhiDivProperty);
            }

            &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;set
&lt;/SPAN&gt;            {
                SetValue(PhiDivProperty, &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;value&lt;/SPAN&gt;);
            }
        }

        &lt;SPAN style="COLOR: rgb(128,128,128)"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;        &lt;SPAN style="COLOR: rgb(128,128,128)"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; The radius of the sphere
&lt;/SPAN&gt;        &lt;SPAN style="COLOR: rgb(128,128,128)"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;readonly&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyProperty&lt;/SPAN&gt; RadiusProperty =
            &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyProperty&lt;/SPAN&gt;.Register(&lt;SPAN style="COLOR: rgb(163,21,21)"&gt;"Radius"&lt;/SPAN&gt;,
                                        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;double&lt;/SPAN&gt;),
                                        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Sphere&lt;/SPAN&gt;),
                                        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;PropertyMetadata&lt;/SPAN&gt;(1.0, RadiusPropertyChanged));

        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt; RadiusPropertyChanged(&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyObject&lt;/SPAN&gt; d, &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyPropertyChangedEventArgs&lt;/SPAN&gt; e)
        {
            &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Sphere&lt;/SPAN&gt; s = (&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Sphere&lt;/SPAN&gt;)d;
            s.InvalidateModel();
        }

        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;double&lt;/SPAN&gt; Radius
        {
            &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;get
&lt;/SPAN&gt;            {
                &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;return&lt;/SPAN&gt; (&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;double&lt;/SPAN&gt;)GetValue(RadiusProperty);
            }

            &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;set
&lt;/SPAN&gt;            {
                SetValue(RadiusProperty, &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;value&lt;/SPAN&gt;);
            }
        }&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;InvalidateModel, OnUpdateModel and &lt;STRONG&gt;Visual3DModel&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The above should look like standard C# WPF code to create a few dependency properties, but the one new method that should look unfamiliar is the InvalidateModel call made whenever any of the above dependency properties changes.&amp;nbsp;InvalidateModel is similar to the InvalidateVisual method that exists for the 2D UIElement.&amp;nbsp; Calling InvalidateModel indicates that the 3D model representing the UIElement3D has changed and should be updated.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In&amp;nbsp;response to InvalidateModel, OnUpdateModel will be called to update the 3D model that represents the object. In this way, you can&amp;nbsp;make multiple changes to properties that affect the visual appearance of the UIElement3D and only make one final change to the model, rather than having to regenerate it each time a change is made.&amp;nbsp; For instance, say changes are made to ThetaDiv, PhiDiv, and Radius above.&amp;nbsp;&amp;nbsp;Rather than having to regenerate the model each time, InvalidateModel can be called each time a property changes, and then all of the changes can be dealt with when OnUpdateModel is called. Of course,&amp;nbsp;the model can also be changed in other places, but this provides one standard option to make the change.&lt;/P&gt;
&lt;P&gt;The last thing that hasn't been discussed is how to actually change the model.&amp;nbsp;In 3.5, Visual3D now exposes a protected CLR property Visual3DModel which represents the 3D model for the object.&amp;nbsp; This is the 3D equivalent to the render data of a 2D Visual.&amp;nbsp; To set what the visual representation for the Visual3D&amp;nbsp;is&amp;nbsp;then, it's necessary to set this property.&amp;nbsp; For instance, ModelUIElement3D's&amp;nbsp;Model property takes care of setting this. There is one subtle point about setting this property.&amp;nbsp; Just like render data, setting this property won't set up the links necessary for things such as data bindings to work.&amp;nbsp; To make this happen, you'll also want to have a dependency property for the&amp;nbsp;model itself.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code for InvalidateModel is shown below, as well as the Model dependency property:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=code&gt;        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;protected&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;override&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt; OnUpdateModel()
        {
            &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;GeometryModel3D&lt;/SPAN&gt; model = &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;GeometryModel3D&lt;/SPAN&gt;();

            model.Geometry = Tessellate(ThetaDiv, PhiDiv, Radius);
            model.Material = &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DiffuseMaterial&lt;/SPAN&gt;(&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Brushes&lt;/SPAN&gt;.Blue);

            Model = model;
        }

        &lt;SPAN style="COLOR: rgb(128,128,128)"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;        &lt;SPAN style="COLOR: rgb(128,128,128)"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; The Model property for the sphere
&lt;/SPAN&gt;        &lt;SPAN style="COLOR: rgb(128,128,128)"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;readonly&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyProperty&lt;/SPAN&gt; ModelProperty =
            &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyProperty&lt;/SPAN&gt;.Register(&lt;SPAN style="COLOR: rgb(163,21,21)"&gt;"Model"&lt;/SPAN&gt;,
                                        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Model3D&lt;/SPAN&gt;),
                                        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Sphere&lt;/SPAN&gt;),
                                        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;PropertyMetadata&lt;/SPAN&gt;(ModelPropertyChanged));

        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt; ModelPropertyChanged(&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyObject&lt;/SPAN&gt; d, &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;DependencyPropertyChangedEventArgs&lt;/SPAN&gt; e)
        {
            &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Sphere&lt;/SPAN&gt; s = (&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Sphere&lt;/SPAN&gt;)d;
            s.Visual3DModel = (&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Model3D&lt;/SPAN&gt;)e.NewValue;
        }

        &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Model3D&lt;/SPAN&gt; Model
        {
            &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;get
&lt;/SPAN&gt;            {
                &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;return&lt;/SPAN&gt; (&lt;SPAN style="COLOR: rgb(43,145,175)"&gt;Model3D&lt;/SPAN&gt;)GetValue(ModelProperty);
            }

            &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;set
&lt;/SPAN&gt;            {
                SetValue(ModelProperty, &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;value&lt;/SPAN&gt;);
            }
        }&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;Attached to this post you'll find a simple example app which has the full code to the above Sphere class.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4775055" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/wpf3d/attachment/4775055.ashx" length="60911" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/wpf3d/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/wpf3d/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/wpf3d/archive/tags/Geometry/default.aspx">Geometry</category><category domain="http://blogs.msdn.com/wpf3d/archive/tags/UIElement3D/default.aspx">UIElement3D</category><category domain="http://blogs.msdn.com/wpf3d/archive/tags/3.5/default.aspx">3.5</category></item><item><title>Texture Coordinates in WPF3D</title><link>http://blogs.msdn.com/wpf3d/archive/2007/01/15/texture-coordinates-in-wpf3d.aspx</link><pubDate>Tue, 16 Jan 2007 01:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1473171</guid><dc:creator>wpf3d</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/wpf3d/comments/1473171.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpf3d/commentrss.aspx?PostID=1473171</wfw:commentRss><description>&lt;P&gt;If you've never encountered texture coordinates before, DanLehen has a detailed introduction that you can find &lt;A href="http://blogs.msdn.com/danlehen/archive/2005/11/06/489627.aspx" mce_href="http://blogs.msdn.com/danlehen/archive/2005/11/06/489627.aspx"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;If you have used texture coordinates before in another API you may have noticed that&amp;nbsp;we are a little different. Here's what you need to know: 
&lt;UL&gt;
&lt;LI&gt;Traditionally, the vertical texture coordinate axis (&lt;EM&gt;v&lt;/EM&gt;) points up but in WPF3D it points down. This is for consistency with 2D. If you're trying to dispay a mesh from a system where &lt;EM&gt;v&lt;/EM&gt; points up, you can either convert the texture coordinates by hand or use a Transform on the Brush to flip it. 
&lt;LI&gt;If you don't set TileBrush.ViewportUnits to BrushMappingMode.Absolute, your texture coordinates will be relative to the bounding box of your geometry. For example, let's say you only want half of your texture in &lt;EM&gt;v&lt;/EM&gt; to be mapped to the mesh. In other APIs, you would just range your coordinate from 0.0 -&amp;gt; 0.5. If you do that in WPF3D without setting ViewportUnits to Absolute, it'll still map the entire thing. Essentially any time you don't want&amp;nbsp;one&amp;nbsp;copy of the entire texture&amp;nbsp;you'll want to set Absolute. 
&lt;LI&gt;We do not generate texture coordinates if you do not specify them. The only Brush that doesn't need texture coordinates is SolidColorBrush. 
&lt;LI&gt;Tiling is controlled by TileBrush.TileMode which defaults to None. If you want to tile your texture, set Absolute, set TileMode to Tile, and then use texture coordinates that go past 1.0 (e.g. 0.0 -&amp;gt; 3.0 would tile it three times). Check out the TileMode docs for more options.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;If you're having trouble&amp;nbsp;coming up with&amp;nbsp;texture coordinates, &lt;A href="http://www.codeplex.com/3DTools"&gt;3DTools&lt;/A&gt; has some&amp;nbsp;basic&amp;nbsp;texture coordinate generators.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-- Jordan&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1473171" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpf3d/archive/tags/3D/default.aspx">3D</category><category domain="http://blogs.msdn.com/wpf3d/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/wpf3d/archive/tags/3DTools/default.aspx">3DTools</category><category domain="http://blogs.msdn.com/wpf3d/archive/tags/Geometry/default.aspx">Geometry</category><category domain="http://blogs.msdn.com/wpf3d/archive/tags/Brushes/default.aspx">Brushes</category></item></channel></rss>