top of page

Scenegraph!

  • Writer: Pablo Narvaja
    Pablo Narvaja
  • Oct 10, 2019
  • 1 min read

What is a scenegraph and why is it useful?


Child object following parent object rotation

A scenegraph is a data structure, often a kd-tree, that represent parent-children relationships between objects, is useful to make easy to keep track of every relationship (generally there is thousands of them) so often every frame the tree update all world transforms of the objects.


First I did a templated kd-tree with it's nodes consisting of:

  • parent

  • children array

  • local transform

  • world transform

And it gave me heap problems sometimes, I couldn't figure it out for like 2 weeks and then realize that I was allocating memory for the base node instead for the template.

This structure is good to make cpu skeletal animation or that i think since is easy to implement.


Transform Component

Later on I tried to implement entity-component-system system but it get really complicated and i wanted to get into physics so I decided to use a library, I choosed Sam Bloomberg's ECS library because is single header and easy to use. When I make my own implementation I will post a dedicated article about ECS.


So now I changed the scenegraph structure from a kd-tree to a System.

I thing to have in mind when setting the local transform of a child is:


local_transform = parent_transform.inverse() * world_transform

I remember this because is a common mistake to do when setting the child transform.


That's all for this post, folk. Bye!

Comments


  • facebook
  • linkedin
  • youtube
  • generic-social-link
  • Grey LinkedIn Icon
  • Facebook
  • YouTube

2019 Pablo Narvaja. Llamathrust GameEngine

bottom of page