Поделиться через


Worldspace, Modelspace, Primitives and Code: The Donut Primitive, V2

If you are interested in Avalon 3D, you should be following Dan Lehen's blog.  His most recent article is excellent and was quite illuminating for me, especially the understanding of how you can compose Avalon 3D models in a very similar way to composing Avalon 2D elements.  I went through Dan's exercise and found it extremely illuminating and would highly encourage you to do so. 

I decided to improve my last 3D sample based on what I learned from Dan's piece, tweaking the way I created world space, model space and primitives. In the screen shot below, you can see the cylinder has been translated to 3,-3,-3. 

The application allows you to perform scale, rotation and translation transformations to primitives using a GUI.  Note that it doesn't hold Transformation collections nor does it maintain state of the prior transformation.  Baby steps.  When I find some more time, I want to support Transformation collections and state maintenance, so that you could use the arrow keys to move your primitives through world space.

Rather, than walk through the code in this blog, I would encourage you to download it and take a look.  One gotcha I encountered when building the sample:  Dan loads his primitives from XAML files using a stream loader, as opposed to getting them from a class.  Consequently, MSBUILD needs to know that these files are not to be compiled at design time, only at runtime.  As such, in the MSBUILD file, they need to be tagged as "resources".

Comments