【发布时间】:2012-07-03 16:17:03
【问题描述】:
我正在开发一种类似 DCC 的工具,它具有 3D 视口,您可以用鼠标四处移动,类似于 Maya、Blender 等。
我需要一些数学方面的帮助。
我试图确定两点。第一个是基于目标距离的小车速度。在小尺度上(例如,dist=10^-3),它移动得太快,而在大尺度上(例如,dist=10^6),它移动得太慢。我想要一个平坦的“相机速度”输入,可以整体缩放效果,但在所有比例下,相机都应该感觉相同。不管我是在 0.1 单位还是 1000 单位之外,对于给定的鼠标增量,我应该感觉我正在以相同的速度接近目标。
另一个是相机平移,同样基于相机距离。实际上,我希望相机目标沿着与相机对齐且distance_to_target 单位距离的平面完美地跟踪鼠标光标。我不确定透视失真是否会影响这一点?
输入是:
// Distance in world units to camera's centre of interest
real distance_to_target
// Number of pixels mouse has moved horizontally since last frame
int mouse_delta_x
// Number of pixels mouse has moved vertically since last frame
int mouse_delta_y
// The vector of the mouse delta, normalized into -1 to 1 space based on
// viewport dimensions where a value of (-1,-1) or (1,1) means the cursor
// moved from one corner of the viewport to the other, or further, since
// the last frame.
vec2 mouse_delta_vector
// Scale the dolly speed
real dolly_speed
通常我会根据经验做类似的事情,尝试不同的值,直到找到我喜欢的东西,但为此我认为是时候尝试理论了。
【问题讨论】:
标签: input 3d perspectivecamera