instantreality forum
news: Welcome to the instantreality forums!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
January 16, 2018, 10:31:26 am


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: X3D converter to XHTML  (Read 4389 times)
neiderer
Newbie
*
Posts: 4


View Profile
« on: December 12, 2014, 05:43:21 pm »

I am new to the converter tool.

I have several .x3d that I need to convert to .xhtml to display in
web browser.  In the past I have used BS Contact and Xj3D
viewers with Script node in ECMAScript.  But maybe I need to use
JavaScript instead (?) as the ouput from using the online conversion
tool does not ECMAScript, I think.

I have a simple example below that maybe someone could look at
and offer some guidance.  I will a similiar approach for the several
.x3d that I must convert to .xhtml.

Thank you very much.

Andrew M. Neiderer
US Army Research Laboratory
---------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN"
                     "http://www.web3d.org/specifications/x3d-3.0.dtd">

<X3D profile="Immersive">
  <head/>

  <Scene>
    <Viewpoint description="Start"
               position="0.0 0.0 5.0" centerOfRotation="0.0 0.0 0.0"/>

    <Transform translation="-1.0 0.0 0.0">
      <Shape>
        <Appearance>
          <Material ambientIntensity="0.200"
                    shininess="0.200"
                    diffuseColor="0.0 1.0 0.0"/>
        </Appearance>

        <Sphere radius="0.2"/>
      </Shape>

      <TouchSensor DEF="TOUCH_SENSOR"
                   description="click me to toggle"/>
    </Transform>

    <Switch DEF="SWITCH">
      <Shape>
        <Appearance>
          <Material ambientIntensity="0.200"
                    shininess="0.200"
                    diffuseColor="1.0 0.0 0.0"/>
        </Appearance>

        <Sphere radius="0.2"/>
      </Shape>
    </Switch>

    <!-- turn on/off node of a single node switch-->

    <Script DEF="SCRIPT_toggleSwitch" directOutput="true">
      <field name="switchNode" type="SFNode"
                               accessType="initializeOnly">
        <Switch USE="SWITCH"/>
      </field>

      <field name="toggle"     type="SFTime"
                               accessType="inputOnly"/>
      <![CDATA[ecmascript:
                          function initialize()
                          {
                            Browser.println('initialize() switchNode: ' +
                                             switchNode);
                          }

                          function toggle(dummy)
                          {
                            Browser.println('toggle() on entry, switchNode.
whichChoice: ' +  switchNode.whichChoice);

                            if ( switchNode.whichChoice < 0 ) {
                              switchNode.whichChoice = 0;
                            }
                            else {
                              switchNode.whichChoice = -1;
                            }

                            Browser.println('switchNode: ' +
                                             switchNode);
                            Browser.println('toggle() on exit, switchNode.whichChoice: ' +
                                             switchNode.whichChoice);
                          }
              ]]>
    </Script>

    <ROUTE fromNode="TOUCH_SENSOR"        fromField="touchTime"
           toNode=  "SCRIPT_toggleSwitch" toField=  "toggle"/>
  </Scene>
</X3D>
Logged
mlimper
Administrator
Newbie
*****
Posts: 7


View Profile
« Reply #1 on: December 15, 2014, 04:01:39 pm »

Do you want to use X3DOM?

Or do you still want to use BS Contact (or something else) as a plugin?
In the latter case I guess we cannot really help out.

For X3DOM, conversion using aopt or the online tool should do the job, given that all nodes you need are supported by X3DOM. You might need to replace the X3D script nodes with standard HTML JavaScript script nodes, and the SAI could be slightly different.
Logged
neiderer
Newbie
*
Posts: 4


View Profile
« Reply #2 on: December 16, 2014, 07:13:52 am »

Hi and thank you for the quick reply.

X3DOM!

It is just when I use the code below a sphere appears in my
Mozilla Ff window (on Dell with Linux Mint 16) with the message

"ecmascript: function initialize() { Browser.println('initialize() switchNode: ' + switchNode); } function toggle(dummy) { Browser.println('toggle() on entry, switchNode.whichChoice: ' + switchNode.whichChoice); if ( switchNode.whichChoice < 0 ) { switchNode.whichChoice = 0; } else { switchNode.whichChoice = -1; } Browser.println('switchNode: ' + switchNode); Browser.println('toggle() on exit, switchNode.whichChoice: ' + switchNode.whichChoice); }"

and TouchSensor does not work Sad
Logged
mlimper
Administrator
Newbie
*****
Posts: 7


View Profile
« Reply #3 on: December 18, 2014, 09:43:30 am »

Hi, I just saw you already posted to the X3DOM list, which is great - let's continue discussion there.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2011, Simple Machines