Jump to content
  • Advertisement
Sign in to follow this  
Toolmaker

[.net] Developing a simple (re-usable) 3D engine in MDX 9(And some DLL fun)

This topic is 4889 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently reading Managed DirectX 9 Kickstart. It's a pretty good book from my point of view, but I'm currently following the course of the book(Chapter 6, Making the Game) and I want to write some reusable code which I can use later in a game. I'm currently aiming at a simplistic 3D engine which supports: - Simple Camera movement - Encapsulated renderer for managing the device and setting up simple things - Resource management class to load meshes from .X files - Easy way to render models - Standard scene management So, right now, I'm laying out a bit of the classes which I got down to: - Camera (Obvious) - Renderer (Manages the D3D device) - ModelManager (Loads up all the requires models and their textures and hands them out when required). - SceneManager, holds all models/objects in it, and sorts them by x,y,z before rendering them. Now, my question is: How can I keep rendering manageable within the engine? Cough up an (abstract?) Model/Entity class from which all other "game" models are derived and have a standard Render() function? Or have a RenderModel(Model model) inside the Renderer class to do all the rendering? Both have their pro's/con's. And the most important question: I want to shove this code into an DLL, since I want to develop the engine over time and eventually write a real game with it(Not some toy-games to test out the stuff from the book). I know I need to add a new project(.net dll) to my solution and write all the code in there. But how do I reference to my DLL from my game application? Does MSVC automaticly pickup the DLL and add it to the GAC? Or do I have to accomplish this through a specific way? EDIT: Forgot scene management Toolmaker

Share this post


Link to post
Share on other sites
Advertisement
Hi

If you use a .fx file to describe how a model should be rendered, you shou;d only need one [or two, animation can be fun] model classes. Nothing outside of them need really know about how rendering of a model works, in my opinion.

You can have your modelmanager class know how to render models, but it requires that the modelmanager understand the internals of said models... that would appear to be a violation of the encapsulation principle.

Shoving this code into a DLL is definitely the thing to do, and is very easy. .NET removes all the pain associated with DLLs.

Simply write your engine code in one or more .NET Class Library (if using C#) projects. Then, in your main module (using windows forms or some other guvange), do project/Add reference.../Projects/[add your dll projects]. From this point on, it just works. VS.NET will ensure that your dll gets compiled before the exe, and the version that got built against will end up in the same folder as the exe (/bin/release)... As far as I know, the system GAC is not involved at any time.

Share this post


Link to post
Share on other sites
You have to add to the GAC manually with the gacutil.exe (which should be included with Visual Studio), or through an installer such as the setup and deployment project templates in visual studio. Don't forget, you have to create and bind to a strong name key to install your code into the GAC and this can be done with sn.exe which is also included with visual studio.

Share this post


Link to post
Share on other sites
Quote:
Original post by Tape_Worm
You have to add to the GAC manually with the gacutil.exe (which should be included with Visual Studio), or through an installer such as the setup and deployment project templates in visual studio. Don't forget, you have to create and bind to a strong name key to install your code into the GAC and this can be done with sn.exe which is also included with visual studio.

But why stick it in the GAC? As long as it is only being used for his game, there should being any issues keeping it out and just distributing the dll with the rest of the program.

Share this post


Link to post
Share on other sites
Thanks for the replies, as for now, I don't plan on writing alot of games with it, so shoving it into the GAC might be a bit over the top(And polutes it anyway).

About the rendering, although completely nothing to do with .NET interests, what would be "best practice" of doing it? I'm tending to have a Model base-class and derive all my entities from that and have a basic Render() function.

The pro of doing it that way is that you can have models to custom render themself, opposed to a generic Renderer.Render(model).

Is there a performance difference? Perhaps a slightly more function overhead with Model.Render, but that's not an issue. I assume DX batches up everything in between the BeginScene()/EndScene() calls, right?

Toolmaker

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!