Visual3D.TransformToAncestor and Visual3D.TransformToDescendant

Visual3D contains methods for the opposite scenario of mapping from 3D space into 2D space. The GeneralTransform3DTo2D returned by Visual3D.TransformToAncestor maps from the Visual3D’s 3D coordinate space into some 2D parent’s coordinate space. This is especially useful when an app tracks a 3D point on the screen and then draws 2D content whose position must follow that 3D point.

Listings 8.10 and 8.11 use TransformToAncestor to make the TextBlocks to follow the corners of the rotating cube, as shown in Figure 8.53.

LISTING 8.10 MainWindow.xaml: The Cube and TextBlocks

<Window x:Class="MainWindow"        xmlns="" ...

Get XAML Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.