Click here to Skip to main content
Click here to Skip to main content

3D Rotate a Shattered Content Control

By , 6 Jul 2009
 

Introduction

This control has front and back content. The transition between the contents is a 3D rotation of the contents broken down into multiple pieces.

It is kind of a knockoff of the much more elegant control Josh Smith made, which can be found here.

Background

During the animation, the front and back content controls are hidden and the Viewport3D is made visible. When the animation completes, the Viewport3D is hidden and the appropriate content is made visible.

This is achieved simply by creating a visual brush of each content control, then retrieving a section of the Visual Brush using the Viewbox property, then painting that brush to a grid which is then set to the Visual property of a Viewport2DVisual3D. The Viewport2DVisual3D then gets positioned and added to the Viewport.

Using the code

To change the size of each rotating piece, you can set the PeiceSizeHeight and PeiceSizeWidth fields in the custom control. These fields use absolute coordinates relative to the actual size of the control. There are also fields for the animation length.

These fields should be exposed as dependency properties; however, I felt fields were appropriate to indicate the “incomplete” status of this control.

double PeiceSizeHeight = 0.2;
double PeiceSizeWidth = 0.2;

Points of interest

There are some features of the control that are being ignored until the most significant issues get resolved. Most are marked with comments in the code.

My main problem with this control is the animation. Each piece has its own animation that fires and runs separate from one another, and the actual one gets started right after the creation phase of each Viewport2DVisual3D. A keyframe type animation within a Storyboard would be ideal to build up the animation and give each piece its proper animation “delay” time offset.

The second thing that could make this control better is if each Viewport2DVisual3D had a property that describes the location of the piece (Pieces down, Pieces across – e.g., 3,3 => is the middle (almost) piece of 6 pieces by 6 pieces). This would make the task of performing the animations in a controlled manner require less code, rather than relying on the order in which children were added to the viewport during an iterative statement.

Would this be archived by adding an Attached Property to a custom Viewport3D class or by adding a Dependency Property to a custom Viewport2DVisual3D class? Do I extend the Viewport3D class or the Viewport2DVisual3D class to hold the “Pieces down/Pieces across” property, or am I approaching this all wrong? Thanks for any suggestions.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Dan Wts
Canada Canada
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
General3D Rotate a Shattered Content Controlmembermouss200622 Dec '10 - 6:14 
Hi thanks very much for your control.I don't want multiple part in the rotation.
So I set the peiceSize to 1.
 
double PeiceSizeHeight =1;
double PeiceSizeWidth =1;
 
But after the rotation the backcontent is visible but disabled.
I cannot do any thing.
Could you explain me why? and how can I perform this effect.
Generalwhite stripe on bottommemberDaProgramma14 Jul '09 - 23:45 
Hello,
the animation does not seem to work correctly. When it runs, a white stripe at the bottom of the window appears, and the picture is truncated.
Any ideas?
 
Tnx
daProgramma
GeneralRe: white stripe on bottom [modified]memberDan Wts15 Jul '09 - 15:01 
Thank you for the feedback DaProgramma.
 
The white stripe you refereed to appears when the pieceSizeHight field is set to a value that does not divide into 1 evenly. For example - if pieceSizeHight is .23 then .... 1/.23 = 4.34 . Four pieces(down) will appear and the remaining .34 will not. Basically there is a missing for loop to build the remainder pieces.
To avoid the white stripe keep the pieceSizeHight and pieceSizeWidth values something like .2, .25, .5 . Anything without a remainder when divided by 1.
 
Thanks for pointing that out. I should have mentioned something in the article.
 
modified on Wednesday, September 16, 2009 12:12 PM

GeneralPretty cool~memberDragonfly_Lee9 Jul '09 - 23:42 
Interesting article, well done~ Wink | ;)
 
Smile | :)
 
I Love KongFu~

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 7 Jul 2009
Article Copyright 2009 by Dan Wts
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid