Skip to main content
GameDev.net gamedev.net
🔒 Locked

3d engine design example

Started by littlekid Aug 6, 2005 at 12:46 AM 8 replies 1.2k views
Original Post
littlekid
littlekid
is there any 3d engine class design than is availiable for reference. I am currently trying to create a 3d engine however i can't find a suitable design to link all the classes (3dengine, VertexClass, MeshClass, ParticleClass, etc) together. Or is there a standard way to go about doing such things?
HAM
HAM
Try This
cozman
cozman
Perhaps view the docs for popular engines like OGRE or Irrlicht. Both are Open Source too so you can browse as much of it as you want.

gan
gan
Quote:
Original post by littlekid
is there any 3d engine class design than is availiable for reference.

I am currently trying to create a 3d engine however i can't find a suitable design to link all the classes (3dengine, VertexClass, MeshClass, ParticleClass, etc) together.

Or is there a standard way to go about doing such things?


How can we forget

this?

littlekid
littlekid
Thanks alot people, thoes links were really helpful

Just a small question, where do i put the 'global' variables (LPDIRECT3D9 g_d3d_obj, etc)

do i wrap them like that:

class CEngine{protected:    static LPDIREC3D9       g_d3d_obj;    static LPDIREC3DDEVICE9 g_d3d_device;public:    //functions...};class CEngineRenderer : public CEngine{    //some functions that access g_d3d_obj, g_d3d_device}or just:LPDIREC3D9       g_d3d_obj;LPDIREC3DDEVICE9 g_d3d_device;class CEngine{    //...}class CEngineRenderer{    //...}


[Edited by - littlekid on August 7, 2005 2:51:53 AM]
Mezz
Mezz
I typically do it like this (simplified example):

class Engine{private:   Renderer m_renderer;   // other modules e.g. input, sound etc.public:   Renderer &GetRenderer();};class Renderer{private:   IDirect3DDevice9 *m_device;public:   IDirect3DDevice9 *GetDevice();};


But it's up to you really.

-Mezz
Basiror
Basiror
hm

I wouldn t put all the modules as members into engine base class

i would keep them seperated as singletons

CShaderManager
CSceneGraph
CRenderer
CNetwork

and i would use these single tons as a interface and implement the functionality into a derived class to keep it modular

but thats more or less a personal choice
http://www.8ung.at/basiror/theironcross.html
johnnyBravo
johnnyBravo
Quote:
Original post by Basiror
hm

I wouldn t put all the modules as members into engine base class

i would keep them seperated as singletons

CShaderManager
CSceneGraph
CRenderer
CNetwork

and i would use these single tons as a interface and implement the functionality into a derived class to keep it modular

but thats more or less a personal choice


Just curious, why does everyone always put C in front of their classes?
eg CRender instead of Render?

Also are singletons such a good idea? They do seem kinda messy, right now im just using extern for my classes, eg
render.hclass Render {public:Render();};extern Render render;render.cpp#include "render.h"Render::Render() {}Render render;


Then you can just use render. from anywhere, when using c++.


Quote:
Just a small question, where do i put the 'global' variables (LPDIRECT3D9 g_d3d_obj, etc)


Why isn't that just hidden in your render class, and have functions on the render class eg addVertices,

and sort all the vertices etc inside the render class to be drawn, and have like your entity or monster classes add their own vertices to the render class by themselves?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.