package Savage.AircraftFixedWing.F18BlueAngelUnitedStates;

import org.web3d.x3d.jsail.Core.*;
import org.web3d.x3d.jsail.EnvironmentalEffects.*;
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.Networking.*;
import org.web3d.x3d.jsail.Rendering.*;
import org.web3d.x3d.jsail.Scripting.*;
import org.web3d.x3d.jsail.Shape.*;
import org.web3d.x3d.jsail.Text.*;
import org.web3d.x3d.jsail.Time.*;

// Javadoc metadata annotations follow, see below for X3DJSAIL Java source code.
/**
 * <p> This prototype performs canopy opening and closing. </p>
 <p> Related links: Catalog page <a href="../../../../AircraftFixedWing/F18BlueAngelUnitedStates/CanopyPrototypeIndex.html" target="_blank">CanopyPrototype</a>,  source <a href="../../../../AircraftFixedWing/F18BlueAngelUnitedStates/CanopyPrototype.java">CanopyPrototype.java</a>, <a href="https://www.web3d.org/x3d/content/examples/X3dResources.html" target="_blank">X3D Resources</a>, <a href="https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html" target="_blank">X3D Scene Authoring Hints</a>, and <a href="https://www.web3d.org/x3d/content/X3dTooltips.html" target="_blank">X3D Tooltips</a>. </p>
	<table style="color:black; border:0px solid; border-spacing:10px 0px;">
        <caption>Scene Meta Information</caption>
		<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;">&nbsp; Document Metadata </td>
		</tr>

		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> title </i> </td>
			<td> <a href="../../../../AircraftFixedWing/F18BlueAngelUnitedStates/CanopyPrototype.x3d">CanopyPrototype.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> description </i> </td>
			<td> This prototype performs canopy opening and closing. </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> creator </i> </td>
			<td> Etsuko Lippi </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> created </i> </td>
			<td> 18 October 2001 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> modified </i> </td>
			<td> 28 November 2019 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> reference </i> </td>
			<td> <a href="https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/BlueAngelCanopy.jpg" target="_blank">https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/BlueAngelCanopy.jpg</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> reference </i> </td>
			<td> <a href="http://www.military.com/Content/MoreContent1?file=aboutba" target="_blank">http://www.military.com/Content/MoreContent1?file=aboutba</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> identifier </i> </td>
			<td> <a href="https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/CanopyPrototype.x3d" target="_blank">https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/CanopyPrototype.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> generator </i> </td>
			<td> X3D-Edit 3.2, <a href="https://www.web3d.org/x3d/tools/X3D-Edit" target="_blank">https://www.web3d.org/x3d/tools/X3D-Edit</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> subject </i> </td>
			<td> canopy opening and closing, Prototype </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> license </i> </td>
			<td> <a href="../../../../AircraftFixedWing/F18BlueAngelUnitedStates/../../license.html">../../license.html</a> </td>
		</tr>
		<tr style="background-color:silver; border-color:silver;">
			<td style="text-align:center;" colspan="2">  &nbsp; </td>
		</tr>
	</table>

	<p>
		This program uses the
		<a href="https://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="https://www.web3d.org/x3d/stylesheets/X3dToJava.xslt" target="_blank">X3dToJava.xslt</a>
		stylesheet
	       (<a href="https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/X3dToJava.xslt" target="_blank">version control</a>)
                which is used to create Java source code from an original <code>.x3d</code> model.
	</p>

	* @author Etsuko Lippi
 */

public class CanopyPrototype
{
	/** Default constructor to create this object. */
	public CanopyPrototype ()
	{
	  initialize();
	}

	/** Create and initialize the X3D model for this object. */
	public final void initialize()
	{
            try { // catch-all
  x3dModel = new X3D().setProfile(X3D.PROFILE_IMMERSIVE).setVersion(X3D.VERSION_3_0)
  .setHead(new head()
    .addMeta(new meta().setName(meta.NAME_TITLE      ).setContent("CanopyPrototype.x3d"))
    .addMeta(new meta().setName(meta.NAME_DESCRIPTION).setContent("This prototype performs canopy opening and closing."))
    .addMeta(new meta().setName(meta.NAME_CREATOR    ).setContent("Etsuko Lippi"))
    .addMeta(new meta().setName(meta.NAME_CREATED    ).setContent("18 October 2001"))
    .addMeta(new meta().setName(meta.NAME_MODIFIED   ).setContent("28 November 2019"))
    .addMeta(new meta().setName(meta.NAME_REFERENCE  ).setContent("https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/BlueAngelCanopy.jpg"))
    .addMeta(new meta().setName(meta.NAME_REFERENCE  ).setContent("http://www.military.com/Content/MoreContent1?file=aboutba"))
    .addMeta(new meta().setName(meta.NAME_IDENTIFIER ).setContent("https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/CanopyPrototype.x3d"))
    .addMeta(new meta().setName(meta.NAME_GENERATOR  ).setContent("X3D-Edit 3.2, https://www.web3d.org/x3d/tools/X3D-Edit"))
    .addMeta(new meta().setName(meta.NAME_SUBJECT    ).setContent("canopy opening and closing, Prototype"))
    .addMeta(new meta().setName(meta.NAME_LICENSE    ).setContent("../../license.html")))
  .setScene(new Scene()
    .addChild(new WorldInfo().setTitle("CanopyPrototype.x3d"))
    .addChild(new ProtoDeclare("Canopy").setName("Canopy")
      .setProtoInterface(new ProtoInterface()
        .addField(new field().setName("canopyOpen").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("boolean eventIn: true = canopy open false = canopy close."))
        .addField(new field().setName("animationStartTime").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_INPUTONLY))
        .addField(new field().setName("canopyOut").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
        .addField(new field().setName("traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(false)))
      .setProtoBody(new ProtoBody()
        .addChild(new Transform().setScale(1.4,1.0,1.0)
          .addChild(new Viewpoint().setDescription("Canopy (click back to open, click front to close)").setOrientation(0.0,1.0,0.0,-1.57).setPosition(0.0,0.0,-4.0))
          .addChild(new Transform("CockpitFront").setTranslation(3.0,0.0,0.0)
            .addChild(new Shape()
              .setAppearance(new Appearance("CanopyColor")
                .setMaterial(new Material().setDiffuseColor(0.3,0.4,0.8).setTransparency(0.85)))
              .setGeometry(new IndexedFaceSet().setCreaseAngle(1.8).setSolid(false).setCoordIndex(new int[] {9,300,10,-1,10,300,301,-1,301,306,10,-1,2,308,309,-1})
                .setCoord(new Coordinate().setPoint(getCoordinate_9_22_point())))))
          .addChild(new Group()
            .addChild(new Transform("CanopyTransform").setCenter(0.0,0.0,-3.5)
              .addChild(new Transform().setTranslation(3.0,0.0,0.0)
                .addChild(new Shape()
                  .setAppearance(new Appearance().setUSE("CanopyColor"))
                  .setGeometry(new IndexedFaceSet().setCreaseAngle(1.8).setSolid(false).setCoordIndex(new int[] {16,17,112,302,-1,301,304,305,306,-1,306,305,186,179,-1,304,307,257,305,-1,305,257,187,186,-1,302,112,307,304,-1,9,16,302,300,-1,300,302,304,301,-1,17,112,310,-1,112,307,310,-1,307,257,310,-1,257,187,310,-1})
                    .setCoord(new Coordinate().setPoint(getCoordinate_11_27_point()))))))
            .addChild(new Script("CanopyScript").setSourceCode("""
ecmascript:

function canopyOpen(value, timeStamp) {
  
 if (value == true)       //Canopy Open
 {
      	tracePrint ('[Canopy Open] ' );
      	tracePrint ('value = ' + value);
      	canapyOut = true;    	
      
      	kV1 = new SFRotation (new SFVec3f (1, 0, 0), 0.0);  
     	kV2 = new SFRotation (new SFVec3f (1, 0, 0), 0.52);
      	kV3 = new SFRotation(new SFVec3f (1, 0, 0), 0.79);
      	keyValue = new MFRotation(kV1, kV2, kV3);  
      	//tracePrint ('[keyValue = ]' + keyValue);      
  
 }
 else        //Canopy Close
 {
      	tracePrint ('[Canopy Close] ' );
      	tracePrint ('value = ' + value);
      	canopyOut = true;
     	
      	keyValue = new MFRotation(kV3, kV2, kV1);  
      	//tracePrint ('[keyValue = ]' + keyValue);             
 }
 
}

function set_fraction (value, timeStamp)
{
	//tracePrint('time fraction = ' + value);
}

function animationStartTime(value, timeStamp)
{	
	tracePrint('The Start Time is: ' + value);
	clockStartTime = value;
}

function tracePrint (outputString)
{
	if (traceEnabled) Browser.println ('[CanopyPrototype] ' + outputString);
}
""")
              .addField(new field().setName("canopyOpen").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("eventIn: boolean true: canopy open false: canopy close"))
              .addField(new field().setName("canopyOut").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
              .addField(new field().setName("keyValue").setType(field.TYPE_MFROTATION).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
              .addField(new field().setName("kV1").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(new SFRotation(0.0,1.0,0.0,0.0)))
              .addField(new field().setName("kV2").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(new SFRotation(0.0,1.0,0.0,0.0)))
              .addField(new field().setName("kV3").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(new SFRotation(0.0,1.0,0.0,0.0)))
              .addField(new field().setName("set_fraction").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTONLY))
              .addField(new field().setName("animationStartTime").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_INPUTONLY))
              .addField(new field().setName("clockStartTime").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
              .addField(new field().setName("traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
              .setIS(new IS()
                .addConnect(new connect().setNodeField("canopyOpen").setProtoField("canopyOpen"))
                .addConnect(new connect().setNodeField("animationStartTime").setProtoField("animationStartTime"))
                .addConnect(new connect().setNodeField("canopyOut").setProtoField("canopyOut"))
                .addConnect(new connect().setNodeField("traceEnabled").setProtoField("traceEnabled"))))
            .addChild(new OrientationInterpolator("CanopyInterpolator").setKey(new double[] {0.0,0.5,1.0}).setKeyValue(new MFRotation(new double[] {1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.52,1.0,0.0,0.0,0.79})))
            .addChild(new TimeSensor("Clock").setCycleInterval(4))
            .addChild(new ROUTE().setFromNode("CanopyScript").setFromField("clockStartTime").setToNode("Clock").setToField("set_startTime"))
            .addChild(new ROUTE().setFromNode("CanopyScript").setFromField("canopyOut").setToNode("Clock").setToField("set_enabled"))
            .addChild(new ROUTE().setFromNode("CanopyScript").setFromField("keyValue").setToNode("CanopyInterpolator").setToField("set_keyValue"))
            .addChild(new ROUTE().setFromNode("Clock").setFromField("fraction_changed").setToNode("CanopyInterpolator").setToField("set_fraction"))
            .addChild(new ROUTE().setFromNode("Clock").setFromField("fraction_changed").setToNode("CanopyScript").setToField("set_fraction"))
            .addChild(new ROUTE().setFromNode("CanopyInterpolator").setFromField("value_changed").setToNode("CanopyTransform").setToField("set_rotation"))))))
    .addChild(new Background().setSkyColor(new MFColor(new double[] {0.6,0.6,0.6})))
    .addChild(new Anchor().setDescription("Canopy Example").setParameter(new String[] {"target=_blank"}).setUrl(new String[] {"CanopyExample.wrl","../../AircraftFixedWing/F18BlueAngelUnitedStates/CanopyExample.wrl","https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/CanopyExample.wrl","CanopyExample.x3d","../../AircraftFixedWing/F18BlueAngelUnitedStates/CanopyExample.x3d","https://www.web3d.org/x3d/content/examples/Savage/AircraftFixedWing/F18BlueAngelUnitedStates/CanopyExample.x3d"})
      .addChild(new Shape()
        .setGeometry(new Text().setString(new String[] {"CanopyPrototype","is a prototype definition file","","To see an example scene","click on this text and view","CanopyExample"})
          .setFontStyle(new FontStyle().setJustify(FontStyle.JUSTIFY_MIDDLE_MIDDLE)))
        .setAppearance(new Appearance()))));
            }
            catch (Exception ex)
            {       
                System.err.println ("*** Further hints on X3DJSAIL errors and exceptions at");
                System.err.println ("*** https://www.web3d.org/specifications/java/X3DJSAIL.html");
                throw (ex);
            }
	}
	// end of initialize() method

		/** Define subarrays using type double[] */
		private double[] getCoordinate_9_22_point_1()
		{
			double[] value = {-0.35,-0.32,-6.71,-0.44,-0.17,-5.91,0.0,0.25,-5.9,0.0,0.0,-6.7,-0.35,-0.5,-6.7,-0.45,-0.5,-5.9,-0.44,-0.17,-5.91,-0.35,-0.32,-6.71,-0.44,0.11,-5.01,-0.32,0.23,-5.0,0.0,0.25,-5.9,-0.45,-0.5,-5.0,-0.45,-0.5,-4.55,-0.44,0.25,-4.56,-0.45,-0.5,-3.93,-0.44,0.31,-4.05,-0.34,0.36,-4.55,-0.26,0.57,-3.55,0.6,0.54,0.65,0.62,0.53,1.09,0.7,0.5,2.05,4.62,0.05,2.42,4.62,0.08,1.58,3.79,0.18,0.71,0.69,0.59,-0.95,0.64,0.57,-0.27,0.64,0.57,0.0,2.78,0.32,0.0,1.45,0.49,-0.92,0.19,0.79,4.91,0.0,0.85,6.5,0.11,0.79,6.5,-0.33,-0.54,-6.7,-0.34,-0.68,-5.9,0.0,-0.7,-6.7,0.0,-0.85,-5.9,-0.3,-0.8,-5.0,0.0,-0.95,-5.0,-0.3,-0.8,-4.55,0.0,-0.95,-4.55,-0.3,-0.8,-3.9,0.0,-0.95,-3.55,-0.3,-0.8,-3.55,0.0,-0.43,-7.22,0.0,-0.43,-7.22,0.0,-0.7,-6.7,-0.33,-0.54,-6.7,-0.69,0.28,-4.03,-0.83,0.5,-3.58,-0.89,-0.64,-3.91,-0.93,-0.63,-3.54,-1.1,0.0,-3.55,-1.0,-0.25,-3.95,0.75,0.6,-1.6,-0.65,-0.7,-2.6,0.0,-0.95,-1.8,-1.13,-0.35,-2.63,-1.13,0.25,-2.62,-1.13,-0.35,-2.63,-1.15,-0.35,-1.6,-1.15,0.25,-1.6,-1.13,0.25,-2.62,-0.96,0.25,-3.57,-0.8,0.6,-2.6,-0.8,0.25,-1.6,-0.8,0.6,-2.6,-0.85,0.25,-0.95,-0.85,-0.35,-0.95,-0.9,-0.35,0.65,-0.9,0.25,0.65,-0.87,0.25,0.0,0.03,0.45,7.14,0.22,0.57,7.14,0.22,0.68,7.14,0.03,0.8,7.14,-0.65,-0.35,0.65,-0.65,-0.35,1.1,-0.46,-0.85,-1.8,-0.5,-0.85,-1.6,-0.8,-0.35,-1.6,-0.75,-0.35,-1.8,0.0,-0.95,-1.6,-0.55,-0.84,-0.95,-0.85,-0.35,-0.95,0.0,-0.95,-0.95,-0.33,-0.88,0.65,-0.65,-0.35,0.65,0.0,-0.95,0.65,-0.33,-0.88,1.1,-0.65,-0.35,1.1,0.0,-0.95,1.1,-0.69,0.68,-2.61,-0.41,0.84,-1.6,0.0,0.95,-1.6,0.0,0.85,-2.65,-0.75,0.6,-1.6,-0.41,0.84,-1.6,-0.69,0.68,-2.61,-0.36,0.86,-0.95,0.0,0.95,-0.95};
			return value;
		}
		private double[] getCoordinate_9_22_point_2()
		{
			double[] value = {-0.75,0.6,-1.6,-0.67,0.64,-0.95,-0.34,0.85,0.0,0.0,0.92,0.0,-0.55,0.7,0.0,-0.31,0.78,2.05,0.0,0.85,2.05,0.0,0.85,-3.55,-0.26,0.74,-3.55,0.0,0.85,-2.65,0.0,0.4,6.87,0.25,0.55,6.87,-0.26,0.74,-3.55,-0.69,0.59,-0.95,-0.67,0.64,-0.95,-0.64,0.57,-0.27,-0.55,0.7,0.0,-0.65,0.35,3.45,-0.55,0.35,4.0,-0.4,0.74,4.01,-0.49,0.72,3.51,-0.2,0.8,4.0,-0.2,0.8,4.55,-0.19,0.79,4.91,0.0,0.85,4.9,0.0,0.85,4.0,-0.35,0.35,4.9,-0.19,0.79,4.91,-0.53,-0.23,3.52,-0.45,-0.18,4.02,0.0,-0.6,3.55,0.0,-0.5,4.0,-0.45,-0.18,4.02,-0.53,-0.23,3.52,-0.26,-0.16,4.92,0.0,-0.35,4.9,-0.26,-0.16,4.92,0.0,0.4,6.5,-0.35,0.35,4.9,0.0,0.0,6.4,-0.25,0.7,6.5,-0.25,0.55,6.5,0.0,0.4,6.5,-0.11,0.79,6.5,-0.65,0.25,1.1,-0.65,0.25,0.65,-0.66,0.54,0.48,-0.6,0.54,0.65,-0.59,0.64,0.65,0.0,-0.6,3.55,-0.65,0.25,1.1,0.0,0.85,3.55,-0.49,0.72,3.51,0.0,0.85,3.55,-0.31,0.78,2.05,-0.7,0.5,2.05,-0.7,0.5,2.05,-0.62,0.6,1.09,-0.62,0.53,1.09,0.0,0.85,6.5,-0.25,0.7,6.87,0.0,0.85,6.87,-0.25,0.55,6.87,-0.22,0.68,7.14,-0.03,0.8,7.14,-0.22,0.57,7.14,-0.03,0.45,7.14,-1.45,0.49,-0.92,-0.11,0.79,6.5,-0.64,0.57,0.0,-2.78,0.32,0.0,-4.62,0.05,2.42,-4.62,0.08,1.58,-3.79,0.18,0.71,0.0,0.0,-6.7,0.44,-0.17,-5.91,0.35,-0.32,-6.71,0.45,-0.5,-5.9,0.35,-0.5,-6.7,0.32,0.23,-5.0,0.44,0.11,-5.01,0.45,-0.5,-5.0,0.44,0.25,-4.56,0.45,-0.5,-4.55,0.44,0.31,-4.05,0.45,-0.5,-3.93,0.34,0.36,-4.55,0.26,0.57,-3.55,0.22,0.68,7.14,0.22,0.57,7.14,0.25,0.55,6.87,0.25,0.7,6.87,0.25,0.7,6.87,0.0,0.4,6.87,0.25,0.55,6.5,0.25,0.55,6.5,0.25,0.7,6.5,0.11,0.79,6.5,0.65,0.35,3.45,0.65,0.25,1.1};
			return value;
		}
		private double[] getCoordinate_9_22_point_3()
		{
			double[] value = {0.7,0.5,2.05,0.34,-0.68,-5.9,0.33,-0.54,-6.7,0.3,-0.8,-5.0,0.3,-0.8,-4.55,0.3,-0.8,-3.9,0.3,-0.8,-3.55,0.35,-0.32,-6.71,0.35,-0.5,-6.7,0.33,-0.54,-6.7,0.83,0.5,-3.58,0.69,0.28,-4.03,1.0,-0.25,-3.95,1.1,0.0,-3.55,0.93,-0.63,-3.54,0.89,-0.64,-3.91,0.65,0.25,1.1,0.62,0.6,1.09,0.65,-0.7,-2.6,1.13,-0.35,-2.63,1.15,0.25,-1.6,1.15,-0.35,-1.6,1.13,-0.35,-2.63,1.13,0.25,-2.62,1.13,0.25,-2.62,0.96,0.25,-3.57,0.8,0.25,-1.6,0.8,0.6,-2.6,0.8,0.6,-2.6,0.49,0.72,3.51,0.85,0.25,-0.95,0.87,0.25,0.0,0.9,0.25,0.65,0.9,-0.35,0.65,0.85,-0.35,-0.95,0.31,0.78,2.05,0.9,-0.35,0.65,0.65,-0.35,1.1,0.65,-0.35,0.65,0.85,-0.35,-0.95,0.75,-0.35,-1.8,0.8,-0.35,-1.6,0.5,-0.85,-1.6,0.46,-0.85,-1.8,0.55,-0.84,-0.95,0.33,-0.88,0.65,0.33,-0.88,1.1,0.41,0.84,-1.6,0.69,0.68,-2.61,0.69,0.68,-2.61,0.41,0.84,-1.6,0.36,0.86,-0.95,0.67,0.64,-0.95,0.75,0.6,-1.6,0.34,0.85,0.0,0.55,0.7,0.0,0.26,0.74,-3.55,0.26,0.74,-3.55,0.67,0.64,-0.95,0.55,0.7,0.0,0.59,0.64,0.65,0.66,0.54,0.48,0.4,0.74,4.01,0.55,0.35,4.0,0.2,0.8,4.55,0.2,0.8,4.0,0.19,0.79,4.91,0.35,0.35,4.9,0.45,-0.18,4.02,0.53,-0.23,3.52,0.0,-0.5,4.0,0.55,0.35,4.0,0.35,0.35,4.9,0.26,-0.16,4.92,0.45,-0.18,4.02,0.65,0.25,0.65,0.33,-0.88,1.1,0.65,-0.35,1.1,0.0,-0.6,5.95,0.0,-0.45,6.2,0.2,0.8,4.0,0.34,0.85,0.0,0.31,0.78,2.05,0.8,-0.35,-1.6,0.75,-0.35,-1.8,2.2,0.15,6.7,2.2,0.15,6.35,0.2,0.8,4.55,0.0,1.7,4.9,0.0,2.4,5.65,0.0,2.75,6.15,0.0,2.85,6.7,0.0,0.95,4.0,0.0,0.95,3.55,-0.8,-0.35,-1.6,-0.75,-0.35,-1.8,-0.34,0.85,0.0,-0.4,0.74,4.01,-2.2,0.15,6.7,-2.2,0.15,6.35};
			return value;
		}
		private double[] getCoordinate_9_22_point_4()
		{
			double[] value = {-0.33,0.52,-5.0,0.0,0.85,-4.85,-0.34,0.68,-4.55,0.0,0.91,-3.44,0.0,0.98,-4.4,0.34,0.68,-4.55,0.33,0.52,-5.0,0.0,0.91,-3.44,0.33,0.52,-5.0,0.32,0.23,-5.0,0.0,0.25,5.9};
			return value;
		}


		/** Define subarrays using type double[] */
		private double[] getCoordinate_11_27_point_1()
		{
			double[] value = {-0.35,-0.32,-6.71,-0.44,-0.17,-5.91,0.0,0.25,-5.9,0.0,0.0,-6.7,-0.35,-0.5,-6.7,-0.45,-0.5,-5.9,-0.44,-0.17,-5.91,-0.35,-0.32,-6.71,-0.44,0.11,-5.01,-0.32,0.23,-5.0,0.0,0.25,-5.9,-0.45,-0.5,-5.0,-0.45,-0.5,-4.55,-0.44,0.25,-4.56,-0.45,-0.5,-3.93,-0.44,0.31,-4.05,-0.34,0.36,-4.55,-0.26,0.57,-3.55,0.6,0.54,0.65,0.62,0.53,1.09,0.7,0.5,2.05,4.62,0.05,2.42,4.62,0.08,1.58,3.79,0.18,0.71,0.69,0.59,-0.95,0.64,0.57,-0.27,0.64,0.57,0.0,2.78,0.32,0.0,1.45,0.49,-0.92,0.19,0.79,4.91,0.0,0.85,6.5,0.11,0.79,6.5,-0.33,-0.54,-6.7,-0.34,-0.68,-5.9,0.0,-0.7,-6.7,0.0,-0.85,-5.9,-0.3,-0.8,-5.0,0.0,-0.95,-5.0,-0.3,-0.8,-4.55,0.0,-0.95,-4.55,-0.3,-0.8,-3.9,0.0,-0.95,-3.55,-0.3,-0.8,-3.55,0.0,-0.43,-7.22,0.0,-0.43,-7.22,0.0,-0.7,-6.7,-0.33,-0.54,-6.7,-0.69,0.28,-4.03,-0.83,0.5,-3.58,-0.89,-0.64,-3.91,-0.93,-0.63,-3.54,-1.1,0.0,-3.55,-1.0,-0.25,-3.95,0.75,0.6,-1.6,-0.65,-0.7,-2.6,0.0,-0.95,-1.8,-1.13,-0.35,-2.63,-1.13,0.25,-2.62,-1.13,-0.35,-2.63,-1.15,-0.35,-1.6,-1.15,0.25,-1.6,-1.13,0.25,-2.62,-0.96,0.25,-3.57,-0.8,0.6,-2.6,-0.8,0.25,-1.6,-0.8,0.6,-2.6,-0.85,0.25,-0.95,-0.85,-0.35,-0.95,-0.9,-0.35,0.65,-0.9,0.25,0.65,-0.87,0.25,0.0,0.03,0.45,7.14,0.22,0.57,7.14,0.22,0.68,7.14,0.03,0.8,7.14,-0.65,-0.35,0.65,-0.65,-0.35,1.1,-0.46,-0.85,-1.8,-0.5,-0.85,-1.6,-0.8,-0.35,-1.6,-0.75,-0.35,-1.8,0.0,-0.95,-1.6,-0.55,-0.84,-0.95,-0.85,-0.35,-0.95,0.0,-0.95,-0.95,-0.33,-0.88,0.65,-0.65,-0.35,0.65,0.0,-0.95,0.65,-0.33,-0.88,1.1,-0.65,-0.35,1.1,0.0,-0.95,1.1,-0.69,0.68,-2.61,-0.41,0.84,-1.6,0.0,0.95,-1.6,0.0,0.85,-2.65,-0.75,0.6,-1.6,-0.41,0.84,-1.6,-0.69,0.68,-2.61,-0.36,0.86,-0.95,0.0,0.95,-0.95};
			return value;
		}
		private double[] getCoordinate_11_27_point_2()
		{
			double[] value = {-0.75,0.6,-1.6,-0.67,0.64,-0.95,-0.34,0.85,0.0,0.0,0.92,0.0,-0.55,0.7,0.0,-0.31,0.78,2.05,0.0,0.85,2.05,0.0,0.85,-3.55,-0.26,0.74,-3.55,0.0,0.85,-2.65,0.0,0.4,6.87,0.25,0.55,6.87,-0.26,0.74,-3.55,-0.69,0.59,-0.95,-0.67,0.64,-0.95,-0.64,0.57,-0.27,-0.55,0.7,0.0,-0.65,0.35,3.45,-0.55,0.35,4.0,-0.4,0.74,4.01,-0.49,0.72,3.51,-0.2,0.8,4.0,-0.2,0.8,4.55,-0.19,0.79,4.91,0.0,0.85,4.9,0.0,0.85,4.0,-0.35,0.35,4.9,-0.19,0.79,4.91,-0.53,-0.23,3.52,-0.45,-0.18,4.02,0.0,-0.6,3.55,0.0,-0.5,4.0,-0.45,-0.18,4.02,-0.53,-0.23,3.52,-0.26,-0.16,4.92,0.0,-0.35,4.9,-0.26,-0.16,4.92,0.0,0.4,6.5,-0.35,0.35,4.9,0.0,0.0,6.4,-0.25,0.7,6.5,-0.25,0.55,6.5,0.0,0.4,6.5,-0.11,0.79,6.5,-0.65,0.25,1.1,-0.65,0.25,0.65,-0.66,0.54,0.48,-0.6,0.54,0.65,-0.59,0.64,0.65,0.0,-0.6,3.55,-0.65,0.25,1.1,0.0,0.85,3.55,-0.49,0.72,3.51,0.0,0.85,3.55,-0.31,0.78,2.05,-0.7,0.5,2.05,-0.7,0.5,2.05,-0.62,0.6,1.09,-0.62,0.53,1.09,0.0,0.85,6.5,-0.25,0.7,6.87,0.0,0.85,6.87,-0.25,0.55,6.87,-0.22,0.68,7.14,-0.03,0.8,7.14,-0.22,0.57,7.14,-0.03,0.45,7.14,-1.45,0.49,-0.92,-0.11,0.79,6.5,-0.64,0.57,0.0,-2.78,0.32,0.0,-4.62,0.05,2.42,-4.62,0.08,1.58,-3.79,0.18,0.71,0.0,0.0,-6.7,0.44,-0.17,-5.91,0.35,-0.32,-6.71,0.45,-0.5,-5.9,0.35,-0.5,-6.7,0.32,0.23,-5.0,0.44,0.11,-5.01,0.45,-0.5,-5.0,0.44,0.25,-4.56,0.45,-0.5,-4.55,0.44,0.31,-4.05,0.45,-0.5,-3.93,0.34,0.36,-4.55,0.26,0.57,-3.55,0.22,0.68,7.14,0.22,0.57,7.14,0.25,0.55,6.87,0.25,0.7,6.87,0.25,0.7,6.87,0.0,0.4,6.87,0.25,0.55,6.5,0.25,0.55,6.5,0.25,0.7,6.5,0.11,0.79,6.5,0.65,0.35,3.45,0.65,0.25,1.1};
			return value;
		}
		private double[] getCoordinate_11_27_point_3()
		{
			double[] value = {0.7,0.5,2.05,0.34,-0.68,-5.9,0.33,-0.54,-6.7,0.3,-0.8,-5.0,0.3,-0.8,-4.55,0.3,-0.8,-3.9,0.3,-0.8,-3.55,0.35,-0.32,-6.71,0.35,-0.5,-6.7,0.33,-0.54,-6.7,0.83,0.5,-3.58,0.69,0.28,-4.03,1.0,-0.25,-3.95,1.1,0.0,-3.55,0.93,-0.63,-3.54,0.89,-0.64,-3.91,0.65,0.25,1.1,0.62,0.6,1.09,0.65,-0.7,-2.6,1.13,-0.35,-2.63,1.15,0.25,-1.6,1.15,-0.35,-1.6,1.13,-0.35,-2.63,1.13,0.25,-2.62,1.13,0.25,-2.62,0.96,0.25,-3.57,0.8,0.25,-1.6,0.8,0.6,-2.6,0.8,0.6,-2.6,0.49,0.72,3.51,0.85,0.25,-0.95,0.87,0.25,0.0,0.9,0.25,0.65,0.9,-0.35,0.65,0.85,-0.35,-0.95,0.31,0.78,2.05,0.9,-0.35,0.65,0.65,-0.35,1.1,0.65,-0.35,0.65,0.85,-0.35,-0.95,0.75,-0.35,-1.8,0.8,-0.35,-1.6,0.5,-0.85,-1.6,0.46,-0.85,-1.8,0.55,-0.84,-0.95,0.33,-0.88,0.65,0.33,-0.88,1.1,0.41,0.84,-1.6,0.69,0.68,-2.61,0.69,0.68,-2.61,0.41,0.84,-1.6,0.36,0.86,-0.95,0.67,0.64,-0.95,0.75,0.6,-1.6,0.34,0.85,0.0,0.55,0.7,0.0,0.26,0.74,-3.55,0.26,0.74,-3.55,0.67,0.64,-0.95,0.55,0.7,0.0,0.59,0.64,0.65,0.66,0.54,0.48,0.4,0.74,4.01,0.55,0.35,4.0,0.2,0.8,4.55,0.2,0.8,4.0,0.19,0.79,4.91,0.35,0.35,4.9,0.45,-0.18,4.02,0.53,-0.23,3.52,0.0,-0.5,4.0,0.55,0.35,4.0,0.35,0.35,4.9,0.26,-0.16,4.92,0.45,-0.18,4.02,0.65,0.25,0.65,0.33,-0.88,1.1,0.65,-0.35,1.1,0.0,-0.6,5.95,0.0,-0.45,6.2,0.2,0.8,4.0,0.34,0.85,0.0,0.31,0.78,2.05,0.8,-0.35,-1.6,0.75,-0.35,-1.8,2.2,0.15,6.7,2.2,0.15,6.35,0.2,0.8,4.55,0.0,1.7,4.9,0.0,2.4,5.65,0.0,2.75,6.15,0.0,2.85,6.7,0.0,0.95,4.0,0.0,0.95,3.55,-0.8,-0.35,-1.6,-0.75,-0.35,-1.8,-0.34,0.85,0.0,-0.4,0.74,4.01,-2.2,0.15,6.7,-2.2,0.15,6.35};
			return value;
		}
		private double[] getCoordinate_11_27_point_4()
		{
			double[] value = {-0.33,0.52,-5.0,0.0,0.85,-4.85,-0.34,0.68,-4.55,0.0,0.91,-3.44,0.0,0.98,-4.4,0.34,0.68,-4.55,0.33,0.52,-5.0,0.0,0.91,-3.44,0.33,0.52,-5.0,0.32,0.23,-5.0,0.0,0.57,-2.5};
			return value;
		}

		/** Large attribute array: Coordinate point field, scene-graph level=9, element #22, 933 total numbers made up of 311 3-tuple values.
		 * Reassemble split array as single method to improve readability and runnability.
		 * Provide large array values via separate methods, hoping to avoid 'code too large' Java compilation errors. 
		 * Individual Java methods (including aggregated initializations) are limited to 64KB.
		 * @see https://stackoverflow.com/questions/2407912/code-too-large-compilation-error-in-java
		 * @see https://stackoverflow.com/questions/11437905/java-too-many-constants-jvm-error
		 */
		private MFVec3f getCoordinate_9_22_point()
		{
			MFVec3f Coordinate_9_22_point = new MFVec3f()/*2.finalize*/
				.append(new MFVec3f(getCoordinate_9_22_point_1()))
				.append(new MFVec3f(getCoordinate_9_22_point_2()))
				.append(new MFVec3f(getCoordinate_9_22_point_3()))
				.append(new MFVec3f(getCoordinate_9_22_point_4()));
			return Coordinate_9_22_point;
		}
		/** Large attribute array: Coordinate point field, scene-graph level=11, element #27, 933 total numbers made up of 311 3-tuple values.
		 * Reassemble split array as single method to improve readability and runnability.
		 * Provide large array values via separate methods, hoping to avoid 'code too large' Java compilation errors. 
		 * Individual Java methods (including aggregated initializations) are limited to 64KB.
		 * @see https://stackoverflow.com/questions/2407912/code-too-large-compilation-error-in-java
		 * @see https://stackoverflow.com/questions/11437905/java-too-many-constants-jvm-error
		 */
		private MFVec3f getCoordinate_11_27_point()
		{
			MFVec3f Coordinate_11_27_point = new MFVec3f()/*2.finalize*/
				.append(new MFVec3f(getCoordinate_11_27_point_1()))
				.append(new MFVec3f(getCoordinate_11_27_point_2()))
				.append(new MFVec3f(getCoordinate_11_27_point_3()))
				.append(new MFVec3f(getCoordinate_11_27_point_4()));
			return Coordinate_11_27_point;
		}

	/** The initialized model object, created within initialize() method. */
	private X3D x3dModel;

	/** 
	 * Provide a 
	 * <a href="https://dzone.com/articles/java-copy-shallow-vs-deep-in-which-you-will-swim" target="_blank">shallow copy</a>
	 * of the X3D model.
	 * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html">X3D</a>
	 * @return CanopyPrototype model
	 */
	public X3D getX3dModel()
	{	  
		return x3dModel;
	}
	   
    /** 
     * Default main() method provided for test purposes, uses CommandLine to set global ConfigurationProperties for this object.
     * @param args array of input parameters, provided as arguments
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html#handleArguments-java.lang.String:A-">X3D.handleArguments(args)</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html#validationReport--">X3D.validationReport()</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/CommandLine.html">CommandLine</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/CommandLine.html#USAGE">CommandLine.USAGE</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/ConfigurationProperties.html">ConfigurationProperties</a>
     */
    public static void main(String args[])
    {
        System.out.println("Build this X3D model, showing validation diagnostics...");
        X3D thisExampleX3dModel = new CanopyPrototype().getX3dModel();
//      System.out.println("X3D model construction complete.");
	
        // next handle command line arguments
        boolean hasArguments = (args != null) && (args.length > 0);
        boolean validate = true; // default
        boolean argumentsLoadNewModel = false;
        String  fileName = new String();

        if (args != null)
        {
                for (String arg : args)
                {
                        if (arg.toLowerCase().startsWith("-v") || arg.toLowerCase().contains("validate"))
                        {
                                validate = true; // making sure
                        }
                        if (arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_X3D) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_CLASSICVRML) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_X3DB) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_VRML97) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_EXI) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_GZIP) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_ZIP) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_HTML) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_XHTML))
                        {
                                argumentsLoadNewModel = true;
                                fileName = arg;
                        }
                }
        }
        if      (argumentsLoadNewModel)
                System.out.println("WARNING: \"Savage.AircraftFixedWing.F18BlueAngelUnitedStates.CanopyPrototype\" model invocation is attempting to load file \"" + fileName + "\" instead of simply validating itself... file loading ignored.");
        else if (hasArguments) // if no arguments provided, this method produces usage warning
                thisExampleX3dModel.handleArguments(args);
	
        if (validate)
        {
            //  System.out.println("--- TODO fix duplicated outputs ---"); // omit when duplicated outputs problem is solved/refactored
		String validationResults = thisExampleX3dModel.validationReport();
            //  System.out.println("-----------------------------------"); // omit when duplicated outputs problem is solved/refactored
                System.out.print("Savage.AircraftFixedWing.F18BlueAngelUnitedStates.CanopyPrototype self-validation test confirmation: ");
                if (!validationResults.equals("success"))
                    System.out.println();
                System.out.println(validationResults.trim());

                // experimental: test X3DJSAIL output files
                // AircraftFixedWing/F18BlueAngelUnitedStates/CanopyPrototype_JavaExport.* file validation is checked when building X3D Example Archives
                String filenameX3D  = "AircraftFixedWing/F18BlueAngelUnitedStates/CanopyPrototype_JavaExport.x3d"; 
                String filenameX3DV = "AircraftFixedWing/F18BlueAngelUnitedStates/CanopyPrototype_JavaExport.x3dv"; 
                String filenameJSON = "AircraftFixedWing/F18BlueAngelUnitedStates/CanopyPrototype_JavaExport.json";
                thisExampleX3dModel.toFileX3D        (filenameX3D);
                thisExampleX3dModel.toFileClassicVRML(filenameX3DV);
// TODO         thisExampleX3dModel.toFileJSON       (filenameJSON);
        }
    }
}
