From: Braden M. <br...@en...> - 2008-08-11 03:19:29
|
Braden McDaniel wrote: > Murashov Gleb wrote: >> >> On Wed, 2008-07-23, Braden McDaniel wrote: >>> node_type::create_node is a rather low-level operation from OpenVRML's >>> perspective. That is not to say that you shouldn't be using it; just >>> be aware that browser::create_vrml_from_stream may be an appropriate >> alternative. >> >> I've used browser::create_vrml_from_stream successfully, but I can't >> understand, which scope got created node. >> >> field_value_listener< mfnode >& fvl_add = >> group_node->event_listener< mfnode >("addChildren"); >> >> std::stringstream sss; >> sss << "DEF main_TS TouchSensor {}"; >> mfnode::value_type nodes_for_mfnode = >> browser.create_vrml_from_stream(sss); >> >> mfnode mfn(nodes_for_mfnode); >> fvl_add.process_event(mfn, 0.0); >> >> ... >> >> node* f_n = root_scope.find_node("main_TS"); >> // f_n == 0 :( >> >> TouchSensor is created and works, but created node doesn't appear in >> root_scope. Where can I find that? Is there any possibility to manage >> this? > > openvrml::scope corresponds to a lexical scope for DEF/USE names. As > such, the nodes created from create_vrml_from_stream have their own root > scope that is distinct from the scene's. The only way to get to this > scope is through a node (i.e., openvrml::node::scope). I was very tired when I wrote the above response. In case it's not clear, you can get the root scope associated with the nodes read from the stream as follows: const openvrml::scope & s = nodes_for_mfnode[0]->scope(); You can then use openvrml::scope::find_node on s as you do with root_scope in the code above. Of course, if all you want is a pointer to main_TS, "nodes_for_mfnode[0]" is a perfectly reasonable way to get it (in this case). -- Braden McDaniel e-mail: <br...@en...> <http://endoframe.com> Jabber: <br...@ja...> |