早上好, 我在我的XAML文件中创建了一个3D立方体。
<Viewport3D Margin="4,43,4,-17" MinHeight="200" MinWidth="200" Width="328">
<Viewport3D.Children>
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup x:Name="Cube">
<AmbientLight Color="Gray"/>
<DirectionalLight Color="Gray" Direction="1,-2,-3"/>
<DirectionalLight Color="Gray" Direction="-1,2,-3"/>
<GeometryModel3D x:Name="Vorne">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Blue"/>
</GeometryModel3D.Material>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="1,1,1 -1,1,1 -1,-1,1 1,-1,1"
TriangleIndices="0 1 2 0 2 3"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<GeometryModel3D x:Name="Hinten">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Cyan"/>
</GeometryModel3D.Material>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="-1,-1,-1 -1,1,-1 1,1,-1 1,-1,-1 "
TriangleIndices="0 1 2 0 2 3"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<GeometryModel3D x:Name="Oben">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Red"/>
</GeometryModel3D.Material>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="1,1,-1 -1,1,-1 -1,1,1 1,1,1"
TriangleIndices="0 1 2 0 2 3"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<GeometryModel3D x:Name="Unten">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Magenta"/>
</GeometryModel3D.Material>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="-1,-1,1 1,-1,1 1,-1,-1 -1,-1,-1"
TriangleIndices="3 2 0 2 1 0"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<GeometryModel3D x:Name="Rechts">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Green"/>
</GeometryModel3D.Material>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="1,-1,1 1,-1,-1 1,1,-1 1,1,1"
TriangleIndices="0 1 2 0 2 3 "/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<GeometryModel3D x:Name="Links">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Yellow"/>
</GeometryModel3D.Material>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="-1,-1,1 -1,1,1 -1,1,-1 -1,-1,-1"
TriangleIndices="0 1 2 0 2 3"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<Model3DGroup.Transform>
<Transform3DGroup>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<QuaternionRotation3D x:Name="myQuaternionRotation3D" Quaternion="{Binding Path=Quaternionen,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" />
</RotateTransform3D.Rotation>
</RotateTransform3D>
</Transform3DGroup>
</Model3DGroup.Transform>
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<DirectionalLight x:Name="dirLghtMain" Direction="-1,-0,-2" Color="Gray"></DirectionalLight>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D.Children>
<Viewport3D.Camera>
<PerspectiveCamera Position="2,4,6" LookDirection="-1,-2,-3" UpDirection="0,1,0" FieldOfView="60"></PerspectiveCamera>
</Viewport3D.Camera>
</Viewport3D>
我从传感器到我的应用程序的Quaternions,我想将它们连接到我上面看到的3D立方体。我是否必须创建一个新对象?我尝试了不同的选项,但没有任何效果,我的立方体不旋转。有人得到了解决方案吗?