Welcome Guest! To enable all features please Login or Register.



Go to last post Go to first unread
Offline Matasx  
#1 Posted : Saturday, February 22, 2014 6:29:15 PM(UTC)

Joined: 8/30/2013(UTC)
Posts: 43

Thanks: 11 times
Was thanked: 1 time(s) in 1 post(s)
Hi again :)
I've got one more question: is there a simple way to have hierarchy of rendered objects?
For example: I need to have parent Sprite with some position (Center) and Rotation and child sprites. Child sprites should have their position relative to the parent sprite (lets say to parent draw area center) - respecting parent rotation. Is there a simple way to do that?

Here is an image of what I want to achieve without need to manually calculating rotation and position of child sprites.
Render hierarchy

Wanna join the discussion?! Login to your forum accountregister a new account. Or Connect via Facebook Twitter Google

Offline ollimorp  
#2 Posted : Saturday, February 22, 2014 11:06:50 PM(UTC)

Joined: 7/22/2013(UTC)
Posts: 13

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)

this kind of object-hierarchy is called "Scene Graph". For a concrete implementation
you simply use the composite pattern.

Quick overview:
A composite is a container, which represents 1 component (in your case a Sprite) and has a list of further composites.

  • Sprite


As the child-objects have relative coordinates to their parents, you have to link the parent within the child to add the parent´s position with the children positions.


abstract class DrawableComponent 
public Sprite DrawingObject;
public abstract void Add(DrawableComponent)
public abstract Vector2D GetConcreteCoordinates();

class Composite : DrawableComponent
ctor(Composite parent, Sprite spr)
DrawingObject = spr; 
this.Parent = parent;

Composite Parent;

List<DrawableComponent/Sprite> list = new ...

public override void Add(DrawableComponent spr)
{ list.Add(spr); }

public override Vector2D GetConcreteCoordinates()
{ return Parent.Sprite.Center + spr.Center}


Something like that...


Edit: the List-Tag won´t do what I want to do :D ... child2 should be at the same hierarchylevel as child1

Edited by user Saturday, February 22, 2014 11:09:13 PM(UTC)  | Reason: Not specified

Offline Benjamin  
#3 Posted : Tuesday, February 25, 2014 2:35:29 PM(UTC)

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
A user (Santtu) worked on Scene Graph Nodes for the Delta Engine more than 2 years ago. Maybe it is helpful to you:

If support for this is wished we can try to port it, or you do it yourself, or ask Santtu ^^

As ollimorp said it is not that difficult to roll your own Scene Graph.
Rss Feed  Atom Feed
Users browsing this topic
OceanSpiders 2.0
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
This page was generated in 0.058 seconds.