Archived

This topic is now archived and is closed to further replies.

dave

I Really Cant Think Of A Good OO Layout For An Engine

Recommended Posts

dave    2187
I recently bought a book that i thought would help me, it didn't, twas a pile of pap. All i really need is a partial on a finished OO engine that i can get some ideas from, Enginuity didnt help at all really, doesnt explain anything. Have searched google, to no avail. can anyone proved some light at the end of a long dark windy tunnel. regards ace [edited by - ace_lovegrove on May 25, 2004 3:06:45 PM]

Share this post


Link to post
Share on other sites
twix    636
If you can''t be bothered to come up with your own ideas, then try perusing the OGRE source.

Share this post


Link to post
Share on other sites
DirectXXX    151
I had same experience but recently i have found that good engine design technincs are derived mostly from software design technincs. After reading tons of software designing resources (and most of them dont make any sense to me) then I looked back at enguinity articles and other game engine design related resources, a big picture was forming like a puzzle but I think it will take time mroe time and exp. to be at home with it.

Share this post


Link to post
Share on other sites
antareus    576
Then don''t make it OO. OO is not a catch-all paradigm. Make it procedural.

Sit down and do it, or you''ll always be caught in object oriented paralysis. You cannot and will not learn if you are afraid to make mistakes.

Share this post


Link to post
Share on other sites
dave    2187
who said i was afraid to make mistakes :S, i been trying different methods for ages. and i post on her to see if anyone thinks this may be a good layout and noone says anything, so no wonder im asking.

Share this post


Link to post
Share on other sites
Codexus    118
My advice is not to try to find the "perfect" OO layout. You need to get started. Identify the objects you think you''re going to use for example views, meshes, cameras and start with that. Think of how you would like to be able to use the engine. For example, it seems one would like to control the camera movement in the same way as the objects movement. So you could make a common base class for them. Keep things as simple as possible and avoid redundant code that way it will be easy to change things as you identify problems or ways to improve your design.
OO programming is really great if you like thinking in an abstract way.

Share this post


Link to post
Share on other sites
antareus    576
No one replies because the question is overly vague. Read How to ask questions the smart way. Your questions are usually essay-type questions that no one wants to sit down and answer. Engenuity is as close as you're going to get to hand-holding; I find it perfectly adequete for describing how to set up an engine.

Also, I don't recommend a game as a first project. There is too much to build.

Edit: also, you never addressed my point about making it procedural for now. You can always refactor duplicated code and switch statements into polymorphic entities. From experience, I have used OO in places where I am now going to go back and rewrite procedurally, because the OO actually hurt the readability of the code.

[edited by - antareus on May 25, 2004 2:17:09 PM]

Share this post


Link to post
Share on other sites
dave    2187
If you read the post u would see that it was hardly vague, i gave brief concise description of how it worked, class names how they link etc...

Share this post


Link to post
Share on other sites
antareus    576
quote:
Original post by ace_lovegrove
If you read the post u would see that it was hardly vague, i gave brief concise description of how it worked, class names how they link etc...

Show me. I re-read this whole thread.

Share this post


Link to post
Share on other sites
MumbleFuzz    188
Could you elaborate a bit more? Are there any specific parts of the engine you're stuck with? The scene graph or renderer for example? I'm facing similar problems myself at the moment, but I find with each rewrite, my engine becomes closer to being finished. It just takes perseverence.

edit:
Sorry, let me rephrase that. Are there any specific parts of the engine you aren't sure how to write in an OO way?

[edited by - MumbleFuzz on May 25, 2004 2:29:43 PM]

Share this post


Link to post
Share on other sites
dave    2187
Im not entirely sure how different parts of the engine link together regarding classes and the instances, objects, methods like inheritance and polymorphism (i know how these work BTW). Methods for having it Finite-State like in operation. Im trying to obey the diagram that was presented in the Enginuity article and im having trouble trying to contrive a concept for how different parts work. I have already created a simple engine, just a renderer though, which is basically a kernel that once having initialised the main window calls a TaskManager class every frame. The Task Manager then controls the states the engine lies in, ie playing, paused etc. In order to use the engine you have to create an inherited class from the kernel. I am having problems with overriding methods within the other base classes.

PS thanc fort he kind help MumbleFuzz

regards

ace

Share this post


Link to post
Share on other sites
markr    1692
Go and read some source code - there is plenty out there.

There are a lot of open source games. There are some commercial games which have since released their source into the public domain.

Note that these won't necessarily be model examples of how to do things.

I wrote a game in a weekend last year (for a compo); it wasn't very good but provides an example of how to do polymorphic OO with a manager (which is procedural).

http://www.vectrex.org.uk/aotmj/

None of these are necessarily very good, but you will see a way of doing things.

NB: To build this code on some versions of VC, you may need to change some compiler options from their defaults. Specifically, I use RTTI and assume correct for() scope.

Mark

[edited by - markr on May 25, 2004 4:01:05 PM]

Share this post


Link to post
Share on other sites
RolandofGilead    100
quote:
Original post by Codexus
My advice is not to try to find the "perfect" OO layout. You need to get started. Identify the objects you think you''re going to use for example views, meshes, cameras and start with that. Think of how you would like to be able to use the engine. For example, it seems one would like to control the camera movement in the same way as the objects movement. So you could make a common base class for them. Keep things as simple as possible and avoid redundant code that way it will be easy to change things as you identify problems or ways to improve your design.
OO programming is really great if you like thinking in an abstract way.


What he said but don''t necessarily start with the OO way to do things. Once you write down some things you want your engine to be able to do, you''ll notice certain themes and you''ll be able to come up with a solution that will work for a number of features(templates are your friend and work marvelously for a procedural style). Maybe you should even start with solutions and see what can be solved by them.

Share this post


Link to post
Share on other sites
MumbleFuzz    188
I probably won''t be a great help to you, as I''m still experimenting with different methods myself. However, a few points to keep in mind...

1. I found most of my difficulties came from trying to keep the Windows related code away from the rest of the engine (parts such as the renderer). Once you''ve got the Windows and GL/DX initialization in place, the rest should fall into place quite nicely.

2. I think the Enginuity article treated the Video Task (including window initialization) and Renderer as one and the same. I found it much easier to keep the renderer separate, partly because of the reasons mentioned above.

3. While OO stuff is great, don''t underestimate the flexibility you can get with a simple procedural engine. I think Quake 3 was written in C alone, for example, and that''s powered some great games over the years.

You can create an engine without any OO parts. OO is simply a tool to make your coding easier; only use it if it''ll do this.

Share this post


Link to post
Share on other sites