UWP中是否有等效/替换System.Window.Media.Model3DGroup类?搜遍了所有,找不到任何。
这是我想在UWP中复制的示例WPF代码:
<Model3DGroup.Children>
<!-- Group Child 0 -->
<Model3DGroup >
<Model3DGroup.Transform>
<Transform3DGroup>
<Transform3DGroup.Children>
<Transform3DCollection >
<ScaleTransform3D ScaleX="1" ScaleY="1" ScaleZ="1" />
<RotateTransform3D >
<RotateTransform3D.Rotation >
<AxisAngleRotation3D x:Name="myRotate" Axis="1 0 0" Angle="0" />
</RotateTransform3D.Rotation>
</RotateTransform3D>
<TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0" />
</Transform3DCollection>
</Transform3DGroup.Children>
</Transform3DGroup>
</Model3DGroup.Transform>
<Model3DGroup.Children>
<!-- Child 0 -->
<!-- BACK -->
<GeometryModel3D Transform="{StaticResource CubeMeshTransform2}">
<GeometryModel3D.Geometry>
<MeshGeometry3D
TriangleIndices=" 0,1,2
3,4,5 "
TextureCoordinates=" 1,0 1,1 0,1
0,1 0,0 1,0"
Positions="-0.5,-0.5,-0.5 -0.5,0.5,-0.5 0.5,0.5,-0.5
0.5,0.5,-0.5 0.5,-0.5,-0.5 -0.5,-0.5,-0.5
"
/>
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<VisualBrush>
<VisualBrush.Visual>
<MediaElement Name="media0" IsMuted="True" LoadedBehavior="Manual" MediaEnded="RestartMedia">
</MediaElement>
</VisualBrush.Visual>
</VisualBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
<!-- Front -->
<GeometryModel3D Transform="{StaticResource CubeMeshTransform2}">
<GeometryModel3D.Geometry>
<MeshGeometry3D
TextureCoordinates="0,1 1,1 1,0
1,0 0,0 0,1
"
Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5
0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5
"
/>
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<VisualBrush>
<VisualBrush.Visual>
<MediaElement Name="media3" IsMuted="True" LoadedBehavior="Manual" MediaEnded="RestartMedia">
</MediaElement>
</VisualBrush.Visual>
</VisualBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
<!-- Bottom -->
<GeometryModel3D Transform="{StaticResource CubeMeshTransform2}">
<GeometryModel3D.Geometry>
<MeshGeometry3D
TextureCoordinates="1,1 0,1 0,0 0,0 1,0 1,1 "
Positions="-0.5,-0.5,-0.5 0.5,-0.5,-0.5 0.5,-0.5,0.5 0.5,-0.5,0.5 -0.5,-0.5,0.5 -0.5,-0.5,-0.5
"
/>
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<VisualBrush>
<VisualBrush.Visual>
<MediaElement IsMuted="True" LoadedBehavior="Manual" MediaEnded="RestartMedia" Name="media4">
</MediaElement>
</VisualBrush.Visual>
</VisualBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
<!-- Right -->
<GeometryModel3D Transform="{StaticResource CubeMeshTransform2}">
<GeometryModel3D.Geometry>
<MeshGeometry3D
TextureCoordinates="0,1 0,0 1,0 1,0 1,1 0,1"
Positions=" 0.5,-0.5,-0.5 0.5,0.5,-0.5 0.5,0.5,0.5 0.5,0.5,0.5 0.5,-0.5,0.5 0.5,-0.5,-0.5
"
/>
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<VisualBrush>
<VisualBrush.Visual>
<MediaElement IsMuted="True" Name="media5" LoadedBehavior="Manual" MediaEnded="RestartMedia">
</MediaElement>
</VisualBrush.Visual>
</VisualBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
<!-- Top -->
<GeometryModel3D Transform="{StaticResource CubeMeshTransform2}">
<GeometryModel3D.Geometry>
<MeshGeometry3D
TextureCoordinates=" 0,0 1,0 1,1 1,1 0,1 0,0"
Positions=" 0.5,0.5,-0.5 -0.5,0.5,-0.5 -0.5,0.5,0.5 -0.5,0.5,0.5 0.5,0.5,0.5 0.5,0.5,-0.5
"
/>
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<VisualBrush>
<VisualBrush.Visual>
<MediaElement IsMuted="True" Name="media6" LoadedBehavior="Manual" MediaEnded="RestartMedia">
</MediaElement>
</VisualBrush.Visual>
</VisualBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
<!-- left -->
<GeometryModel3D Transform="{StaticResource CubeMeshTransform2}">
<GeometryModel3D.Geometry>
<MeshGeometry3D
TextureCoordinates="1,0 1,1 0,1 0,1 0,0 1,0 "
Positions="-0.5,0.5,-0.5 -0.5,-0.5,-0.5 -0.5,-0.5,0.5 -0.5,-0.5,0.5 -0.5,0.5,0.5 -0.5,0.5,-0.5 " />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<VisualBrush>
<VisualBrush.Visual>
<MediaElement IsMuted="True" Name="media2" LoadedBehavior="Manual" MediaEnded="RestartMedia">
</MediaElement>
</VisualBrush.Visual>
</VisualBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
</Model3DGroup.Children>
</Model3DGroup>
<Model3DGroup>
<Model3DGroup.Children>
<AmbientLight Color="#ffcccccc"/>
<DirectionalLight Color="LightGray" Direction="-1,-1,-1" />
</Model3DGroup.Children>
</Model3DGroup>
</Model3DGroup.Children>
需要注意的是,有6个Media元素控件()代表多维数据集的每一面。
答案 0 :(得分:0)
我们不能简单地说uwp中的哪个类与wpf中的System.Window.Media.Model3DGroup
类等效/替换。 wpf中的Model3DGroup
用于将多个3-D模型作为一个单元使用。由于一个ModelVisual3D
只能有一个Model3D
,我们可以通过使用Model3DGroup
构建单个模型并将其设置为ModelVisual3D
元素的内容来组合Model3D对象。 / p>
但是在uwp中,Modelvisual3D
,Model3D
甚至Viewport3D
都不受支持。所以我们不需要Mode3DGroup
类。
实际上哪个课程应该在您的应用中使用取决于您的要求。例如。您想要实现哪些功能。例如,一个关于wpf Rectangle
轮换的简单演示,其中包含Model3DGroup
,如下所示:
<Viewport3D Name="myViewport">
<Viewport3D.Camera>
<PerspectiveCamera
FarPlaneDistance="20"
FieldOfView="45"
LookDirection="5,-2,-3"
NearPlaneDistance="0"
Position="-5,2,3"
UpDirection="0,1,0" />
</Viewport3D.Camera>
<ModelVisual3D x:Name="topModelVisual3D">
<ModelVisual3D.Children>
<ModelVisual3D x:Name="children1">
<ModelVisual3D.Content>
<Model3DGroup>
<GeometryModel3D Geometry="{StaticResource myTeapot}">
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Opacity="1.0" Color="Pink" />
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
<GeometryModel3D.Transform>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D
x:Name="myAngleRotation"
Angle="1"
Axis="0,3,0" />
</RotateTransform3D.Rotation>
</RotateTransform3D>
</GeometryModel3D.Transform>
</GeometryModel3D>
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
</ModelVisual3D.Children>
</ModelVisual3D>
<Viewport3D.Triggers>
<EventTrigger RoutedEvent="Viewport3D.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Duration="0:0:10"
From="0"
RepeatBehavior="Forever"
Storyboard.TargetName="myAngleRotation"
Storyboard.TargetProperty="Angle"
To="360" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Viewport3D.Triggers>
</Viewport3D>
我们可以通过以下代码对uwp产生类似的影响。
<Grid x:Name="ImageGrid" Grid.Row="1">
<Grid.Projection>
<PlaneProjection />
</Grid.Projection>
<Rectangle
x:Name="ImageBlock"
Width="100"
HorizontalAlignment="Center"
Fill="Black"
Stretch="Uniform" Height="100">
<Rectangle.Triggers>
<EventTrigger RoutedEvent="Image.Loaded">
<BeginStoryboard>
<Storyboard x:Name="SpinAnimation">
<DoubleAnimation
Duration="0:0:5"
From="360"
RepeatBehavior="Forever"
Storyboard.TargetName="ImageGrid"
Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)"
To="0" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
</Rectangle>
</Grid>
我认为您需要的指南是uwp中的Draw shapes和Animation。对于复杂的3D图形,请参考Direct3D。