在3D模型上应用选择效果 [英] Applying a selection effect on 3D models
本文介绍了在3D模型上应用选择效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我想在3D模型中添加选择效果,这样当我选择模型时,它会淡出另一种颜色,而取消选择它时,它应该又变回原来的颜色再次上色.我的想法是创建一个情节提要板,并在选择了某个模型后在故事提要板后面的代码中的某个位置启动,但是,我将如何指定实际的淡入淡出效果,例如从棕色变为红色?
Hi Guys
I want to add a selection effect to my 3d models so that when I select a model it fades to another color, and when deselecting it, it should fade back to it''s original color again. The idea I have is to create a Storyboard, and somewhere in the code behind start the Storyboard when a certain model is selected, but, how would I go about specifying the actual fade effect e.g brown to red?
推荐答案
您可以使用ColorAnimationUsingKeyFrames
进行此操作,如以下示例所示:
You could do this using a ColorAnimationUsingKeyFrames
as in the following sample:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="FadeSample.Window1"
x:Name="Window"
Title="Window1"
Width="640" Height="480">
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="FadeSample.Window1"
x:Name="Window"
Title="Window1"
Width="640" Height="480">
<Window.Resources>
<Storyboard x:Key="OnClick1">
<ColorAnimationUsingKeyFrames
BeginTime="00:00:00" Storyboard.TargetName="button"
Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
<SplineColorKeyFrame KeyTime="00:00:01" Value="#FFEF1407"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger
RoutedEvent="ButtonBase.Click" SourceName="button">
<BeginStoryboard Storyboard="{StaticResource OnClick1}"/>
</EventTrigger>
</Window.Triggers>
<Grid x:Name="LayoutRoot">
<Button
HorizontalAlignment="Left"
VerticalAlignment="Top"
Content="Button"
RenderTransformOrigin="3.339,5.055"
Margin="120,115,0,0"
Background="#FFDF891A"
x:Name="button"/>
</Grid>
</Window>
这篇关于在3D模型上应用选择效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文