我编写了一个程序,它以 XAML 格式导入 3d 模型:
<Viewport3D x:Name="ZAM3DViewport3D" ClipToBounds="true" Width="400" Height="300" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/interactivedesigner/2006" xmlns:c="http://schemas.openxmlformats.org/markup-compatibility/2006" c:Ignorable="d">
<Viewport3D.Resources>
<ResourceDictionary>/**other Elements at the same Level**/
<Transform3DGroup x:Key="root_boneOR13TR12" >
<TranslateTransform3D OffsetX="-0" OffsetY="-0" OffsetZ="-0"/>
<ScaleTransform3D ScaleX="1" ScaleY="1" ScaleZ="1"/>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D Angle="90.00000933" Axis="-1 0 0"/>
</RotateTransform3D.Rotation>
</RotateTransform3D>
<TranslateTransform3D OffsetX="-0.00299196" OffsetY="0.00964678" OffsetZ="0.000916864"/>
</Transform3DGroup>
</ResourceDictionary>
</Viewport3D.Resources>
<Viewport3D.Camera>
<PerspectiveCamera x:Name="FrontOR6" FarPlaneDistance="10" LookDirection="0,0,-1" UpDirection="0,1,0" NearPlaneDistance="0.1" Position="0,-0.0439422,0.729628" FieldOfView="39.5978" />
</Viewport3D.Camera>
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup x:Name="Scene" Transform="{DynamicResource SceneTR7}"> <!-- Scene (XAML Path = ) -->
<AmbientLight Color="#646464" />
<DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
<DirectionalLight Color="#FFFFFF" Direction="0.612372,-0.5,-0.612372" />
<Model3DGroup x:Name="rootOR9" Transform="{DynamicResource rootOR9TR8}"> <!-- root (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3]) -->
<Model3DGroup x:Name="glasses_meOR11" Transform="{DynamicResource glasses_meOR11TR10}"> <!-- glasses_me (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[0]) -->
<Model3DGroup x:Name="root_boneOR13" Transform="{DynamicResource root_boneOR13TR12}"> <!-- root_bone (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0]) -->
<Model3DGroup x:Name="main_boneOR15" Transform="{DynamicResource main_boneOR15TR14}"> <!-- main_bone (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0]) -->
</Model3DGroup>
<Model3DGroup x:Name="right_boneOR19" Transform="{DynamicResource right_boneOR19TR18}"> <!-- right_bone (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[1]) -->
<Model3DGroup x:Name="right_bon0OR21" Transform="{DynamicResource right_bon0OR21TR20}"> <!-- right_bon0 (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[1].(Model3DGroup.Children)[0]) -->
</Model3DGroup>
</Model3DGroup>
<Model3DGroup x:Name="left_bone_OR25" Transform="{DynamicResource left_bone_OR25TR24}"> <!-- left_bone_ (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[2]) -->
<Model3DGroup x:Name="left_boneOR27" Transform="{DynamicResource left_boneOR27TR26}"> <!-- left_bone (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[2].(Model3DGroup.Children)[0]) -->
</Model3DGroup>
</Model3DGroup>
</Model3DGroup>
<GeometryModel3D x:Name="glasses_meOR11GR12" Geometry="{DynamicResource glasses_meOR11GR12}" Material="{DynamicResource ER___Default_MaterialMR1}" BackMaterial="{DynamicResource ER___Default_MaterialMR1}"/>
</Model3DGroup>
<Model3DGroup x:Name="glasses_m0OR32" Transform="{DynamicResource glasses_m0OR32TR31}"> <!-- glasses_m0 (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[1]) -->
<Model3DGroup x:Name="root_bone1OR34" Transform="{DynamicResource root_bone1OR34TR33}"> <!-- root_bone1 (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[1].(Model3DGroup.Children)[0]) -->
<Model3DGroup x:Name="main_bone1OR36" Transform="{DynamicResource main_bone1OR36TR35}"> <!-- main_bone1 (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[1].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0]) -->
<Model3DGroup x:Name="main_eff1OR38" Transform="{DynamicResource main_eff1OR38TR37}"> <!-- main_eff1 (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[1].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0]) -->
<Model3DGroup x:Name="right_bon1OR40" Transform="{DynamicResource right_bon1OR40TR39}"> <!-- right_bon1 (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[1].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0]) -->
<Model3DGroup x:Name="right_bon2OR42" Transform="{DynamicResource right_bon2OR42TR41}"> <!-- right_bon2 (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[1].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0]) -->
</Model3DGroup>
</Model3DGroup>
<Model3DGroup x:Name="left_bone0OR46" Transform="{DynamicResource left_bone0OR46TR45}"> <!-- left_bone0 (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[1].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[1]) -->
<Model3DGroup x:Name="left_bone1OR48" Transform="{DynamicResource left_bone1OR48TR47}"> <!-- left_bone1 (XAML Path = (Viewport3D.Children)[0].(ModelVisual3D.Content).(Model3DGroup.Children)[3].(Model3DGroup.Children)[1].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[0].(Model3DGroup.Children)[1].(Model3DGroup.Children)[0]) -->
</Model3DGroup>
</Model3DGroup>
</Model3DGroup>
</Model3DGroup>
</Model3DGroup>
</Model3DGroup>
</Model3DGroup>
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
我想通过 C# 访问 Transform3DGroup x:Key="root_boneOR13TR12" 元素,并希望在需要时修改 AxisAngelRotation 属性。
真诚的,bbklol