围绕对象wpf的中心旋转摄影机 [英] rotate cammera around center of object wpf

查看:187
本文介绍了围绕对象wpf的中心旋转摄影机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Expression blend使您可以导入3D模型。我想用代码为3d对象设置动画。我似乎无法弄清楚为使对象旋转而必须修改的属性值。让我告诉你我的意思:





因此,如果要旋转该对象,可以使用相机轨道工具



我知道我可以通过创建一个故事板并创建动画宾语。我需要使用滑块沿x轴旋转对象。如果仅修改一个值,它将以一种怪异的方式旋转,如果需要,实际上我必须更改多个属性。例如,当我使用摄影机轨道工具沿x轴旋转对象时,我可以看到所有这些属性正在变化。我需要弄清楚用于旋转对象的算法是什么。

解决方案

移动相机位置以使您看起来像围绕X轴旋转的数学运算只是的参数方程式圆:



/ p>

其中 t 是从零到 2 pi 的角度。



假设您正站在街上看着一所房子。摄像机的坐标必须围绕房屋走一圈,并且纬度和经度不断变化,以保持距房屋相同的距离。因此,没有一个值可以更改以使其旋转。



一旦您知道了相机的位置,方向就是原点和相机位置之间的差。



所有这些都不难计算,但是有一种更简单的方法。相反,保持相机固定并旋转对象。这使动画更加容易。这是MSDN文章,其中包含该方法的示例,包括动画:





这篇文章是为WPF和Visual Studio设计的,但是您可以轻松地将相同的想法应用于Expression Blend。


Expression blend enables you to import 3d models. I want to animate a 3d object with code. I just can't seem to figure out what are the property values that I have to modify in order to make an object rotate. Let me show you what I mean:

so if I want to rotate this object I could use the camera orbit tool and If I use it I can end up with something like:

I know I can create a storyboard and create the animation by modifying the object. I need to rotate the object along the x axis with a slider. If I modify just one value it will rotate in a weird way I actually have to change several properties if I wish to do so. For example when I am rotating the object along the x-axis with the camera orbit tool I can see that all these properties are changing. I need to figure out what is the algorithm being used to rotate the object.

解决方案

The math to move the camera position around so that you appear to be rotating around the X axis is just the parametric equation of a circle:

where t is the angle from zero to 2 pi.

Imagine you are standing on the street looking at a house. The camera's coordinates have to follow a circle around the house and the latitude and longitude are continuously changing to keep the same distance from the house. So there is no one value you can change to make it rotate.

Once you know the camera position, the direction is just the difference between the origin and the camera position.

All this is not hard to calculate but there is an easier way. Instead, keep the camera fixed and rotate the object. This makes animations much easier. Here is an MSDN article contains examples of that approach, including animations:

That article is meant for WPF and Visual Studio but you can easily adapt the same ideas to Expression Blend.

这篇关于围绕对象wpf的中心旋转摄影机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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