WPF:如何用图像替换 Viewport3D 中的 3D 对象?
在我的 WPF 应用程序中,我想从 xaml 文件添加多个 3D 对象。但是,如果 viewport3D 中的对象越多,我添加的每个对象的应用程序性能就会变得更差。 由于我只能同时处理一个 3D 对象,我想也许我可以用它们的图像替换我没有使用的 3D 对象,当我尝试与其中一些未使用的对象进行交互时,图像会被替换回其图像原始 3D 对象。
关于如何从 3D 对象获取此位图有什么建议吗?
In my WPF application I want to add multiple 3D objects from xaml files. But if more objects I'm having in viewport3D performance of my application becomes worse with every object I add.
As I can only work with only one 3D object at the same time I thought that maybe I can replace 3D objects that I'm not using with their images and when I try to interact with some of these unused objects image is replaced back with its original 3D object.
Any suggestions on how I can get this bitmap from 3D object?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要能够动态地执行此操作吗?如果没有,您可以渲染对象,截取屏幕截图,然后将相关部分保存为位图。
如果您确实需要能够动态执行此操作,则可以渲染 3D 对象一次并将视图保存为 RenderTargetBitmap,然后在将来使用它。例如 http://www.codeproject.com/Articles/103184/How-to-Render-Bitmap-or-to-Print-a-Visual-in-WPF.aspx
在任何一种情况下,位图都可以应用于一个简单的正方形作为纹理。
Do you need to be able to do it dynamically? If not, you can render the object, take a screenshot and then save the relevant part as a bitmap.
If you do need to be able to do it dynamically, you can render the 3D object once and the save the view as a RenderTargetBitmap and then use that in future. E.g. http://www.codeproject.com/Articles/103184/How-to-Render-Bitmap-or-to-Print-a-Visual-in-WPF.aspx
In either case, the bitmap can then be applied to a simple square as a texture.