Character class


17-10-2008 06:11:00

Hi, this is kind of a nooby question, I suppose. I'm trying to make a Character class (or an Avatar class). So I created the class and made it inherit from Entity, Easy enough. Well I go to instantiate my new class when I remember that the normal way of creating your entity would be to do this:

Entity ent = sceneMgr.CreateEntity("entity1", "entity1.mesh");

well the flaw in using a class inheriting entity is that this doesn't work.

Avatar ent = sceneMgr.CreateEntity("entity1", "entity1.mesh");

It seems to me that it would be almost essential to have an Avatar class for any game or 3D application. Is what I'm doing not the best way to go?

Thanks, in advance.


17-10-2008 10:31:29

Mogre is a wrapper for Ogre. You simpliy cannot inherit from wrapped classes.
Unfortunately only solution is to wrap the avatar class so it has entity in it.

Bekas once told that maybe it could be possible to inherit from native classes with some modifications to the Mogre wrapper itself, but I suppose he would be more 'on to it' to explain a bit more.

Take care


17-10-2008 17:34:05

Ah, that's quite annoying. Well, thank you for your reply!


17-10-2008 19:02:31

I don't think that, in your particular case, subclassing is what you should be after. Were you intending to override and change the behavior of the Entity class ?

It seems to me that you just want to "tag" it with additional properties. You could set and use the "UserObject" property in Entity.


17-10-2008 19:57:48

^Right, I was planning on adding properties like HitPoints or Damage.

So are you saying I should create my Avatar class and then after creating a new avatar, assigning the UserObject property of Entity to it?

Like so?
Avatar avy = new Avatar(100);
Entity ent1 = sceneMgr.CreateEntity("entity1", "entity1.mesh");
ent.UserObject = avy;


17-10-2008 20:47:11

Yep, exactly.


17-10-2008 21:29:05

Thank you! I have it all working now.