如何移动带按钮的3D摄像头(Helix Viewport) [英] How Do I Move A 3D Camera With Buttons (Helix Viewport)

查看:344
本文介绍了如何移动带按钮的3D摄像头(Helix Viewport)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试使用单个触摸显示屏上的按钮移动我的3D相机。

为此,我将一个透视相机添加到螺旋视口并绑定其属性。

 <   h:HelixViewport3D.Camera  >  
< PerspectiveCamera

LookDirection = {Binding PerspectiveCamera.LookDirection ,UpdateSourceTrigger = PropertyChanged,Mode = TwoWay}

职位 = {Binding PerspectiveCamera.Position,UpdateSourceTrigger = PropertyChanged,Mode = TwoWay}

UpDirection = {Binding PerspectiveCamera.UpDirection,UpdateSourceTrigger = PropertyChanged,Mode = TwoWay}

/ >
< / h:HelixViewport3D .Camera >





在后面的代码中我更改了这些属性:

  this  .PerspectiveCamera.Position =  new  Point3D(PerspectiveCamera.Position。 X,PerspectiveCamera.Position.Y,perspectiveCamera.Position.Z  -   50 ); 





我的问题是,如果可以使用动画或相机控制器来改变相机的属性。



感谢您的帮助!

解决方案

如果您想使用键盘,除了按钮,

将以下内容添加到HelixViewPort:



 IsMoveEnabled =FalseIsPanEnabled =False IsRotationEnabled =False





在你的按钮上点击左键:

(重复其他按钮, lookdirection an updirection)



 PerspectiveCamera cam =((PerspectiveCamera)h3d.DefaultCamera); 
h3d.Camera.AnimateTo( new Point3D()
{
X = cam.Position.X - ViewPortScale * 2
Y = cam.Position.Y,
Z = cam.Position.Z
},
cam.LookDirection,
cam.UpDirection,
1000 );







您的模型需要某种比例。

(相机必须移动多少)

尝试尝试这个。



  double  ViewPortScale = GetViewPortScale(Visual3DHelper.FindBounds(myModelVisual3D, Transform3D.Identity)); 







  private   double  GetViewPortScale(Rect3D bounds)
{
// 计算轮廓直径
double largestSize = 0 ;
if (bounds.SizeX > largestSize)largestSize = bounds.SizeX;
if (bounds.SizeY > largestSize)largestSize = bounds.SizeY;
if (bounds.SizeZ > largestSize)largestSize = bounds.SizeZ;
ViewPortScale = largestSize / 100 ;
return largestSize / 100 ;
}





 


Hi there, i am trying to move my 3Dcamera with buttons on a single touch display.
For that i added a perspective camera to the helix viewport and bind its properties.

<h:HelixViewport3D.Camera>
                <PerspectiveCamera

                LookDirection="{Binding PerspectiveCamera.LookDirection, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"

                Position="{Binding PerspectiveCamera.Position,  UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"

                UpDirection="{Binding PerspectiveCamera.UpDirection,  UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"

                />
            </h:HelixViewport3D.Camera>



In the code behind i change these properties like that:

this.PerspectiveCamera.Position = new Point3D(PerspectiveCamera.Position.X, PerspectiveCamera.Position.Y, perspectiveCamera.Position.Z - 50);



My question is, if it is possible to use an animation or the camera controller to change the properties of the camera.

Thanks for your help!

解决方案

If you want to use the keyboard, additional to the buttons,
Add the following to your HelixViewPort:

IsMoveEnabled="False" IsPanEnabled="False" IsRotationEnabled="False"



On your button left click:
(repeat for the other buttons, lookdirection an updirection)

PerspectiveCamera cam = ((PerspectiveCamera)h3d.DefaultCamera);
                h3d.Camera.AnimateTo(new Point3D()
                {
                    X = cam.Position.X - ViewPortScale * 2,
                    Y = cam.Position.Y,
                    Z = cam.Position.Z
                },
                   cam.LookDirection,
                   cam.UpDirection,
                1000);




You need some kind of scale for your model.
(How much does the camera have to move)
Try experimenting with this.

double ViewPortScale = GetViewPortScale(Visual3DHelper.FindBounds(myModelVisual3D, Transform3D.Identity));




private double GetViewPortScale(Rect3D bounds)
        {
            //calculate contour diameter
            double biggestSize = 0;
            if (bounds.SizeX > biggestSize) biggestSize = bounds.SizeX;
            if (bounds.SizeY > biggestSize) biggestSize = bounds.SizeY;
            if (bounds.SizeZ > biggestSize) biggestSize = bounds.SizeZ;
            ViewPortScale = biggestSize / 100;
            return biggestSize / 100;
        }




这篇关于如何移动带按钮的3D摄像头(Helix Viewport)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆