适用于我的 DirectX 游戏引擎的 WPF 世界编辑器
我正在使用 DirectX 用 C++ 开发一个小型游戏和游戏引擎。目的是教育和休闲。
我的下一个目标是构建一个使用游戏引擎的简单世界编辑器。为此,我需要将引擎移至 dll 中,以便游戏和/或编辑器可以使用它。世界编辑器将是一个独立的工具,而不是游戏的一部分。世界编辑器的主要目的是读入并显示我的(自定义)场景文件,并允许我注释/修改世界对象(网格)的属性、克隆对象、拾取和移动对象并放置它们、缩放对象等,然后保存修改后的场景,以便以后游戏可以读取。
有人建议我使用 wxWidgets 作为编辑器。一些研究让我觉得 wxWidgets 有点陈旧和笨重,尽管我确信可以使用它编写非常好的 GUI。这只是一个我不期待的陡峭的学习曲线。我已经获得了要构建和运行的示例,但这很令人头痛。
经过更多研究,我发现可以使用 D3DImage 将 DirectX 集成到 WPF 应用程序中。我对 WPF 做了一些了解,并没有发现它太吓人,而且有很多好书可供参考(wxWidgets 只有一本旧书),以及网络上的大量信息。我已经得到了旋转三角形的例子,它看起来非常简单。
所以我的问题是:
WPF 是否允许我构建一个像样的小世界编辑器应用程序来重用我的游戏引擎?
我的游戏引擎目前使用 RawInput 作为鼠标和键盘;这将如何与 WPF 一起工作?
WPF 如何影响我的消息泵?
看来我必须编写很多函数(外观模式?)才能允许 WPF 与我的游戏引擎交互。有没有一种简单的方法可以将其分解出来,这样它就不会被编译到游戏中?
任何有关如何进行的其他提示或想法将不胜感激!
谢谢。
I am working on a small game and game engine in C++ using DirectX. The purpose is educational & recreational.
My next goal is to build a simple world editor that uses the game engine. For this I will need to move the engine into a dll so it can be consumed by the game and/or by the editor. The world editor will be a stand-alone tool and not part of the game. The main purpose of the world editor will be to read in and display my (custom) scene file, and allow me to annotate/modify properties on world objects (meshes), clone objects, pick up and move objects about and drop them, scale objects, etc., and then save out the modified scene so it can later be read by the game.
It has been recommended that I use wxWidgets for the editor. A bit of research makes me feel that wxWidgets is a bit old and clunky, though I am sure very fine GUIs can be written using it. It's just a steep learning curve that I don't look forward to. I have gotten the samples to build and run, but it was a headache.
A little more research and I find that I can integrate DirectX into a WPF app using a D3DImage. I have done a little with WPF and do not find it too intimidating and there are plenty of good books available (there is only one old one for wxWidgets), as well as scads of information on the web. I have gotten the rotating triangle example working and it seemed pretty straightforward.
So my question is:
Will WPF allow me to build a decent little world editor app that re-uses my game engine?
My game engine currently uses RawInput for mouse and keyboard; how will this work with WPF?
How does WPF affect my message pump?
It looks like I will have to write a lot of functions (facade pattern?) to allow WPF to interact with my game engine. Is there an easy way to factor this out so it doesn't get compiled into the game?
Any other tips or ideas on how to proceed would be greatly appreciated!
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要创建一个包装类来公开游戏的某些功能。
例如。该函数位于我的 C++ 游戏引擎编辑器包装器中。
然后在您的 c# wpf 应用程序中,您可以创建一个静态类,允许您使用这些函数。
您必须通过 dll 拥有用于游戏引擎基本功能的函数。
这样的东西
像EditorMain
渲染帧/更新
DXShutdown
那么你可以在你的 wpf 应用程序构造函数中调用 editormain
你将需要创建一个消息过滤器类并在构造函数中初始化它,
这里是你的消息过滤器类如何寻找
执行 win 表单和 wpf 互操作的方式,请看这里
http://msdn.microsoft.com/en-us/library/ms742474.aspx
You need to create a wrapper class that exposes certain functionality of your game.
For example. This function is in my c++ game engine editor wrapper.
Then in your c# wpf application you can create a static class allowing you to use those functions
You will have to have functions for your basic functionality of the game engine through the dll.
things like
EditorMain
RenderFrame / Update
DXShutdown
So then you can call editormain in your wpf app constructor
You will need to create a message filter class and initialize it in the constructor as well
here's how your message filter class could look
for doing win forms and wpf interop look here
http://msdn.microsoft.com/en-us/library/ms742474.aspx