[x3d-public] X3DJSAIL. Please compile rubik.x3d to Java and run.

Don Brutzman brutzman at nps.edu
Sat Apr 22 13:04:49 PDT 2017


First a situation report: have had a super busy 2 weeks, can now return to steadily addressing your many great reports and sections.

Also have upgraded both Java and Ant to recently released versions.  Seems to work fine, possibly even a bit faster than before.  Installation configuration details at

	Savage Developers Guide: Ant
	https://savage.nps.edu/Savage/developers.html#Ant

	Savage Developers Guide: Java
	https://savage.nps.edu/Savage/developers.html#Java

On 4/21/2017 8:53 PM, yottzumm at gmail.com wrote:
> Attached X3D file to test (translate to Java, compile, and run).  You may add it to the archives.  It checks out with the schematron.

Very interesting example, thanks for this great offer John.

For the archives, hoping to get a name that is more descriptive of contents.  Perhaps we create a Prototypes section in the Basic archives and call it NestedSpherePrototypes.x3d?  Seems to fit, better name welcome.  This looks like an excellent test example for players.

If OK I will also apply some of the Scene Authoring Hints: Naming Conventions to further aid clarity and understandability for people using it.  This is independent of your version, which gets referenced and remains independently identified, so that you can innovate further without worrying about archives each step of the way.

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

btw got a "JSON parse error line 1" when selecting ppp/Rubik.x3d at http://coderextreme.net/X3DJSONLD/

Of interest: most X3D players are working on this example.  Beyond well-established prototype implementations, am seeing lots of successful prototype results with some happy surprises:

1. BS Contact
2. Cobweb (hooray!)
3. FreeWrl (hooray!)
4. H3DViewer (hooray!)
5. Octaga
6. view3dscene (hooray!)
7. Xj3D

Meanwhile prototype implementation #8 InstantReality only shows 9 spheres, not 27.  Tried sleuthing without success, not sure why... Screen snapshot attached, console follows:

=========================================
LOG	Avalon	 Dispatch Message: reload
LOG	Avalon	 Clear Image/Proto cache
WARNING	Avalon	 Invalid Field name xtranslation in fieldValue
WARNING	Avalon	 Invalid Field name xtranslation in fieldValue
WARNING	Avalon	 Invalid Field name xtranslation in fieldValue
LOG	Avalon	 CDF parsing (0.005s): 631 Node-Types defined
LOG	Avalon	 CDF parsing (0.005s): 631 Node-Types defined
LOG	Avalon	 CDF parsing (0.005s): 631 Node-Types defined
LOG	Avalon	 CDF parsing (0.004s): 631 Node-Types defined
LOG	Avalon	 CDF parsing (0.004s): 631 Node-Types defined
LOG	Avalon	 CDF parsing (0.004s): 631 Node-Types defined
LOG	Avalon	 CDF parsing (0.004s): 631 Node-Types defined
WARNING	Avalon	 sphere without component, cannot unregister
WARNING	Avalon	 three without component, cannot unregister
WARNING	Avalon	 nine without component, cannot unregister
WARNING	Avalon	 twentyseven without component, cannot unregister
=========================================

Looks like I have the latest InstantReality implementation, released last summer.

	Download the instantreality Framework | 2.8.0 release - 27. July 2016
	http://www.instantreality.org/downloads/

Candidate number 9: prototype support yet found in X3DOM.  Last email on this topic that I was able to detect was way back in 2015.  Perhaps X3DOM remains a candidate for your javascript Prototype Expander?

Implementation number 10, nonrendering:  presumably your X3DJSONLD library works on this scene since it has been central to your testing.

Implementation number 11, nonrendering:  mostly complete, but some adjustment is still needed.  X3dToJava.xslt converts and X3DJSAIL builds and compiles satisfactorily, attached.  Still some more work to do on running.  Just finished some major rework on text escaping of javadoc entries.  However still some difficulties restoring a run/debug configuration.

Having fun with X3D Prototypes!  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 --------------
A non-text attachment was scrubbed...
Name: NestedSpherePrototypes.InstantReality.png
Type: image/png
Size: 63956 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170422/07f5607c/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NestedSpherePrototypes.x3d
Type: model/x3d+xml
Size: 4228 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170422/07f5607c/attachment-0001.x3d>
-------------- next part --------------
package Basic.Prototypes;

/*
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.fields.*;
import org.web3d.x3d.jsail.Geometry3D.*;
import org.web3d.x3d.jsail.Grouping.*;
import org.web3d.x3d.jsail.Navigation.*;
import org.web3d.x3d.jsail.Shape.*;

// Javadoc annotations follow, see below for source.
/**
 * <p> Example prototype nesting where three prototype declarations use each other to create multiple spheres, 27 in total. </p>
 <p> Related links: NestedSpherePrototypes.java source, <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; padding:10px 0px;"><i>meta tags</i></td>
			<td style="text-align:left;   padding:10px 0px;">Basic.Prototypes.NestedSpherePrototypes  Document Metadata </td>
		</tr>

		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> title </i> </td>
			<td> <a href="http://coderextreme.net/X3DJSONLD/NestedSpherePrototypes.x3d">NestedSpherePrototypes.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> creator </i> </td>
			<td> John Carlson </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> created </i> </td>
			<td> 11 January 2016 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> translated </i> </td>
			<td> 21 April 2017 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> revised </i> </td>
			<td> 22 April 2017 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> generator </i> </td>
			<td> manual </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> reference </i> </td>
			<td> <a href="http://coderextreme.net/X3DJSONLD/rubik.x3d" target="_blank">http://coderextreme.net/X3DJSONLD/rubik.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> reference </i> </td>
			<td> <a href="https://github.com/coderextreme/X3DJSONLD/blob/master/rubik.x3d" target="_blank">https://github.com/coderextreme/X3DJSONLD/blob/master/rubik.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> identifier </i> </td>
			<td> <a href="http://coderextreme.net/X3DJSONLD/NestedSpherePrototypes.x3d" target="_blank">http://coderextreme.net/X3DJSONLD/NestedSpherePrototypes.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> description </i> </td>
			<td> Example prototype nesting where three prototype declarations use each other to create multiple spheres, 27 in total. </td>
		</tr>
		<tr style="background-color:silver; border-color:silver;">
			<td style="text-align:center;" colspan="2">    </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 John Carlson
 */

public class NestedSpherePrototypes
{
  /** Default constructor to create this object. */
  public NestedSpherePrototypes ()
  {
    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("NestedSpherePrototypes.x3d"))
    .addMeta(new metaObject().setName("creator").setContent("John Carlson"))
    .addMeta(new metaObject().setName("created").setContent("11 January 2016"))
    .addMeta(new metaObject().setName("translated").setContent("21 April 2017"))
    .addMeta(new metaObject().setName("revised").setContent("22 April 2017"))
    .addMeta(new metaObject().setName("generator").setContent("manual"))
    .addMeta(new metaObject().setName("reference").setContent("http://coderextreme.net/X3DJSONLD/rubik.x3d"))
    .addMeta(new metaObject().setName("reference").setContent("https://github.com/coderextreme/X3DJSONLD/blob/master/rubik.x3d"))
    .addMeta(new metaObject().setName("identifier").setContent("http://coderextreme.net/X3DJSONLD/NestedSpherePrototypes.x3d"))
    .addMeta(new metaObject().setName("description").setContent("Example prototype nesting where three prototype declarations use each other to create multiple spheres, 27 in total.")))
  .setScene(new SceneObject()
    .addChild(new NavigationInfoObject().setType(new MFStringObject("\"EXAMINE\"")))
    .addChild(new ViewpointObject().setPosition(0.0f,0.0f,12.0f).setDescription("Rubiks Cube"))
    .addChild(new ProtoDeclareObject().setName("sphere")
      .setProtoInterface(new ProtoInterfaceObject()
        .addField(new fieldObject().setAccessType("inputOutput").setName("xtranslation").setType("SFVec3f").setValue("0.0 0.0 0.0")))
      .setProtoBody(new ProtoBodyObject()
        .addChild(new TransformObject()
          .setIS(new ISObject()
            .setConnect(new connectObject().setNodeField("translation").setProtoField("xtranslation")))
          .addChild(new ShapeObject()
            .setGeometry(new SphereObject())
            .setAppearance(new AppearanceObject()
              .setMaterial(new MaterialObject().setDiffuseColor(1.0f,1.0f,1.0f)))))))
    .addChild(new ProtoDeclareObject().setName("three")
      .setProtoInterface(new ProtoInterfaceObject()
        .addField(new fieldObject().setAccessType("inputOutput").setName("ytranslation").setType("SFVec3f").setValue("0.0 0.0 0.0")))
      .setProtoBody(new ProtoBodyObject()
        .addChild(new TransformObject()
          .setIS(new ISObject()
            .setConnect(new connectObject().setNodeField("translation").setProtoField("ytranslation")))
          .addChild(new ProtoInstanceObject().setName("sphere")
            .addFieldValue(new fieldValueObject().setName("xtranslation").setValue("0 0 0")))
          .addChild(new ProtoInstanceObject().setName("sphere")
            .addFieldValue(new fieldValueObject().setName("xtranslation").setValue("2 0 0")))
          .addChild(new ProtoInstanceObject().setName("sphere")
            .addFieldValue(new fieldValueObject().setName("xtranslation").setValue("-2 0 0"))))))
    .addChild(new ProtoDeclareObject().setName("nine")
      .setProtoInterface(new ProtoInterfaceObject()
        .addField(new fieldObject().setAccessType("inputOutput").setName("ztranslation").setType("SFVec3f").setValue("0.0 0.0 0.0")))
      .setProtoBody(new ProtoBodyObject()
        .addChild(new TransformObject()
          .setIS(new ISObject()
            .setConnect(new connectObject().setNodeField("translation").setProtoField("ztranslation")))
          .addChild(new ProtoInstanceObject().setName("three")
            .addFieldValue(new fieldValueObject().setName("ytranslation").setValue("0 0 0")))
          .addChild(new ProtoInstanceObject().setName("three")
            .addFieldValue(new fieldValueObject().setName("ytranslation").setValue("0 2 0")))
          .addChild(new ProtoInstanceObject().setName("three")
            .addFieldValue(new fieldValueObject().setName("ytranslation").setValue("0 -2 0"))))))
    .addChild(new ProtoDeclareObject().setName("twentyseven")
      .setProtoInterface(new ProtoInterfaceObject()
        .addField(new fieldObject().setAccessType("inputOutput").setName("ttranslation").setType("SFVec3f").setValue("0.0 0.0 0.0")))
      .setProtoBody(new ProtoBodyObject()
        .addChild(new TransformObject()
          .setIS(new ISObject()
            .setConnect(new connectObject().setNodeField("translation").setProtoField("ttranslation")))
          .addChild(new ProtoInstanceObject().setName("nine")
            .addFieldValue(new fieldValueObject().setName("ztranslation").setValue("0 0 0")))
          .addChild(new ProtoInstanceObject().setName("nine")
            .addFieldValue(new fieldValueObject().setName("ztranslation").setValue("0 0 2")))
          .addChild(new ProtoInstanceObject().setName("nine")
            .addFieldValue(new fieldValueObject().setName("ztranslation").setValue("0 0 -2"))))))
    .addChild(new ProtoInstanceObject().setName("twentyseven")
      .addFieldValue(new fieldValueObject().setName("ttranslation").setValue("0 0 0"))));
  }
  // end of initialize() method
			
  /** The initialized model object, created within initialize() method. */
  private X3DObject x3dModel;
  
  /** Provide a shallow copy of the X3D model.
   * @return NestedSpherePrototypes 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();
		
		if ((getX3dModel() == null) || (getX3dModel().getHead() == null))
		{
			validationResult = "empty scene, nothing to validate. " + x3dModel.validate();
			return validationResult;
		}
		// 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;
		if  (exceptionResult.isEmpty() && !validationResult.isEmpty())
			returnMessage = "\n" + returnMessage; // skip line before meta tags, etc.
		returnMessage += validationResult;
		return returnMessage;
	}
  }
    /** Default main() method provided for test purposes.
     * @param argv input parameters
     */
    public static void main(String argv[])
    {
		NestedSpherePrototypes testObject = new NestedSpherePrototypes();
		System.out.println ("NestedSpherePrototypes execution self-validation test results: " + testObject.validateSelf());
	}
}


More information about the x3d-public mailing list