by John Zolezzi
EllipseLayout3D Sample
This sample shows how to create a circular path of 3D models that you can rotate with the mouse. The 3D is created in xaml with the classes found in Blendables 3D mix. Add ItemsControl3D to a Viewport3D and then set the layout, model generator and items to ItemsControl3D.
Blendables’ layout class EllipseLayout3D handles positioning the models in 3D space. To rotate the items around, you just need to change the direction of EllipseLayout3D’s FrontDirection vector as seen below:
AxisAngleRotation3D rotate = new AxisAngleRotation3D(new Vector3D(0, 1, 0), (deltaX / 2));RotateTransform3D trans = new RotateTransform3D(rotate);_EllipseLayout.FrontDirection = trans.Transform(_EllipseLayout.FrontDirection);
ItemsControl3D needs to know how to generate models from the items that are passed in via the ItemsSource property. This property works just like WPF’s ItemsControl. Here we are using one of the pre-built model generators: DataTemplatedVisual3DGenerator. It allows you to use a DataTemplate and a default mesh to create all the models. It works in a similar fashion to ItemsControl’s ItemsTemplate property.