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. 
|
|
|
|
Joined: 7/22/2013(UTC) Posts: 13
Thanks: 1 times Was thanked: 2 time(s) in 2 post(s)
|
Hi, 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. child2 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. Pseudo-Code Code:
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... B.R. ollimorp 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
|
|
|
|
Medals:  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: http://forum.deltaengine...elta-Engine.aspx#post407If 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.
|
|
|
|
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.