instantreality forum
news: Welcome to the instantreality forums!
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 24, 2018, 01:18:50 pm

Login with username, password and session length

Pages: [1]
Author Topic: Exporting Nodes  (Read 1605 times)
Posts: 3

View Profile
« on: January 17, 2013, 02:15:52 pm »

sorry to get on everyones nerves again.
Is there a possibility to get an XML or vrml-string representation of a whole group object with children and fields? I'm trying to export parts of the scene to an x3d file, but it seems i only can get an xml-representation of the actual node, but without children or fields, so in this case of an empty group node. Is there some nice way to do this i missed or do i have to walk the scenegraph and parse all the data?

Just noticed some other stuff and getting very frustrated with the ecma-scripting of instant. Either i'm too stupid, which i don't want to rule out or there are some bugs:
I'm trying to get all the children of a node:
The  X3D-File looks like this:

    <Group DEF='SaveGroup'>
        <Transform translation='1 1 -10'> 
                <Shape DEF='S1'>
                  <Box DEF='Box1' size= '1 1 1'/>
                        <Material DEF='mat1' diffuseColor='0.5 0.5 0.5'/>
             <Transform translation='1 2 -10'>
                <Shape DEF='S2'>
                  <Box DEF='Box2' size= '2 2 2'/>
                        <Material DEF='mat2' diffuseColor='0.7 0.5 0.8'/>
        <TouchSensor DEF='ts'/>

    <Script DEF='FileExporter' url=' "scripts/FileExporter.js" ' mustEvaluate='true' directOutput='true'>
        <field accessType='inputOnly' name='isActive' type='SFBool'/>
    <ROUTE fromNode="ts" fromField="isActive" toNode="FileExporter" toField="isActive"/>

Now i have a FileExporter.js that prints out the nodeStrings to console if i click the group:

function isActive(value){
    if (value == true){
        var node = Browser.currentScene.getNamedNode("SaveGroup");
        var c1=node.getChildren();

the console output is:
<TouchSensor DEF='ts'/>

Why is the length of c1 "0" if it has 2 children, which i can both access?
Tested on V2.2 and latest daily build.

If i change the code from "c1=node.getChildren();" to "c1=node.children;" i get the correct length of "2", but now if  i parse a Shape Node, i don't get the geometry and appearance as array elements, because they are not listed under the children-field "children", but under their own fields, which brings me back to getChildren(), but i can't iterate over the result because i get length=0 even if there are existing elements. Seems parsing the Scenegraph and getting all the elements will be next to impossible.

Sorry for the ranting, but very frustrated at the moment. If its my fault, please excuse this thread and i would be incredibly thankful if you could tell me where the mistakes are or show me more efficient ways of doing things, especially exporting nodes with content from IR to file.

Best regards
« Last Edit: January 17, 2013, 03:25:52 pm by FA55 » Logged
Pages: [1]
Jump to:  

Powered by SMF 1.1.15 | SMF © 2011, Simple Machines