dermont
18-05-2007 05:15:42
How do I subclass classes with protected methods and/or variable?. In this instance I'm trying to create a Partilce Affector Factory. For example:
OgreStringInterface
With python-ogre the following test crashes with no createParamDictionary method:
Partilce Affector Factories
I could hack Ogre with methods for the ParticleAffector such as the following:
However, it appears there are so many such instances that obviously I must be doing something wrong.
OgreStringInterface
class _OgreExport StringInterface
{
protected:
/// Class name for this instance to be used as a lookup (must be initialised by subclasses)
String mParamDictName;
bool createParamDictionary(const String& className)
{
mParamDictName = className;
...
With python-ogre the following test crashes with no createParamDictionary method:
class TestStringInterface(ogre.StringInterface):
def __init__(self):
ogre.StringInterface.__init__(self)
self.createParamDictionary("MyTest")
t = TestStringInterface()
#print dir(t.getParamDictionary())
Partilce Affector Factories
ParticleAffectorFactory
----------------------------
class _OgreExport ParticleAffectorFactory
{
protected:
std::vector<ParticleAffector*> mAffectors;
LinearForceAffectorFactory.h
----------------------------
/** See ParticleAffectorFactory */
ParticleAffector* createAffector(ParticleSystem* psys)
{
ParticleAffector* p = new LinearForceAffector(psys);
mAffectors.push_back(p);
return p;
}
class _OgreExport ParticleAffector : public StringInterface
{
protected:
/// Name of the type of affector, MUST be initialised by subclasses
String mType;
I could hack Ogre with methods for the ParticleAffector such as the following:
void pushBackAffector(ParticleAffector* p)
{
mAffectors.push_back(p);
}
ParticleAffector(ParticleSystem* parent, String& name): mParent(parent),mType(name) {}
However, it appears there are so many such instances that obviously I must be doing something wrong.