Information on 3D Engine
I have been getting more and more emails with questions regarding tips/suggestions involving the creation of an XNA engine and editor; I have copied by response to one such email below to hopefully help answer some of the questions flying around out there.
The initial step to creating my 3D system was to think about what functionality I wanted in the editor; which to me the most important was something that you could easily add different games systems just like you would add components in VS, which is dragging and dropping the component into your scene. Since I had an idea of the basic functionality I wanted I knew that when developing my engine I wanted to make my engine as modular as possible and with that in mind I began development. Now in the editor I did not want to be updating the interface constantly as I was adding components to the engine so I used reflection for listing and creating the components available in the engine in the WinForms interface; this turned out to work amazingly well.
Some hints for making your project reflection friendly:
- Put all your scene components in the same custom namespace; this way you can easily reflect that namespace to get a list of the components which you want available in your editor.
- Make all your scene components have the same constructor; this way you always know what parameters your scene component will be expecting; a good way I found to make this possible is simply have a “resources” class which holds references for all the resources your components could ever need (ie graphics device, base game, etc…) and pass that in the constructor; that way each component can pick and choose what it needs to use.
- When designing your components keep in mind that if you want to use existing WinForms components such as PropertyGridView component you need to properly expose the properties you would like visible through those controls (ie public).
One of the things that I spent the most amount of time on and I am still not nearly finished with is the materials system; this is something that I wanted easily editable and very expandable by the end user. The current system works very well for creating and editing materials but it offers no functionality for changing the materials on the fly on the models (although it could be easily expanded in the future to do this). The reason I bring up the rendering system is because depending on how you structure this system it could be crucial to how you structure your other game systems; getting a good rendering system down to start with will make things easier for you since you will know the parameters to work with when creating your other game systems.
Finally I found that making any “information” class serializable was very good practice for the long run because it enabled me to easily save out scene state information into a “Level” file which was easily deserialized later to get the same level; and with the information released on Shawn Hargreaves blog you could easily setup your classes so when you serialize them all important information is saved and this will simplify things for you a great deal in the long run.
- shawn's blog
- Login or register to post comments
