如何在 WPF 中使用鼠标在 ViewPort3D 中旋转相机?
我能够直接在 XAML 中设置放置在 viewport3d 中的透视相机的位置和方向。 但我想知道如何使用鼠标输入旋转相机。 我更喜欢 C# 语言。 我实际上被困在如何使用鼠标输入旋转相机的问题上。 请帮我。 如果有人给我一个示例代码,那将会很有帮助......
I was able to set the position and direction of the perspective camera placed in the viewport3d directly in XAML.
But i would like to know how can i rotate the camera using the mouse input.
I would prefer C# lang.
I was actually stuck at the point how to rotate the camera using the input of the mouse.
Please help me.
It would be helpful if someone gives me a sample code....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这两个链接可以帮助您很多...
动画 3D 相机的位置WPF
(还有一个示例项目可供尝试!)
旋转带鼠标的相机
我同意 XNA 可能是 3D 情况的最佳解决方案,但本机 3D 支持和硬件加速渲染也是WPF 和 XAML!
正如您所看到的,XAML
Viewport3D
的 3D 相机与应用程序完美契合,还使用绑定:...以及通常的
IValueConverter
实现来让相机移动:I think these two links can help you a lot...
Animating the Position of a 3D Camera in WPF
(there's also a sample project to try!)
Rotating the Camera with the Mouse
I agree that maybe XNA would be the best solution for 3D situations, but native 3D support and hardware-accelerated rendering are also fantastic features of WPF and XAML!
As you can see, a 3D camera for XAML
Viewport3D
fits perfectly with the application, also using bindings:...and just the usual
IValueConverter
implementation to let the camera move:以下扩展方法实现了任意方向的自由飞行投影相机旋转到欧几里得 3D 空间。
键盘和鼠标输入的处理程序
图片来源
Following extension methods implement free flight in any directions & rotations of a projection camera into Euclid 3D space.
Handlers for keyboard and mouse input
The image source