OO Design w/ 3d Engines

Discussion about everything. New games, 3d math, development tips...
Post Reply
shurijo
Posts: 148
Joined: Sat Feb 21, 2004 3:04 am

OO Design w/ 3d Engines

Post by shurijo »

Just a general object oriented design question for the masses...

When you guys develop your 3D apps, do you key it into a specific engine (like Irrlicht)? Or do you use another class(es) (like a indirection, adapter, facade pattern, etc.) so that you could maybe code in another 3D engine to replace Irrlicht?

In my first few Irrlicht programs, I coded in Interfaces in case that I did switch away from Irrlicht to something else, but then I realized it was a little more work than just directly coupling Irrlicht classes, structures into my classes.

Anyways, just wondering what you guys do. I know the best practice is probably not directly couple a specific 3D engine to your app (and use some form of Interface/adapter), but I know that doesn't mean its always done that way.

thanks,
Warchief
Posts: 204
Joined: Tue Nov 22, 2005 10:58 am

Post by Warchief »

Yep, i usually use adapter classes; just interfaces for entity representation.

Example:

Code: Select all

// Adapter
class IAnimatedEntity {

   enum AnimationType { ... };

   void ChangeAnimation( AnimationType ani );

  // ...

};

// Logic class with model
class CPlayer
{
     IAnimatedEntity& m_model;

}

// Irrlicht specific
class CIrrAnimatedEntity : public IAnimatedEntity 
{
  // ...
}
CIrrAnimatedEntity instantiation is provided by abstract factory. Once you build the base for the factory and the interfaces, you can reuse them everywhere.

btw you are not probably going to change the engine during the project, but will be useful for a secuel 8)
buhatkj
Posts: 444
Joined: Fri Dec 12, 2003 4:53 am
Contact:

entities

Post by buhatkj »

i began my first projects by creating my own heirarchal system of entities layered on top of the scenenodes, but i felt like i was just duplicating too much functionality that was already there in the node, so instead i and most people just create custom nodes for anything not native to the engine.
honestly it's hard to see where you would need to swap out irrlicht in favor of something else, irrlicht supports almost anything.
My irrlicht-based projects have gone underground for now, but if you want, check out my webcomic instead! http://brokenboomerang.net
shurijo
Posts: 148
Joined: Sat Feb 21, 2004 3:04 am

Post by shurijo »

Thanks for the feedback.
Post Reply