A
anne001
I want to draw a figure with opengl. The key seems to start from a tree
structure.
The top of the tree is the trunk, there are several childrens, head,
upper arms upper legs, each of these have children of their own...
I found a tutorial which explains
Information is stored in nodes which include
pointer to a function that draws the object
matrix which positions, scales and orient this node relative to parent
(including children)
pointer to children of node
typedef struct treenode {
GLfloat m[16]; //transformation - e.g. translation
void *f(); //figure - e.g. Left leg
struct treenode *child;
struct treenode *parent;
} treenode;
What is the OOP ruby way of building a tree? Can it be something like
this? (per Brian Schröder)
class Node
attr_reader :children
def initialize
@children = []
end
end
what goes in @children? the transformation and drawing would be Node
methods I think?
And how do you refer to parent (You need information on the parent to
know where to draw the node)
What do I do with my class Node (called traversing a tree? )
I saw http://raa.ruby-lang.org/search.rhtml?search=tree
that trees are something people think about in ruby. Do any of those
reference have a bearing on my question?
structure.
The top of the tree is the trunk, there are several childrens, head,
upper arms upper legs, each of these have children of their own...
I found a tutorial which explains
Information is stored in nodes which include
pointer to a function that draws the object
matrix which positions, scales and orient this node relative to parent
(including children)
pointer to children of node
typedef struct treenode {
GLfloat m[16]; //transformation - e.g. translation
void *f(); //figure - e.g. Left leg
struct treenode *child;
struct treenode *parent;
} treenode;
What is the OOP ruby way of building a tree? Can it be something like
this? (per Brian Schröder)
class Node
attr_reader :children
def initialize
@children = []
end
end
what goes in @children? the transformation and drawing would be Node
methods I think?
And how do you refer to parent (You need information on the parent to
know where to draw the node)
What do I do with my class Node (called traversing a tree? )
I saw http://raa.ruby-lang.org/search.rhtml?search=tree
that trees are something people think about in ruby. Do any of those
reference have a bearing on my question?