Sadi Tanis wrote:
> Hi!
>
> i'm trying to write a function which stores all nodenames of my loaded
> VRML-Model in an array. For each name i want to assign a KEY/ID so that
> i can access a specific node with it.
> For example:
>
> I have my wooden puppet and want to tell every joint on it how much to
> rotate in x,y and z direction. With an ID i can easily access a node and
> determine the x,y,z values.
>
> At the moment this function
>
> >Action::ResultE enter(NodePtr& node)
> >{
> > if (getName(node))
> > {
> > cout << getName(node) << endl;
> > }
> > else
> > cout << "No name was set!" << endl;
> >
> > return Action::Continue;
> >}
>
> returns all names used in the model on my panel. I want them in an array
> with a key.
> Yesterday I tried the string <map> functionality described in the c++
> stdlib.
That's your best bet if you want to map strings to NodePtrs.
The above function should help you, just do the following instead of cout:
map.insert(std::make_pair(std::string(getName(node)), node));
(Where map is a variable of type std::map<std::string, OSG::NodePtr>)
> Is there also a function in openSG to achieve my goal? I couldn't find any.
No general search for nodes, AFAIK.
I have written my own that traverses a graph and looks for a node based
on names, but if your nodes (and their names) do not change, it is
better to create the map just once.
Note that several nodes can have the same name. There is an integer ID
for each FieldContainer (which is what Node is) and that is unique, so
it might help you if you run into trouble.
Cheers,
/Marcus
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users