Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Lestat3D

Is it well done? (Object Hierarchy)

This topic is 6107 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m working on an RPG game on VC++ and DX8, and I would to know if I have to write my own Direct3DRM classes, I''ve started with a hierarchy like as follows (it''s just a diagram): class CCamera { //''Look-at'' Vector //''Up'' Vector //Position Vector //Set-Get Camera Methods } class CCharacter { //CMesh Object //Position Vector //''Look-at'' Vector //Position Vector (Relative to Scenario) //Set-Get Mesh Methods //Animation Methods //Talking Methods //Sounds } class CScenario { //CMesh Objects //Position Methods //CCharacters Collection //CCameras Collection //Set-Get Mesh Methods //Animation Methods //Natural Events Methods } class CCollisionManager { //Information About Coordinates and Meshes //CallBack functions that manages collisions between CCharacters } class CGame { //CMenu Object //CPlayers Collection //CCharacters Collection //... } I want to know if I am doing sonething bad in my objects hierarchy. Tnxs a lot.

Share this post


Link to post
Share on other sites
Advertisement
Looks pretty good

Instead of call-backs you can use observers, and/or interface pointers.

Anything that the collision mangager needs to deal with could support a ''ICollisionObject'' interface, for instance.

Magmai Kai Holmlor
- Not For Rent

Share this post


Link to post
Share on other sites
If you''re familar with Java, they call them ''Listeners''.

  
//In some file

interface ISomeObjectObserver
{
HRESULT OnSomeEvent(ISomeObject* pObj, ...);
}

class CSomeObject : public ISomeObject
{
AddObserver(ISomeObjectObserver* pOb)
{
m_pObserver = pOb;
}
HRESULT SomeEvent()
{
return m_pObserver->OnSomeEvent(this, ...);
}
};

//In some other file

class CMyClass : public ISomeObjectObserver
{
HRESULT OnSomeEvent(ISomeObject* pObj, ...)
{
cout<<"SomeObject ("<<pObj<<") fired SomeEvent"<<endl;
}
};

This decouples the event handling code from the event firing code, which makes it easy to make more classes the can send/receive ISomeObject events via the Observer interface.

Share this post


Link to post
Share on other sites
Thanks a lot for your hints.
Yes, I''m familiarized with java, but I don''t know how to implemet it in VC++, could you help me with it?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!