是否可以在WPF中更改3D对象的点? [英] Is it possible to change the points of a 3D object in WPF?
本文介绍了是否可以在WPF中更改3D对象的点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我想知道渲染3D对象后是否可以更改一个或多个点.我使用XAML和C#进行了尝试.
我想使用滑块影响其中之一.这是XAML代码,解释了我如何实现对第一点的Y维的操纵:
Hello,
I wonder if it is possible to change one or more points of a 3D object after it has been rendered. I tried it using XAML and C#.
I want to influence one of the points using a slider. This is the XAML-code that explains how I wanted to achieve a manipulation of the Y-dimension of the first point:
<Grid>
<Viewport3D>
<Viewport3D.Camera>
<PerspectiveCamera Position="0.5, 0.5, 4" LookDirection="0,0,-1"/>
</Viewport3D.Camera>
<Viewport3D.Children>
<ModelVisual3D>
<ModelVisual3D.Content>
<DirectionalLight Color="White" Direction="0,0,-1" />
</ModelVisual3D.Content>
</ModelVisual3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="0, {Binding ElementName=PunktSlider, Path=Value} ,1 , 1,0,1 , 1,1,1 , 0,1,1
0,0,0 , 1,0,0 , 1,1,0 , 0,1,0"
TriangleIndices="0 1 2, 2 3 0,
1 5 6, 6 2 1,
5 4 7, 7 6 5,
4 0 3, 3 7 4,
2 6 7, 7 3 2,
0 4 5, 5 1 0" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Transform>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D Axis="1,1,1" Angle="{Binding ElementName=RotationSlider, Path=Value}" />
</RotateTransform3D.Rotation>
</RotateTransform3D>
</GeometryModel3D.Transform>
<GeometryModel3D.Material>
<DiffuseMaterial Brush="OrangeRed" />
</GeometryModel3D.Material>
</GeometryModel3D>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D.Children>
</Viewport3D>
<Slider x:Name="RotationSlider" Minimum="0" Maximum="360" Value="0"/>
<Slider x:Name="PunktSlider" Minimum="0" Maximum="1" Value="0"/>
</Grid>
有谁知道如何做到这一点?
预先感谢您的每一个想法...
Does anyone have an idea how to do this?
Thanks in advance for every idea...
推荐答案
为什么不呢?您要更改的对象是什么?MeshGeometry3D
?
只需在XAML中为该对象命名,然后以编程方式进行更改即可.
请参阅 http://msdn.microsoft.com/en-us/library /system.windows.media.media3d.meshgeometry3d.aspx [ ^ ].
这篇CodeProject文章介绍了如何操作网格: WPF 3D入门 [
Why not? What is your object you want to change?MeshGeometry3D
?
Just give this object a name in XAML and do the changes programmatically.
See http://msdn.microsoft.com/en-us/library/system.windows.media.media3d.meshgeometry3d.aspx[^].
This CodeProject article explains manipulating mesh: WPF 3D Primer[^].
Have fun!
—SA
这篇关于是否可以在WPF中更改3D对象的点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文