Sign in to follow this  
Sr_Guapo

Game Design - Few questions

Recommended Posts

Sr_Guapo    876
OK, I am slowly making the switch to unmanged DX and I am starting to make a few basic apps. I understand the basics (most is just learning the function names). Anyways, I had a few questions before I try any larger apps. I have a base class ("Graphics") that controls all the basic DX stuff (device creation, rendering, etc.). I want to make another class that will control any static objects (no animation, just crates and such). I could make a seperate class that controls them and call it from my form, but then there has to be a way to render it through the "graphics" class. Another way would be to control the object class through the graphics class, and just have a few basic functions to expose to the main form. This just seems difficult because everytime I create another feature in the object class, I will need to implement it in the graphics class. Cliff notes: How do you implement the various world objects in your engine? I just want a fairly easy way that won't leave my code looking like my hamster got loose on the keyboard. If you need any more info, feel free to ask.

Share this post


Link to post
Share on other sites
James Trotter    432
You should probably draw a few diagrams of your design, (you might use UML and Dia). Now, since you seem to have to different approaches in your head, draw diagrams of both of them. Stare at the diagrams for a long time, and note down the pros and cons of implementing each of the methods. Then, after some careful thinking it should become apparent which approach is best.

I've seen many (mostly very simple) engines handle all the rendering in each of the objects' classes. This might make for a lot of code duplication, though.
Another way, which in my opinion is far superior, is to have a generic "mesh" class. In this way, each of the static objects are meshes. The meshes are loaded from files, (various formats can be used: .3ds, .obj, or a custom format). This avoids the problem of having loads of duplicate code lying around.

I'm sorry if this doesn't answer everything, but it's quite a big and complicated question, and there are many ways to go about it.

Share this post


Link to post
Share on other sites
Sr_Guapo    876
Quote:
Original post by James Trotter
You should probably draw a few diagrams of your design, (you might use UML and Dia). Now, since you seem to have to different approaches in your head, draw diagrams of both of them. Stare at the diagrams for a long time, and note down the pros and cons of implementing each of the methods. Then, after some careful thinking it should become apparent which approach is best.

I've seen many (mostly very simple) engines handle all the rendering in each of the objects' classes. This might make for a lot of code duplication, though.
Another way, which in my opinion is far superior, is to have a generic "mesh" class. In this way, each of the static objects are meshes. The meshes are loaded from files, (various formats can be used: .3ds, .obj, or a custom format). This avoids the problem of having loads of duplicate code lying around.

I'm sorry if this doesn't answer everything, but it's quite a big and complicated question, and there are many ways to go about it.


The way I have done it in the past (with VB) is to have a class for the object. It contains the mesh, textures, materials, matrix, etc. for that particular object. That design works pretty well for some things, but it also has a number of flaws. Also, unless I make the device global, there isn't a way for me to draw the mesh from the class...

Thanks for the good advice, I will probably try to draw diagram later today. It almost seems silly to draw a diagram for a little project like this, but I guess if I can reuse the code and add on later, it shouldn't be so bad...

Share this post


Link to post
Share on other sites
James Trotter    432
Quote:
Original post by Sr_Guapo
The way I have done it in the past (with VB) is to have a class for the object. It contains the mesh, textures, materials, matrix, etc. for that particular object. That design works pretty well for some things, but it also has a number of flaws. Also, unless I make the device global, there isn't a way for me to draw the mesh from the class...

I'm afraid I haven't had much experience with DirectX, so I'm not much help right here. I'm not familiar with the term device, and don't understand why you need it to render a mesh.

Quote:

Thanks for the good advice, I will probably try to draw diagram later today. It almost seems silly to draw a diagram for a little project like this, but I guess if I can reuse the code and add on later, it shouldn't be so bad...

Each to his own, but I always make diagrams. Even for very small projects. [smile]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this