简体   繁体   English

是否可以围绕三个轴中的任何一个旋转Viewport3D?

[英]Is it possible to rotate Viewport3D around any of the three axes?

I know that a ModelVisual3D can be rotated around any axis via AxisAngleRotation3D , but is it possible to do the same with Viewport3D that contains 9 ModelVisual3D s, so they are rotated together as if they are one object.. for example I can do this with ModelVisual3D : 我知道一个ModelVisual3D可以通过AxisAngleRotation3D绕任何轴旋转,但是可以对包含9个ModelVisual3D的Viewport3D进行同样的操作,因此它们可以像一个对象一样一起旋转。例如,我可以使用ModelVisual3D

<Viewport3D.Triggers>
       <EventTrigger RoutedEvent="Viewport3D.Loaded">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation 
                  Storyboard.TargetName="myVerticalRotation"
                  Storyboard.TargetProperty="Angle"
                  From="0" To="360" Duration="0:0:10"
                  RepeatBehavior="Forever" />
                            <DoubleAnimation 
                  Storyboard.TargetName="myHorizontalRotation"
                  Storyboard.TargetProperty="Angle"
                  From="0" To="360" Duration="0:0:9"
                  RepeatBehavior="Forever" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Viewport3D.Triggers>

but this presumes that Viewport3D contains only one ModelVisual3D 但这假定Viewport3D仅包含一个ModelVisual3D

Yes, it's possible by containing all GeometryModel3D objects inside a Model3DGroup inside ModelUIElement3D inside ContainerUIElement3D , and then we're able to define the RotateTransform3D in ContainerUIElement3D.Transform : 是的,它可以通过一个包含所有GeometryModel3D一个内部的对象Model3DGroupModelUIElement3DContainerUIElement3D ,然后我们能够定义RotateTransform3DContainerUIElement3D.Transform

 <ContainerUIElement3D>
                    <ModelUIElement3D>
                        <Model3DGroup>
                            <GeometryModel3D>...</GeometryModel3D>
                            <GeometryModel3D>...</GeometryModel3D>
                            <GeometryModel3D>...</GeometryModel3D>
                        </Model3DGroup>
                    </ModelUIElement3D>
                    <ContainerUIElement3D.Transform>
                      <Transform3DGroup>
                        <RotateTransform3D >
                            <RotateTransform3D.Rotation>
                                <AxisAngleRotation3D  x:Name="myHorizontalRotation" Angle="142.884" Axis="0 1 0"/>
                            </RotateTransform3D.Rotation>
                        </RotateTransform3D>
                     </Transform3DGroup>
                   </ContainerUIElement3D.Transform>
            </ContainerUIElement3D>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM