简体   繁体   English

如何重用WPF 3D模型?

[英]How to reuse WPF 3D models?

I am trying to build an app in VS2013+C#+WPF for 3D traffic simulation. 我正在尝试在VS2013 + C#+ WPF中构建一个用于3D交通模拟的应用程序。 My problem is the performance. 我的问题是性能。 With just a 1500 very simple ugly cars the app becomes unusable. 仅使用1500辆非常简单的丑陋汽车,该应用就无法使用。

I guess the reason is that I generate a new 3D model for each car: 我想原因是我为每辆汽车生成了一个新的3D模型:

Auto newAuto = new Auto();
newAuto.model = new ModelBase("car1");

where ModelBase is the function: 其中ModelBase是函数:

public ModelBase(string resourceKey)
        {
            this.Visual3DModel = Application.Current.Resources[resourceKey] as Model3DGroup; 
            this.Visual3DModel.Freeze(); //does not affect on performance for some reason 
        }

and car1.xaml is a car model converted from 3DS using zam3d software. car1.xaml是使用zam3d软件从3DS转换而来的汽车模型。 After converting I tried hard to minimize the number of triangles in it. 转换后,我尽力减少三角形的数量。 That's why the cars are ugly :) 这就是为什么汽车丑陋的原因:)

The question is: how to load the 3D model into graphics memory once and then reuse it? 问题是:如何将3D模型一次加载到图形内存中然后再使用? Or am I doing something wrong? 还是我做错了什么?

please, help! 请帮忙! I have spent soooo much time on it!!! 我花了很多时间!

WPF不适合复杂的场景,您需要切换到OpenGLDirectX

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM