"Mesh" should be an interface or an abstract class?

Started by
31 comments, last by swiftcoder 11 years, 6 months ago
Hello,
I found a book called Game Programming Gems which may look pretty useful.
Will try to grab a copy.
Thanks
Jack
Advertisement

[quote name='Aressera' timestamp='1346921866' post='4977121']
Data-oriented design is basically the process of describing the function of a program in data
N.B. this is "data-driven design", not "data-oriented design". The former is about making data more in control of behaviour rather than code, and the latter is a methodology for writing code that has optimal memory access patterns.
[/quote]

Oops, my mistake. I knew there was a distinction in there but I couldn't put my finger on it.
Could you please show me a standard UML game model? Or any link will do
Thanks
Jack
Lucky, your hierachy is far too deep and complicated imho. I've tried designs like that before over the years, and they always turn into an unsustainable mess. Swiftcoder finally helped me understand how to implement a good data-driven Renderer design, and I haven't looked back since. Listen to his wisdom and it will help you greatly indeed. ;-)
_______________________________________________________________________________
CEO & Lead Developer at ATCWARE™
"Project X-1"; a 100% managed, platform-agnostic game & simulation engine

Please visit our new forums and help us test them and break the ice!
___________________________________________________________________________________
Thanks ATC, I listen to the experts too. I'd like to see some diagrams on how a data-driven system is designed.
:) Yes, I am trying to conform to the standards.
Thanks
Jack
Is this you guys talking about?
http://dundee.cs.queensu.ca/wiki/index.php/CAX_Game_Architecture
In my engine I first made "Mesh" an abstract class. However, I changed it to an interface, "IMesh", a couple weeks ago and it works out better. I just implement new Mesh classes for DirectX10, 11 and OpenGL and let the engine pass around IMesh and IMeshIndexed references... the underlying rendering API and its bindings don't matter, keeping the code weakly/loosely (or not at all) coupled and engine components tidy, clean and easily maintainable. So I say go with an interface-type design. Interfaces are most often badly underused or terribly abused. But find a happy medium and your code will be excellent and almost pain-free to work with!
_______________________________________________________________________________
CEO & Lead Developer at ATCWARE™
"Project X-1"; a 100% managed, platform-agnostic game & simulation engine

Please visit our new forums and help us test them and break the ice!
___________________________________________________________________________________

Is this you guys talking about?
http://dundee.cs.que...me_Architecture

A word to the wise: your life doesn't have to be ruled by UML diagrams and class hierarchies. Formal design process has a place, but it's generally not necessary to be so formal.

A lot of the beauty of data-driven design is in how it simplifies designs:
struct Mesh
{
VertexBuffer *vertices;
IndexBuffer *indices;
};

struct Camera
{
Matrix4 viewMatrix;
Matrix4 projectionMatrix;
};

class IMeshAnimator
{
IMeshAnimator(const Mesh &mesh);
virtual void update(float deltaTime) = 0;
};

class IRenderer // Has OpenGLRenderer and D3DRenderer as subclasses
{
virtual void render(const Mesh &mesh, Matrix4 modelMatrix, const Camera &camera) = 0;
};


Take a look at how conceptually clean this is:
- The Mesh and Camera classes are just pure data containers.
- The MeshAnimator uses composition, instead of inheritance.
- The Renderer just deals with individual render operations.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

That's beauty. Thanks

That's beauty. Thanks


Indeed it is. I hadn't ever been properly exposed to those ideas until I ran into swiftcoder and had a very interesting conversation. The data-driven design really is amazing. Since then I've started reading technical articles on the subject from nVidia, and my questions are becoming less and less frequent/necessary. Have a look at this article when you begin working shaders and materials into your engine/app.
_______________________________________________________________________________
CEO & Lead Developer at ATCWARE™
"Project X-1"; a 100% managed, platform-agnostic game & simulation engine

Please visit our new forums and help us test them and break the ice!
___________________________________________________________________________________

This topic is closed to new replies.

Advertisement