2012年9月30日 星期日
三球儀自轉公轉設定
三球儀公自轉設定(以WPF 3D Sphere 物件為例)
1. 腳本設定
<Grid.Triggers>
<EventTrigger RoutedEvent="UserControl.Loaded" >
<BeginStoryboard>
<Storyboard Name="myStoryBoard">
<DoubleAnimation
Storyboard.TargetName="自轉"
Storyboard.TargetProperty="Angle"
From="0" To="360" Duration="0:0:1" RepeatBehavior="Forever"/>
<DoubleAnimation
Storyboard.TargetName="公轉"
Storyboard.TargetProperty="Angle"
From="0" To="360" Duration="0:0:10" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
2. 自、公轉軸設定
<ModelVisual3D.Transform>
<Transform3DGroup>
<!-- 先設定自轉軸 --!>
<RotateTransform3D CenterX="0" CenterY="0" CenterZ="0">
<RotateTransform3D.Rotation>
<AxisAngleRotation3D x:Name="自轉" Angle="0" Axis="0.3,1,0" />
</RotateTransform3D.Rotation>
</RotateTransform3D>
<!-- 平移公轉半徑 --!>
<TranslateTransform3D OffsetX="3" OffsetY="0" OffsetZ="0" />
<!-- 設定公轉軸--!>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D x:Name="公轉" Angle="0" Axis="0,1,0" />
</RotateTransform3D.Rotation>
</RotateTransform3D>
</Transform3DGroup>
</ModelVisual3D.Transform>
訂閱:
文章 (Atom)