๐ŸŽ‰ Celebrating 25 Years of GameDev.net! ๐ŸŽ‰

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Attach system design

Started by
3 comments, last by fleabay 1ย year, 11ย months ago

Hi everyone,

I'm designing my attach system and I have some doubts about it. Right now my hierarchy works like this,

I have an Object then from it I create Entity (everything that has an ID, Transform and goes into the scene/world) and also from Object I created a Mesh class, so it's kinda:

- Object (base class)
  - Entity (parent Object)
    - WorldObject (parent Entity)
      - inside it will a ptr to Mesh, ex, Mesh* m_ptrMesh;
    - Actor (parent Entity)
    - Item (parent Entity)
  -Mesh (parent Object)

For example, a tree (WorldObject) will have a model (Mesh) of Sakura_Tree.mdl.

My issue come when I want to attach an entity to another one (like, if I move the parent, all the childs will move), because it would be easy to create some Attachable class and add it to Entity with a list of all the child entities, but what about attaching to bone from models?

Example, if I want to attach an item to the back bone of the model, if the model doens't exist (or I remove it), should I also remove the item? One idea is to attach the item as a โ€œchildโ€ of the Entity that holds the Mesh, and find the bone and given that bone, update the transform. (Attach the item to Actor player entity)

Any thoughts, examples or references about this issue?

Thanks!

Advertisement

Are you familiar with Scene Graphs?

๐Ÿ™‚๐Ÿ™‚๐Ÿ™‚๐Ÿ™‚๐Ÿ™‚<โ†The tone posse, ready for action.

@fleabay No, I've never heard of that, I will google it now, mind telling me more about it? Thanks!

Rewaz said:
I will google it now, mind telling me more about it?

I'll just say that the easiest way to implement a scene graph is for each parented game object to call a getter for its parents current transformations (the parent also having the same getter for it's own transformations, similar to recursion) and applying that to itself to find its current world transformations. I'm sure there are much faster ways but this is a quick way to get something working.

๐Ÿ™‚๐Ÿ™‚๐Ÿ™‚๐Ÿ™‚๐Ÿ™‚<โ†The tone posse, ready for action.

This topic is closed to new replies.

Advertisement