General questions about bodies and design

Prophet

04-11-2008 20:14:34

I've been thinking and I've come up with some questions about the Bodies.

Step one is to create your own Body-class. If I want to use Ogre, should I use the basic Body-class? Or should I create a new from inheriting Actor and RenderableSource? Why/Why not?
If I have a Body, and want to add sound to it, can I inherit a Sound-class (say from OgreAL) into the Body? If I use the standard Body-class, can I just make a new Body by inheriting Body and the Sound-class? Should everything using physics go this way? (But different Bodies)

Step two is to create your own RenderableActorFactory. What is the purpose of this? I can't really see it. Since the template-system was implemented, why would I use a RenderableActorFactory? If I pass my own Body as template, what will really change?

So, I kindly ask for some help on these matters.
Thank you in advance.

Notes: Most/all information about this comes from here and so far I know nothing about OgreAL, it was a mere example.

nargil

04-11-2008 20:32:20

1. You can add values to your own body-class: for example hitpoints, mana-points, AI script. You can set multiple graphical meshes to 1 "own body class"
2. Inheriting sound class ? I don't know if its a good idea, but creating an object within - seems fine
3. Factories moving ogre entities/scenenodes, deleting all "own bodies" on scene deletion, maybe stages handling in bloody ?

mcaden

04-11-2008 23:12:10

Without the RenderableActorFactory your custom body won't be able to be created. It creates and destroys your bodies.

reptor

05-11-2008 00:37:37

If you ever want to develop a dedicated server for your game, then you would have to think what is required on a dedicated server and what is not required.

For example, sounds and graphics are definitely not required on a dedicated server. But physics are definitely required.

I think I am going for a more component-based system, in which I do not base my application on Ogre3D or on other libraries but I just use them as components where needed. I am in the design phase so I don't have code to show you. I believe there is some component system topic over at the main forum somewhere, which discusses the subject at least close to what I am thinking of.

I think that by using a more component-like system, I get more flexibility as I have not written the game to be based on some libraries, but it just uses them. I hope that makes sense.

NoodlesOnMyBack

05-11-2008 05:29:46

What i do is to create components as Reptor said, for example, the player character has several components wich makes one unique game object:


GameObject* go = new GameObject("asd");

CMesh* _CMesh = new CMesh(mOgre,this,"ninja.mesh"); //Ticket Collector.mesh
CAnimation* _CAnim = new CAnimation(mOgre);
CCharacter* _CCharacter = new CCharacter(mOgre,mPhys,this,"nin");
CCamera* _CCamera = new CCamera(CCamera::VIEW_THIRD_PERSON_FREE,mOgre);
CPlayerInput* _CPlayerInput = new CPlayerInput(mOgre);
CRender* _CRender = new CRender(mOgre,this,"ninja");
CPosition* _CPos = new CPosition(Vector3(588.064,900.998,988.782));
COrientation* _COrient = new COrientation();

go->setComponent(_CPlayerInput);
go->setComponent(_CRender);
go->setComponent(_CCamera);
go->setComponent(_CCharacter);
go->setComponent(_CAnim);
go->setComponent(_COrient);
go->setComponent(_CPos);
go->setComponent(_CMesh);

go->setup();

addObject(go); //Here the object manager have a container with all go's



Setup method is overriden by the components, so lets say in the CCamera component i have:



void CCamera::setup() {
mCharacter = dynamic_cast<CCharacter*>(getOwnerObject()->getComponent("CCharacter"));
mMesh = dynamic_cast<CMes*>(getOwnerObject()->getComponent("CMesh"));
...


The physics are handled in CCharacter, for regular dynamic actors i use a CActor component, wich should inherit from the RenderableSource.

Prophet

05-11-2008 09:46:42

Yes, I'll be using a component system as well, but I got a bit confused along the way. Which is why I was thinking of inheriting the sound-class together with the Body-class.
Sorry, I forgot the "limitations" of templates. I thought that if I provided a template, it could just use that, regardless.

I'll probably come back to this.
Thanks!

Prophet

06-11-2008 20:32:56

You who do uses a component based system, how do you use your bodies/actors? Inheritance? Has-a-relation?
To take my example again, if you combine body and sound, would you create your new body and include sound? Or the other way around? Or inherit both sound and actor into a new body? (With RenderableActor of course)
Once again, thankful for any tips!