in

Tile Turn Sample

File Size: 285.9kB Posted By: kurt.brockett
Date Added: 03-26-2009

Blendables 3D mix gives you the flexibility to create your own custom layouts.   This example shows how to create your own layout and model generator to implement your own tile turn view.  This is similar to the one found in iTunes cover flow.  The key classes that implement this custom layout are TileTurnLayout and ModelFromTemplateVisual3DGenerator.

TileTurnLayout class controls how the models are placed in the view by implementing a function called GetItemTransforms from Layout3D.  GetItemTransforms passes a list of created models and data associated for each item.  The function expects a list of Transform3D objects for each item.  You can create multiple transforms for each item by using a Transform3DGroup. 

The class also has a property called CenteredItemOffset which controls which item is centered in the view.  When this property is changed the 3D mix framework calls GetItemTransforms again. Notice that this property is a double instead of a normal index value to allow smooth animation by calling GetItemTransforms more often.  So from 0 to 1, you would get calls for 0.1, 0.2, 0.4, 0.6, etc as determined by the animation you have setup.  This example has the slide animation defined:

 

<DoubleAnimation x:Key="SlideAnimation" Duration="0:0:0.7" DecelerationRatio="1" AccelerationRatio="0" />

 

The second part of this implementation is creating the models from the data in TileTurnControl’s ItemsSource.   We created a custom model generator called ModelFromTemplateVisual3DGenerator.  This class creates the model with reflection from each item passed to ItemsSource.  It also uses a DataTemplate passed to the TileTurnControl.   It implements GetItemVisual3D defined in Visual3DGeneratorBase.  GetItemVisual3D pass you the data from the item and expects a model in return.

To run the sample, simply load it in Visual Studio 2008 and add the IdentityMine.Windows and IdentityMine.Windows.Media3D references.

Enjoy!

Filed under:
Copyright © 2007 IdentityMine, Inc.  | Careers  | Policies  | License  | News & Press