-
August 6th, 2013, 05:52 AM
#1
How do I change a hierarchy without passing it a root element?
I got a mesh which has an edge with a specific transformation (translation + orientation).
When this configuration/transformation is changed, its neighbours are to be updated.
This structure is kept inside a tree so that when a root "frame" is passed to a method like UpdateHierachy,
the mesh will recursively update itself.
If, I don't pass this method the root element, which is in my case, how do I change the rest of the structure?
The reason to do this is because I want to say move the door, the windows and furniture will move along with it
, get the idea? I think you do..
Thanks
Jack
Last edited by lucky6969b; August 6th, 2013 at 06:20 AM.
-
August 6th, 2013, 08:02 AM
#2
Re: How do I change a hierarchy without passing it a root element?
I guess your "UpdateHierachy" method has to work the same way for every node you pass in, whether it is the root or any other one.
Victor Nijegorodov
-
August 7th, 2013, 12:13 AM
#3
Re: How do I change a hierarchy without passing it a root element?
The thing I am worried about is UpdateHierachy is only able to scan downwards from the top of the tree, and is unable to go back up one level.
-
August 7th, 2013, 01:02 AM
#4
Re: How do I change a hierarchy without passing it a root element?
Why would it need to go up?
While it is true that each of your nodes can have a pointer to its parent (and use it go "up a level"), a trivial tree traverse doesn't need it,
Consider this dfs:
Code:
void Node::UpdateHierachy(const Matrix& transform)
{
UpdateSelf(transform);
for(auto child : m_children)
{
child.UpdateHierachy(transform);
}
}
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames
-
August 7th, 2013, 03:37 AM
#5
Re: How do I change a hierarchy without passing it a root element?
Code:
House
Window
Window Frame
Window Glass
Door
Door Frame
Door Body
If I change the transformation of Door Frame, how can I change the rest of the transformation of the house parts?
Since House and Window cannot be accessed by UpdateHierarchy?
UpdateHierarchy(DoorFrame);
will not update the transformation of other parts of the house.
Thanks
Jack
-
August 7th, 2013, 03:46 AM
#6
Re: How do I change a hierarchy without passing it a root element?
Er... Why should it? This should work in reverse order. When you change the transformation of the door, the handle and other parts should be changed and not vice versa. Why should changing the position of the door, do anything to the position of the house?
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames
-
August 7th, 2013, 05:18 AM
#7
Re: How do I change a hierarchy without passing it a root element?
I have to tell the whole story, mine is a warehouse simulation, when a lorry comes in, it has to park exactly to the location of the dock leveler,
However, this has to be pre-computed where the dock leveler is and work backwards to calculate the position of the truck.
So I got a transformation of the dock leveler, match it to the trailer position, and work backwards to the position of other parts of the truck. Note that some parts of the truck aren't necessarily the children of this trailer, but the parent of it
Last edited by lucky6969b; August 7th, 2013 at 05:26 AM.
-
August 7th, 2013, 04:44 PM
#8
Re: How do I change a hierarchy without passing it a root element?
Originally Posted by lucky6969b
I have to tell the whole story, mine is a warehouse simulation, when a lorry comes in, it has to park exactly to the location of the dock leveler,
So does you application design take in consideration all of your requirements? If it does, then what's the problem? If it doesn't, then you need to redesign your application.
Regards,
Paul McKenzie
-
August 8th, 2013, 01:59 AM
#9
Re: How do I change a hierarchy without passing it a root element?
Originally Posted by lucky6969b
I have to tell the whole story, mine is a warehouse simulation, when a lorry comes in, it has to park exactly to the location of the dock leveler,
However, this has to be pre-computed where the dock leveler is and work backwards to calculate the position of the truck.
So I got a transformation of the dock leveler, match it to the trailer position, and work backwards to the position of other parts of the truck. Note that some parts of the truck aren't necessarily the children of this trailer, but the parent of it
I concur with what others have said: it seems that the control flow of your program is conflicting with the design of your data structure. That is, if the truck is modeled as the parent of the trailer and the trailer does not know about the truck, then it should be the truck that moves the trailer and not the other way round.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|