Jump to content
  • Advertisement
Sign in to follow this  
Tano_ITA

Unity Scene Graph to compose my gameobjects

This topic is 3032 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

Hello,
i've a question about the Scene Graph. I want to create a system that allow you to create Empty GameObjets and later you can "compose" the GameObject with some simple objects like Mesh, Light, Camera. For example:

- Create GameObject "object1"
- Attach Mesh "mesh.x"

So now i've a gameobject composed by two elements: Empty GameObject and a Mesh for render. So when i try to translate it, my engine translate the father node "object1" and his child "mesh.x". (As Unity3D do).

Is that a good idea to manage my game objects? Can i use a Scene Graph system to compose my gameobjects? Have you some document that i can read?

Thanks a lot for you replies, and sorry for my bad english :).

P.S. I'm using C++ and DirectX 9.0.

Share this post


Link to post
Share on other sites
Advertisement
I would suggest making everything traversable in the scene graph of a common base type and then build derived classes based on that type which you can 'attach' or add as child nodes to the parent basic type. Then supply different properties to these derived classes to create the functionality you want to add to the 'father'.

Like this:


class mesh
{
float *vertices[3];
// etc...
};

class game_object
{
// 3d position in space
float pos[3];
};

class game_actor: public game_object
{
// collection of meshes that are rendered
std::vector<Mesh> actor_meshes;
};




These child nodes can inherit certain properties from their 'father' nodes, such as visibility status, world position and orientation etc.




- game_object (x, y, z)
|
- game_actor (x, y, z), (mesh)
|
- game_actor (x, y, z), (mesh)
|

// or a more funky way of looking at it:
- super_spaceship (124.51, 98.124, -32.55)
|
- laser_turret ( 0.1, 0.1, -1), (laser_mesh)
|
- laser_turret (-0.1, 0.1, -1), (laser_mesh)



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!