[x3d-public] second release: X3DJSAIL Java translations, javadoc in X3D Examples Archives

Don Brutzman brutzman at nps.edu
Sun Apr 9 14:07:13 PDT 2017


Am happy to report that second release of more than a thousand published X3DJSAIL Java translations for X3D programs is now online in the Web3D Example Archives.

	http://www.web3d.org/specifications/java/X3DJSAIL.html
	http://www.web3d.org/x3d/content/examples/X3dResources.html#Examples

Current support includes Basic Examples, X3dForWebAuthors and X3dForAdvancedModeling archives.  Also included are console logs when building the java versions of each example.

	http://www.web3d.org/x3d/content/examples/Basic (776 Models)
	http://www.web3d.org/x3d/content/examples/Basic/javadoc
	http://www.web3d.org/x3d/content/examples/Basic/build.out.java.txt

	http://x3dgraphics.com/examples/X3dForWebAuthors (260 Models)
	http://x3dgraphics.com/examples/X3dForWebAuthors/javadoc
	http://x3dgraphics.com/examples/X3dForWebAuthors/build.java.out.txt

	http://x3dgraphics.com/examples/X3dForAdvancedModeling (83 Models)
	http://x3dgraphics.com/examples/X3dForAdvancedModeling/javadoc
	http://x3dgraphics.com/examples/X3dForAdvancedModeling/build.java.out.txt

As described in the X3DJSAIL documentation, the archives build process uses the X3dToJava.xslt stylesheet for conversions.  Each index page for each example model has links to corresponding java and javadoc (as well as .x3d .x3dv .json x3dom cobweb html etc. of course) for comparison.

Of note: in addition to compilation, the build process also executes each java version to reveal execution success or executions.  In other words we are *producing unit tests that also test themselves* - pretty cool!  Run-time testing isn't often a part of automated graphics testing, so this appears to be a significant step forward. The capabilities demonstrated by each example really help us with ongoing testing and improvement of X3DJSAIL API and X3D Java programs.  Rephrased: we are certainly finding and fixing a lot of bugs!  The latest greatest bugs can be found in the build logs above.

     X3D Java Scene Access Interface Library (X3DJSAIL)
     http://www.web3d.org/specifications/java/X3DJSAIL.html

A lot of improvements have been made to the X3dToJava.xslt stylesheet as part of debugging efforts - plus a few touchups for X3dToJson.xslt as well.

Let's again look at one model as an example, the BoxSwitch.x3d scene:

     http://x3dgraphics.com/examples/X3dForAdvancedModeling/Animation/BoxSwitchIndex.html
     http://x3dgraphics.com/examples/X3dForAdvancedModeling/Animation/BoxSwitch.java
     http://x3dgraphics.com/examples/X3dForAdvancedModeling/javadoc/index.html?X3dForAdvancedModeling/Animation/BoxSwitch.html
     http://x3dgraphics.com/examples/X3dForAdvancedModeling/Animation/BoxSwitch.json

Console excerpt:
================
C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForAdvancedModeling/Animation/BoxSwitch.java produced from BoxSwitch.x3d
[Large tuple found: PositionInterpolator keyValue, $tupleCount=37, $tupleSplitSize=10, string-length=480]
Compiling 1 source file to C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForAdvancedModeling\classes
now run and validate the java model
java -classpath classes;../../../stylesheets/java/jars/X3DJSAIL.3.3.full.jar;C:\x3d-code\www.web3d.org\x3d\tools\jar/saxon9he.jar X3dForAdvancedModeling.Animation.BoxSwitch
BoxSwitch self-validation test results: success
================

Java coders can look at the main() and validateSelf() methods in the .java source to see how each autogenerated class is internally checking for correctness when run.  Most functionality (such as strong-typing checks for attribute values and allowed child nodes) is built into X3DJSAIL for generality, and the per-scene exemplar code simply shows how to invoke it.

As before, one challenge encountered during this process was the need to rename directories and file names to omit hyphen and period characters - those are not allowed as Java package or class names.  A number of rename fixes were made for Basic archive as well.  Next up is the VRML 2 Sourcebook, lots of renaming is necessary for this to work.  Naming conventions can be found in the X3D Scene Authoring Hints at

     http://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#NamingConventions

As an example of debugging strength, this publishing process revealed a number of utilization problems that are independent of X3DJSAIL codebase itself.  All discovered deficiencies fixed in the converter, no major new bugs have been found on X3DJSAIL, changes are deployed every 1-2 days and checked in steadily, further progress expected.

A table summary of different conversion capabilities (available and planned) is now found at

	http://www.web3d.org/specifications/java/X3DJSAIL.html#Conversions

Finally, have improved documentation further and am highlighting X3dToJava.xslt issues with a TODO subsection on the web page:

====================================
X3DJSAIL: TODO Planned Work
http://www.web3d.org/specifications/java/X3DJSAIL.html#TODO

* Continued testing and improvement with conversion of .x3d source models in the X3D Examples Archive.
* Continued resolution of issue reports on x3d-public at web3d.org mailing list (_archives_).
* Handle too-large initialization methods (greater than 64K compiled) by splitting off arrays portions as separate data structures, when needed, rather than pipelined functional-style instantiations.
* Prototypes: check IS/connect support, improve ProtoInstance handling without needing containerField
====================================

Special thanks still for continuing superlative efforts by John Carlson in testing and debugging this codebase, as well as innovative design patterns for usage.  We'll continue highlighting issues of interest on the x3d-public mail list, those mails represent just a portion of much work going on in the background.

Looking ahead:  "Object Model for X3D (OM4X3D) and Scene Access Interface (SAI) for X3D, including JSONLD and X3DJSAIL" by John, Roy and myself was accepted to the tutorial program of Web3D 2017.  Looking forward to showing people how to use these production-ready X3D codebases there.

	Web3D 2017 Conference
	Brisbane Australia, 3-5 June 2017
	http://web3d2017.web3d.org

So, onward we continue.  Have fun with X3D Java!  8)

all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman
-------------- next part --------------
{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.3",
    "@xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.3.xsd",
    "JSON schema":"http://www.web3d.org/specifications/x3d-3.3-JSONSchema.json",
    "head": {
        "meta": [
          {
            "@name":"title",
            "@content":"BoxSwitch.x3d"
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"30 December 2015"
          },
          {
            "@name":"modified",
            "@content":"1 April 2017"
          },
          {
            "@name":"description",
            "@content":"Demonstrate simple Switch animation by sequencing through a set of Box nodes that are each covered by a different ImageTexture."
          },
          {
            "@name":"MovingImage",
            "@content":"BoxSwitch.mp4"
          },
          {
            "@name":"reference",
            "@content":"../GeometricShapes/CubeWithLabeledSides.x3d"
          },
          {
            "@name":"drawing",
            "@content":"../GeometricShapes/images/CubeSideImages.vsd"
          },
          {
            "@name":"identifier",
            "@content":"http://x3dGraphics.com/examples/X3dForAdvancedModeling/Animation/BoxSwitch.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"07 April 2017"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"warning",
            "@content":"An experimental version of X3D JSON encoding is used for this scene.  Status online at http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-IllegalChildNodeFieldNameNotFound":[
          { "Background":
            {
              "@skyColor":[0.8,0.8,0.9]
            }
          }
        ],
        "-IllegalChildNodeFieldNameNotFound":[
          { "NavigationInfo":
          }
        ],
        "-IllegalChildNodeFieldNameNotFound":[
          { "Switch":
            {
              "@DEF":"BoxSwitcher",
              "@whichChoice":-1,
              "-IllegalChildNodeFieldNameNotFound":[
                { "Shape":
                    "-IllegalChildNodeFieldNameNotFound":[
                      { "Box":
                        {
                          "@DEF":"UnitBox"
                        }
                      }
                    ],
                    "-IllegalChildNodeFieldNameNotFound":[
                      { "Appearance":
                          "-IllegalChildNodeFieldNameNotFound":[
                            { "ImageTexture":
                              {
                                "@url":["../GeometricShapes/images/RedImage.png","http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/RedImage.png"]
                              }
                            }
                          ]
                      }
                    ]
                }
              ],
              "-IllegalChildNodeFieldNameNotFound":[
                { "Shape":
                    "-IllegalChildNodeFieldNameNotFound":[
                      { "Box":
                        {
                          "@USE":"UnitBox"
                        }
                      }
                    ],
                    "-IllegalChildNodeFieldNameNotFound":[
                      { "Appearance":
                          "-IllegalChildNodeFieldNameNotFound":[
                            { "ImageTexture":
                              {
                                "@url":["../GeometricShapes/images/GreenImage.png","http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/GreenImage.png"]
                              }
                            }
                          ]
                      }
                    ]
                }
              ],
              "-IllegalChildNodeFieldNameNotFound":[
                { "Shape":
                    "-IllegalChildNodeFieldNameNotFound":[
                      { "Box":
                        {
                          "@USE":"UnitBox"
                        }
                      }
                    ],
                    "-IllegalChildNodeFieldNameNotFound":[
                      { "Appearance":
                          "-IllegalChildNodeFieldNameNotFound":[
                            { "ImageTexture":
                              {
                                "@url":["../GeometricShapes/images/TurquoiseImage.png","http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/TurquoiseImage.png"]
                              }
                            }
                          ]
                      }
                    ]
                }
              ],
              "-IllegalChildNodeFieldNameNotFound":[
                { "Shape":
                    "-IllegalChildNodeFieldNameNotFound":[
                      { "Box":
                        {
                          "@USE":"UnitBox"
                        }
                      }
                    ],
                    "-IllegalChildNodeFieldNameNotFound":[
                      { "Appearance":
                          "-IllegalChildNodeFieldNameNotFound":[
                            { "ImageTexture":
                              {
                                "@url":["../GeometricShapes/images/YellowImage.png","http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/YellowImage.png"]
                              }
                            }
                          ]
                      }
                    ]
                }
              ],
              "-IllegalChildNodeFieldNameNotFound":[
                { "Shape":
                    "-IllegalChildNodeFieldNameNotFound":[
                      { "Box":
                        {
                          "@USE":"UnitBox"
                        }
                      }
                    ],
                    "-IllegalChildNodeFieldNameNotFound":[
                      { "Appearance":
                          "-IllegalChildNodeFieldNameNotFound":[
                            { "ImageTexture":
                              {
                                "@url":["../GeometricShapes/images/WhiteImage.png","http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/WhiteImage.png"]
                              }
                            }
                          ]
                      }
                    ]
                }
              ],
              "-IllegalChildNodeFieldNameNotFound":[
                { "Shape":
                    "-IllegalChildNodeFieldNameNotFound":[
                      { "Box":
                        {
                          "@USE":"UnitBox"
                        }
                      }
                    ],
                    "-IllegalChildNodeFieldNameNotFound":[
                      { "Appearance":
                          "-IllegalChildNodeFieldNameNotFound":[
                            { "ImageTexture":
                              {
                                "@url":["../GeometricShapes/images/GreyImage.png","http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/GreyImage.png"]
                              }
                            }
                          ]
                      }
                    ]
                }
              ]
            }
          }
        ],
        "-children":[
          {
            "#comment":"Animated Box"
          },
          { "ROUTE":
            {
              "@fromField":"fraction_changed",
              "@fromNode":"Clock",
              "@toField":"set_fraction",
              "@toNode":"Sequencer"
            }
          },
          { "ROUTE":
            {
              "@fromField":"value_changed",
              "@fromNode":"Sequencer",
              "@toField":"whichChoice",
              "@toNode":"BoxSwitcher"
            }
          },
          {
            "#comment":"Animated Viewpoint, orbiting about the origin"
          },
          { "ROUTE":
            {
              "@fromField":"fraction_changed",
              "@fromNode":"Clock",
              "@toField":"set_fraction",
              "@toNode":"CircularPathPositionInterpolator"
            }
          },
          { "ROUTE":
            {
              "@fromField":"value_changed",
              "@fromNode":"CircularPathPositionInterpolator",
              "@toField":"position",
              "@toNode":"OrbitingView"
            }
          },
          { "ROUTE":
            {
              "@fromField":"fraction_changed",
              "@fromNode":"Clock",
              "@toField":"set_fraction",
              "@toNode":"CenterFacingOrientationInterpolator"
            }
          },
          { "ROUTE":
            {
              "@fromField":"value_changed",
              "@fromNode":"CenterFacingOrientationInterpolator",
              "@toField":"orientation",
              "@toNode":"OrbitingView"
            }
          },
          {
            "#comment":"Additional Viewpoints"
          }
        ],
        "-IllegalChildNodeFieldNameNotFound":[
          { "TimeSensor":
            {
              "@DEF":"Clock",
              "@cycleInterval":12,
              "@loop":true
            }
          }
        ],
        "-IllegalChildNodeFieldNameNotFound":[
          { "IntegerSequencer":
            {
              "@DEF":"Sequencer",
              "@key":[0,0.1667,0.3333,0.5,0.6667,0.8333,1],
              "@keyValue":[0,1,2,3,4,5,0]
            }
          }
        ],
        "-IllegalChildNodeFieldNameNotFound":[
          { "Viewpoint":
            {
              "@DEF":"OrbitingView",
              "@description":"Orbiting view",
              "@orientation":[0,1,0,-1.57],
              "@position":[-8,0,0]
            }
          }
        ],
        "-IllegalChildNodeFieldNameNotFound":[
          { "PositionInterpolator":
            {
              "@DEF":"CircularPathPositionInterpolator",
              "@key":[0,0.02778,0.05556,0.08333,0.11111,0.13889,0.16667,0.19444,0.22222,0.25,0.27778,0.30556,0.33333,0.36111,0.38889,0.41667,0.44444,0.47222,0.5,0.52778,0.55556,0.58333,0.61111,0.63889,0.66667,0.69444,0.72222,0.75,0.77778,0.80556,0.83333,0.86111,0.88889,0.91667,0.94444,0.97222,1],
              "@keyValue":[0,0,8,1.389,0,7.878,2.736,0,7.518,4,0,6.928,5.142,0,6.128,6.128,0,5.142,6.928,0,4,7.518,0,2.736,7.878,0,1.389,8,0,0,7.878,0,-1.389,7.518,0,-2.736,6.928,0,-4,6.128,0,-5.142,5.142,0,-6.128,4,0,-6.928,2.736,0,-7.518,1.389,0,-7.878,0,0,-8,-1.389,0,-7.878,-2.736,0,-7.518,-4,0,-6.928,-5.142,0,-6.128,-6.128,0,-5.142,-6.928,0,-4,-7.518,0,-2.736,-7.878,0,-1.389,-8,0,-0,-7.878,0,1.389,-7.518,0,2.736,-6.928,0,4,-6.128,0,5.142,-5.142,0,6.128,-4,0,6.928,-2.736,0,7.518,-1.389,0,7.878,0,0,8]
            }
          }
        ],
        "-IllegalChildNodeFieldNameNotFound":[
          { "OrientationInterpolator":
            {
              "@DEF":"CenterFacingOrientationInterpolator",
              "@key":[0,0.3333,0.6667,1],
              "@keyValue":[0,1,0,0,0,1,0,2.094395,0,1,0,4.18879,0,1,0,0]
            }
          }
        ],
        "-IllegalChildNodeFieldNameNotFound":[
          { "Viewpoint":
            {
              "@description":"Front view",
              "@orientation":[0,1,0,1.57],
              "@position":[8,0,0]
            }
          }
        ],
        "-IllegalChildNodeFieldNameNotFound":[
          { "Viewpoint":
            {
              "@description":"Back view",
              "@orientation":[0,1,0,-1.57],
              "@position":[-8,0,0]
            }
          }
        ],
        "-IllegalChildNodeFieldNameNotFound":[
          { "Viewpoint":
            {
              "@description":"Left view",
              "@position":[0,0,8]
            }
          }
        ],
        "-IllegalChildNodeFieldNameNotFound":[
          { "Viewpoint":
            {
              "@description":"Right view",
              "@orientation":[0,1,0,3.1416],
              "@position":[0,0,-8]
            }
          }
        ],
        "-IllegalChildNodeFieldNameNotFound":[
          { "Viewpoint":
            {
              "@description":"Top view",
              "@orientation":[1,0,0,-1.57],
              "@position":[0,8,0]
            }
          }
        ],
        "-IllegalChildNodeFieldNameNotFound":[
          { "Viewpoint":
            {
              "@description":"Bottom view",
              "@orientation":[1,0,0,1.57],
              "@position":[0,-8,0]
            }
          }
        ]
    }
  }
}
-------------- next part --------------
package X3dForAdvancedModeling.Animation;

/*
Copyright (c) 1995-2017 held by the author(s).  All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer
      in the documentation and/or other materials provided with the
      distribution.
    * Neither the name of the Web3D Consortium (http://www.web3D.org)
      nor the names of its contributors may be used to endorse or
      promote products derived from this software without specific
      prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/

import java.util.*;
import org.web3d.x3d.jsail.Core.*;
import org.web3d.x3d.jsail.EnvironmentalEffects.*;
import org.web3d.x3d.jsail.EventUtilities.*;
import org.web3d.x3d.jsail.fields.*;
import org.web3d.x3d.jsail.Geometry3D.*;
import org.web3d.x3d.jsail.Grouping.*;
import org.web3d.x3d.jsail.Interpolation.*;
import org.web3d.x3d.jsail.Navigation.*;
import org.web3d.x3d.jsail.Shape.*;
import org.web3d.x3d.jsail.Texturing.*;
import org.web3d.x3d.jsail.Time.*;

// Javadoc annotations follow, see below for source.
/**
 * <p> Demonstrate simple Switch animation by sequencing through a set of Box nodes that are each covered by a different ImageTexture. </p>
 <p> Related links: BoxSwitch.java source, <a href="BoxSwitchIndex.html" target="_top">BoxSwitch catalog page</a>, <a href="http://www.web3d.org/x3d/content/examples/X3dResources.html" target="_blank">X3D Resources</a>, <a href="http://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html" target="_blank">X3D Scene Authoring Hints</a> and <a href="http://www.web3d.org/x3d/content/X3dTooltips.html" target="_blank">X3D Tooltips</a>. </p>
	<table style="color:black; border:0px solid; border-spacing:10px 0px;" summary="Scene Metadata">
		<tr style="background-color:silver; border-color:silver;">
			<td style="text-align:center;">meta tags</td>
			<td style="text-align:left;">X3dForAdvancedModeling.Animation.BoxSwitch Scene Metadata </td>
		</tr>

		<tr>
			<td style="text-align:right; vertical-align: text-top;"> title </td>
			<td> <a href="BoxSwitch.x3d">BoxSwitch.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> creator </td>
			<td> Don Brutzman </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> created </td>
			<td> 30 December 2015 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> modified </td>
			<td> 1 April 2017 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> description </td>
			<td> Demonstrate simple Switch animation by sequencing through a set of Box nodes that are each covered by a different ImageTexture. </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> MovingImage </td>
			<td> <a href="BoxSwitch.mp4">BoxSwitch.mp4</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> reference </td>
			<td> <a href="../GeometricShapes/CubeWithLabeledSides.x3d">../GeometricShapes/CubeWithLabeledSides.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> drawing </td>
			<td> <a href="../GeometricShapes/images/CubeSideImages.vsd">../GeometricShapes/images/CubeSideImages.vsd</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> identifier </td>
			<td> <a href="http://x3dGraphics.com/examples/X3dForAdvancedModeling/Animation/BoxSwitch.x3d" target="_blank">http://x3dGraphics.com/examples/X3dForAdvancedModeling/Animation/BoxSwitch.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> generator </td>
			<td> X3D-Edit 3.3, <a href="https://savage.nps.edu/X3D-Edit" target="_blank">https://savage.nps.edu/X3D-Edit</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> license </td>
			<td> <a href="../license.html">../license.html</a> </td>
		</tr>
		<tr> <td colspan="2"> <hr> </td> </tr>
	</table>

	<p>
		This program uses the
		<a href="http://www.web3d.org/specifications/java/X3DJSAIL.html" target="_blank">X3D Java Scene Access Interface Library (X3DJSAIL)</a>.
		It has been produced using the 
		<a href="http://www.web3d.org/x3d/stylesheets/X3dToJava.xslt" target="_blank">X3dToJava.xslt</a>
		stylesheet to create Java source code from an <code>.x3d</code> scene.
	</p>

	 * @author Don Brutzman
 */

public class BoxSwitch
{
  /** Default constructor to create this object. */
  public BoxSwitch ()
  {
    initialize();
  }
	
  /** Create and initialize the X3D model. */
  public final void initialize()
  {
  x3dModel = new X3DObject().setProfile("Immersive").setVersion("3.3")
  .setHead(new headObject()
    .addMeta(new metaObject().setName("title").setContent("BoxSwitch.x3d"))
    .addMeta(new metaObject().setName("creator").setContent("Don Brutzman"))
    .addMeta(new metaObject().setName("created").setContent("30 December 2015"))
    .addMeta(new metaObject().setName("modified").setContent("1 April 2017"))
    .addMeta(new metaObject().setName("description").setContent("Demonstrate simple Switch animation by sequencing through a set of Box nodes that are each covered by a different ImageTexture."))
    .addMeta(new metaObject().setName("MovingImage").setContent("BoxSwitch.mp4"))
    .addMeta(new metaObject().setName("reference").setContent("../GeometricShapes/CubeWithLabeledSides.x3d"))
    .addMeta(new metaObject().setName("drawing").setContent("../GeometricShapes/images/CubeSideImages.vsd"))
    .addMeta(new metaObject().setName("identifier").setContent("http://x3dGraphics.com/examples/X3dForAdvancedModeling/Animation/BoxSwitch.x3d"))
    .addMeta(new metaObject().setName("generator").setContent("X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"))
    .addMeta(new metaObject().setName("license").setContent("../license.html")))
  .setScene(new SceneObject()
    .addChild(new BackgroundObject().setSkyColor(new MFColorObject(new float[] {0.8f,0.8f,0.9f})))
    .addChild(new NavigationInfoObject())
    .addChild(new SwitchObject("BoxSwitcher").setWhichChoice(-1)
      .addChild(new ShapeObject()
        .setGeometry(new BoxObject("UnitBox"))
        .setAppearance(new AppearanceObject()
          .setTexture(new ImageTextureObject().setUrl(new MFStringObject("\"../GeometricShapes/images/RedImage.png\" \"http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/RedImage.png\"")))))
      .addChild(new ShapeObject()
        .setGeometry(new BoxObject().setUSE("UnitBox"))
        .setAppearance(new AppearanceObject()
          .setTexture(new ImageTextureObject().setUrl(new MFStringObject("\"../GeometricShapes/images/GreenImage.png\" \"http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/GreenImage.png\"")))))
      .addChild(new ShapeObject()
        .setGeometry(new BoxObject().setUSE("UnitBox"))
        .setAppearance(new AppearanceObject()
          .setTexture(new ImageTextureObject().setUrl(new MFStringObject("\"../GeometricShapes/images/TurquoiseImage.png\" \"http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/TurquoiseImage.png\"")))))
      .addChild(new ShapeObject()
        .setGeometry(new BoxObject().setUSE("UnitBox"))
        .setAppearance(new AppearanceObject()
          .setTexture(new ImageTextureObject().setUrl(new MFStringObject("\"../GeometricShapes/images/YellowImage.png\" \"http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/YellowImage.png\"")))))
      .addChild(new ShapeObject()
        .setGeometry(new BoxObject().setUSE("UnitBox"))
        .setAppearance(new AppearanceObject()
          .setTexture(new ImageTextureObject().setUrl(new MFStringObject("\"../GeometricShapes/images/WhiteImage.png\" \"http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/WhiteImage.png\"")))))
      .addChild(new ShapeObject()
        .setGeometry(new BoxObject().setUSE("UnitBox"))
        .setAppearance(new AppearanceObject()
          .setTexture(new ImageTextureObject().setUrl(new MFStringObject("\"../GeometricShapes/images/GreyImage.png\" \"http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/GreyImage.png\""))))))
    .addComments(" Animated Box ")
    .addChild(new TimeSensorObject("Clock").setCycleInterval(12).setLoop(true))
    .addChild(new IntegerSequencerObject("Sequencer").setKey(new float[] {0.0f,0.1667f,0.3333f,0.5f,0.6667f,0.8333f,1.0f}).setKeyValue(new int[] {0,1,2,3,4,5,0}))
    .addChild(new ROUTEObject().setFromNode("Clock").setFromField("fraction_changed").setToNode("Sequencer").setToField("set_fraction"))
    .addChild(new ROUTEObject().setFromNode("Sequencer").setFromField("value_changed").setToNode("BoxSwitcher").setToField("whichChoice"))
    .addChild(new ViewpointObject("OrbitingView").setPosition(-8.0f,0.0f,0.0f).setOrientation(0.0f,1.0f,0.0f,-1.57f).setDescription("Orbiting view"))
    .addComments(" Animated Viewpoint, orbiting about the origin ")
    .addChild(new PositionInterpolatorObject("CircularPathPositionInterpolator").setKeyValue(new MFVec3fObject() /* splitting up long array to improve compilability */
.append(new MFVec3fObject(new float[] {0.0f,0.0f,8.0f,1.389f,0.0f,7.878f,2.736f,0.0f,7.518f,4.0f,0.0f,6.928f,5.142f,0.0f,6.128f,6.128f,0.0f,5.142f,6.928f,0.0f,4.0f,7.518f,0.0f,2.736f,7.878f,0.0f,1.389f,8.0f,0.0f,0.0f}))
.append(new MFVec3fObject(new float[] {7.878f,0.0f,-1.389f,7.518f,0.0f,-2.736f,6.928f,0.0f,-4.0f,6.128f,0.0f,-5.142f,5.142f,0.0f,-6.128f,4.0f,0.0f,-6.928f,2.736f,0.0f,-7.518f,1.389f,0.0f,-7.878f,0.0f,0.0f,-8.0f,-1.389f,0.0f,-7.878f}))
.append(new MFVec3fObject(new float[] {-2.736f,0.0f,-7.518f,-4.0f,0.0f,-6.928f,-5.142f,0.0f,-6.128f,-6.128f,0.0f,-5.142f,-6.928f,0.0f,-4.0f,-7.518f,0.0f,-2.736f,-7.878f,0.0f,-1.389f,-8.0f,0.0f,-0.0f,-7.878f,0.0f,1.389f,-7.518f,0.0f,2.736f}))
.append(new MFVec3fObject(new float[] {-6.928f,0.0f,4.0f,-6.128f,0.0f,5.142f,-5.142f,0.0f,6.128f,-4.0f,0.0f,6.928f,-2.736f,0.0f,7.518f,-1.389f,0.0f,7.878f,0.0f,0.0f,8.0f}))).setKey(new float[] {0.0f,0.02778f,0.05556f,0.08333f,0.11111f,0.13889f,0.16667f,0.19444f,0.22222f,0.25f,0.27778f,0.30556f,0.33333f,0.36111f,0.38889f,0.41667f,0.44444f,0.47222f,0.5f,0.52778f,0.55556f,0.58333f,0.61111f,0.63889f,0.66667f,0.69444f,0.72222f,0.75f,0.77778f,0.80556f,0.83333f,0.86111f,0.88889f,0.91667f,0.94444f,0.97222f,1.0f}))
    .addChild(new ROUTEObject().setFromNode("Clock").setFromField("fraction_changed").setToNode("CircularPathPositionInterpolator").setToField("set_fraction"))
    .addChild(new ROUTEObject().setFromNode("CircularPathPositionInterpolator").setFromField("value_changed").setToNode("OrbitingView").setToField("position"))
    .addChild(new OrientationInterpolatorObject("CenterFacingOrientationInterpolator").setKey(new float[] {0.0f,0.3333f,0.6667f,1.0f}).setKeyValue(new MFRotationObject(new float[] {0.0f,1.0f,0.0f,0.0f,0.0f,1.0f,0.0f,2.094395f,0.0f,1.0f,0.0f,4.18879f,0.0f,1.0f,0.0f,0.0f})))
    .addChild(new ROUTEObject().setFromNode("Clock").setFromField("fraction_changed").setToNode("CenterFacingOrientationInterpolator").setToField("set_fraction"))
    .addChild(new ROUTEObject().setFromNode("CenterFacingOrientationInterpolator").setFromField("value_changed").setToNode("OrbitingView").setToField("orientation"))
    .addComments(" Additional Viewpoints ")
    .addChild(new ViewpointObject().setOrientation(0.0f,1.0f,0.0f,1.57f).setPosition(8.0f,0.0f,0.0f).setDescription("Front view"))
    .addChild(new ViewpointObject().setPosition(-8.0f,0.0f,0.0f).setOrientation(0.0f,1.0f,0.0f,-1.57f).setDescription("Back view"))
    .addChild(new ViewpointObject().setPosition(0.0f,0.0f,8.0f).setDescription("Left view"))
    .addChild(new ViewpointObject().setPosition(0.0f,0.0f,-8.0f).setOrientation(0.0f,1.0f,0.0f,3.1416f).setDescription("Right view"))
    .addChild(new ViewpointObject().setPosition(0.0f,8.0f,0.0f).setOrientation(1.0f,0.0f,0.0f,-1.57f).setDescription("Top view"))
    .addChild(new ViewpointObject().setPosition(0.0f,-8.0f,0.0f).setOrientation(1.0f,0.0f,0.0f,1.57f).setDescription("Bottom view")));
  }
  // end of initialize() method
			
  /** The initialized model object, created within initialize() method. */
  private X3DObject x3dModel;
  
  /** Provide a shallow copy of the X3D model.
   * @return BoxSwitch model
   */
  public X3DObject getX3dModel()
  {	  
	  return x3dModel;
  }
  
  /** Indicate X3DJSAIL validation results for this X3D model.
   * @return validation results plus exception information, if any
   */
  public String validateSelf()
  {
	String       metaResult = new String();
	String validationResult = new String();
	String  exceptionResult = new String();
	try
	{
		initialize();
		
		// first list informational meta elements of interest
		for (metaObject meta : getX3dModel().getHead().getMetaList())
		{
			if (meta.getName().equals(metaObject.NAME_ERROR) ||
				meta.getName().equals(metaObject.NAME_WARNING) ||
				meta.getName().equals(metaObject.NAME_HINT) ||
				meta.getName().equals(metaObject.NAME_INFO) ||
				meta.getName().equals(metaObject.NAME_TODO))
			{
				metaResult += meta.toStringX3D();
			}
		}
		validationResult += x3dModel.validate(); // walk entire tree to validate correctness
	}
	catch (Exception e)
	{
		exceptionResult = e.getMessage(); // report exception failures, if any
	}
	if  (metaResult.isEmpty() && exceptionResult.isEmpty() && validationResult.isEmpty())
	     return "success";
	else
	{
		String returnMessage = metaResult;
		if  (!exceptionResult.isEmpty() && !validationResult.isEmpty())
			returnMessage += "\n*** ";
		returnMessage += exceptionResult;
		returnMessage += validationResult;
		return returnMessage;
	}
  }
    /** Default main() method provided for test purposes.
     * @param argv input parameters
     */
    public static void main(String argv[])
    {
		BoxSwitch testObject = new BoxSwitch();
		System.out.println ("BoxSwitch self-validation test results: " + testObject.validateSelf());
	}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BoxSwitch.x3d
Type: model/x3d+xml
Size: 5546 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170409/00db0c72/attachment-0001.x3d>


More information about the x3d-public mailing list