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,
OO Design w/ 3d Engines
Yep, i usually use adapter classes; just interfaces for entity representation.
Example:
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
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
{
// ...
}
btw you are not probably going to change the engine during the project, but will be useful for a secuel
entities
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.
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