package Savage.ModelDetailing.MilitaryCrestsAndSeals;

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.Rendering.*;
import org.web3d.x3d.jsail.Shape.*;
import org.web3d.x3d.jsail.Texturing.*;

// Javadoc metadata annotations follow, see below for X3DJSAIL Java source code.
/**
 * <p> Example scene COMDESRON31. </p>
 <p> Related links:  source COMDESRON31.java, <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;">Savage.ModelDetailing.MilitaryCrestsAndSeals.COMDESRON31&nbsp; Document Metadata </td>
		</tr>

		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> title </i> </td>
			<td> <a href="COMDESRON31">COMDESRON31</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> Vizthumbnail </i> </td>
			<td> Thumb_COMDESRON31_x3d58303181148874576.jpg </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> license </i> </td>
			<td> <a href="../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>

 */

public class COMDESRON31
{
	/** Default constructor to create this object. */
	public COMDESRON31 ()
	{
	  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("COMDESRON31"))
    .addMeta(new meta().setName("Vizthumbnail").setContent("Thumb_COMDESRON31_x3d58303181148874576.jpg"))
    .addMeta(new meta().setName(meta.NAME_LICENSE    ).setContent("../license.html")))
  .setScene(new Scene()
    .addChild(new WorldInfo().setInfo(new String[] {"This Web3D World was created with Vizx3D, a Web3D authoring tool","www.vizx3d.com"}).setTitle("DESRON31Starboard"))
    .addChild(new Transform("dad_GROUND")
      .addChild(new Group("GROUND")
        .addChild(new Transform("dad_DESRON32").setRotation(-1.0,0.0,0.0,1.571)
          .addChild(new Shape("DESRON32")
            .setAppearance(new Appearance()
              .setTexture(new ImageTexture().setRepeatS(false).setRepeatT(false).setUrl(new String[] {"COMDESRON31/newsealtest.jpg"}))
              .setTextureTransform(new TextureTransform().setCenter(-1.092,-.057).setScale(.912,.981).setTranslation(-.086,.009))
              .setMaterial(new Material("Red_mat").setDiffuseColor(1.0,0.0,0.0)))
            .setGeometry(new IndexedFaceSet().setCreaseAngle(0.524).setCoordIndex(getIndexedFaceSet_7_10_coordIndex()).setTexCoordIndex(getIndexedFaceSet_7_10_texCoordIndex())
              .setCoord(new Coordinate().setPoint(new MFVec3f(new double[] {0.0,.05,-.8,.16,.05,-.78,.31,.05,-.74,.44,.05,-.67,.57,.05,-.57,.67,.05,-.44,.74,.05,-.31,.78,.05,-.16,.8,.05,0.0,.78,.05,.16,.74,.05,.31,.67,.05,.44,.57,.05,.57,.44,.05,.67,.31,.05,.74,.16,.05,.78,-0.0,.05,.8,-.16,.05,.78,-.31,.05,.74,-.44,.05,.67,-.57,.05,.57,-.67,.05,.44,-.74,.05,.31,-.78,.05,.16,-.8,.05,-0.0,-.78,.05,-.16,-.74,.05,-.31,-.67,.05,-.44,-.57,.05,-.57,-.44,.05,-.67,-.31,.05,-.74,-.16,.05,-.78,0.0,.05,0.0,0.0,-.05,-.8,.16,-.05,-.78,.31,-.05,-.74,.44,-.05,-.67,.57,-.05,-.57,.67,-.05,-.44,.74,-.05,-.31,.78,-.05,-.16,.8,-.05,0.0,.78,-.05,.16,.74,-.05,.31,.67,-.05,.44,.57,-.05,.57,.44,-.05,.67,.31,-.05,.74,.16,-.05,.78,-0.0,-.05,.8,-.16,-.05,.78,-.31,-.05,.74,-.44,-.05,.67,-.57,-.05,.57,-.67,-.05,.44,-.74,-.05,.31,-.78,-.05,.16,-.8,-.05,-0.0,-.78,-.05,-.16,-.74,-.05,-.31,-.67,-.05,-.44,-.57,-.05,-.57,-.44,-.05,-.67,-.31,-.05,-.74,-.16,-.05,-.78,0.0,-.05,0.0})))
              .setTexCoord(new TextureCoordinate().setPoint(new MFVec2f(new double[] {.5,1.0,.598,.99,.691,.962,.778,.916,.854,.854,.916,.778,.962,.691,.99,.598,1.0,.5,.99,.402,.962,.309,.916,.222,.854,.146,.778,.084,.691,.038,.598,.01,.5,0.0,.402,.01,.309,.038,.222,.084,.146,.146,.084,.222,.038,.309,.01,.402,0.0,.5,.01,.598,.038,.691,.084,.778,.146,.854,.222,.916,.309,.962,.402,.99,.5,.5,1.0,1.0,.969,1.0,.938,1.0,.906,1.0,.875,1.0,.844,1.0,.813,1.0,.781,1.0,.75,1.0,.719,1.0,.688,1.0,.656,1.0,.625,1.0,.594,1.0,.563,1.0,.531,1.0,.5,1.0,.469,1.0,.438,1.0,.406,1.0,.375,1.0,.344,1.0,.313,1.0,.281,1.0,.25,1.0,.219,1.0,.188,1.0,.156,1.0,.125,1.0,.094,1.0,.063,1.0,.031,1.0,0.0,1.0,1.0,0.0,.969,0.0,.938,0.0,.906,0.0,.875,0.0,.844,0.0,.813,0.0,.781,0.0,.75,0.0,.719,0.0,.688,0.0,.656,0.0,.625,0.0,.594,0.0,.563,0.0,.531,0.0,.5,0.0,.469,0.0,.438,0.0,.406,0.0,.375,0.0,.344,0.0,.313,0.0,.281,0.0,.25,0.0,.219,0.0,.188,0.0,.156,0.0,.125,0.0,.094,0.0,.063,0.0,.031,0.0,0.0,0.0})))))))));
            }
            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 int[] */
		private int[] getIndexedFaceSet_7_10_coordIndex_1()
		{
			int[] value = {0,32,1,-1,1,32,2,-1,2,32,3,-1,3,32,4,-1,4,32,5,-1,5,32,6,-1,6,32,7,-1,7,32,8,-1,8,32,9,-1,9,32,10,-1,10,32,11,-1,11,32,12,-1,12,32,13,-1,13,32,14,-1,14,32,15,-1,15,32,16,-1,16,32,17,-1,17,32,18,-1,18,32,19,-1,19,32,20,-1,20,32,21,-1,21,32,22,-1,22,32,23,-1,23,32,24,-1,24,32,25,-1,25,32,26,-1,26,32,27,-1,27,32,28,-1,28,32,29,-1,29,32,30,-1,30,32,31,-1,31,32,0,-1,34,65,33,-1,35,65,34,-1,36,65,35,-1,37,65,36,-1,38,65,37,-1,39,65,38,-1,40,65,39,-1,41,65,40,-1,42,65,41,-1,43,65,42,-1,44,65,43,-1,45,65,44,-1,46,65,45,-1,47,65,46,-1,48,65,47,-1,49,65,48,-1,50,65,49,-1,51,65,50,-1,52,65,51,-1,53,65,52,-1,54,65,53,-1,55,65,54,-1,56,65,55,-1,57,65,56,-1,58,65,57,-1,59,65,58,-1,60,65,59,-1,61,65,60,-1,62,65,61,-1,63,65,62,-1,64,65,63,-1,33,65,64,-1,0,34,33,-1,34,0,1,-1,1,35,34,-1,35,1,2,-1,2,36,35,-1,36,2,3,-1,3,37,36,-1,37,3,4,-1,4,38,37,-1,38,4,5,-1,5,39,38,-1,39,5,6,-1,6,40,39,-1,40,6,7,-1,7,41,40,-1,41,7,8,-1,8,42,41,-1,42,8,9,-1,9,43,42,-1,43,9,10,-1,10,44,43,-1,44,10,11,-1,11,45,44,-1,45,11,12,-1,12,46,45,-1,46,12,13,-1,13,47,46,-1,47,13,14,-1,14,48,47,-1,48,14,15,-1,15,49,48,-1,49,15,16,-1,16,50,49,-1,50,16,17,-1,17,51,50,-1,51,17,18,-1,18,52,51,-1,52,18,19,-1,19,53,52,-1,53,19,20,-1,20,54,53,-1,54,20,21,-1,21,55,54,-1,55,21,22,-1,22,56,55,-1,56,22,23,-1,23,57,56,-1,57,23,24,-1,24,58,57,-1,58,24,25,-1,25,59,58,-1,59,25,26,-1,26,60,59,-1,60,26,27,-1,27,61,60,-1,61,27,28,-1,28,62,61,-1,62,28,29,-1,29,63,62,-1,63,29,30,-1,30,64,63,-1,64,30,31,-1,31,33,64,-1,33,31,0,-1};
			return value;
		}


		/** Define subarrays using type int[] */
		private int[] getIndexedFaceSet_7_10_texCoordIndex_1()
		{
			int[] value = {0,32,1,-1,1,32,2,-1,2,32,3,-1,3,32,4,-1,4,32,5,-1,5,32,6,-1,6,32,7,-1,7,32,8,-1,8,32,9,-1,9,32,10,-1,10,32,11,-1,11,32,12,-1,12,32,13,-1,13,32,14,-1,14,32,15,-1,15,32,16,-1,16,32,17,-1,17,32,18,-1,18,32,19,-1,19,32,20,-1,20,32,21,-1,21,32,22,-1,22,32,23,-1,23,32,24,-1,24,32,25,-1,25,32,26,-1,26,32,27,-1,27,32,28,-1,28,32,29,-1,29,32,30,-1,30,32,31,-1,31,32,0,-1,15,32,16,-1,14,32,15,-1,13,32,14,-1,12,32,13,-1,11,32,12,-1,10,32,11,-1,9,32,10,-1,8,32,9,-1,7,32,8,-1,6,32,7,-1,5,32,6,-1,4,32,5,-1,3,32,4,-1,2,32,3,-1,1,32,2,-1,0,32,1,-1,31,32,0,-1,30,32,31,-1,29,32,30,-1,28,32,29,-1,27,32,28,-1,26,32,27,-1,25,32,26,-1,24,32,25,-1,23,32,24,-1,22,32,23,-1,21,32,22,-1,20,32,21,-1,19,32,20,-1,18,32,19,-1,17,32,18,-1,16,32,17,-1,33,67,66,-1,67,33,34,-1,34,68,67,-1,68,34,35,-1,35,69,68,-1,69,35,36,-1,36,70,69,-1,70,36,37,-1,37,71,70,-1,71,37,38,-1,38,72,71,-1,72,38,39,-1,39,73,72,-1,73,39,40,-1,40,74,73,-1,74,40,41,-1,41,75,74,-1,75,41,42,-1,42,76,75,-1,76,42,43,-1,43,77,76,-1,77,43,44,-1,44,78,77,-1,78,44,45,-1,45,79,78,-1,79,45,46,-1,46,80,79,-1,80,46,47,-1,47,81,80,-1,81,47,48,-1,48,82,81,-1,82,48,49,-1,49,83,82,-1,83,49,50,-1,50,84,83,-1,84,50,51,-1,51,85,84,-1,85,51,52,-1,52,86,85,-1,86,52,53,-1,53,87,86,-1,87,53,54,-1,54,88,87,-1,88,54,55,-1,55,89,88,-1,89,55,56,-1,56,90,89,-1,90,56,57,-1,57,91,90,-1,91,57,58,-1,58,92,91,-1,92,58,59,-1,59,93,92,-1,93,59,60,-1,60,94,93,-1,94,60,61,-1,61,95,94,-1,95,61,62,-1,62,96,95,-1,96,62,63,-1,63,97,96,-1,97,63,64,-1,64,98,97,-1,98,64,65,-1};
			return value;
		}

		/** Large attribute array: IndexedFaceSet coordIndex field, scene-graph level=7, element #10, 512 total numbers.
		 * 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 MFInt32 getIndexedFaceSet_7_10_coordIndex()
		{
			MFInt32 IndexedFaceSet_7_10_coordIndex = new MFInt32()/*2.finalize*/
				.append(new MFInt32(getIndexedFaceSet_7_10_coordIndex_1()));
			return IndexedFaceSet_7_10_coordIndex;
		}
		/** Large attribute array: IndexedFaceSet texCoordIndex field, scene-graph level=7, element #10, 512 total numbers.
		 * 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 MFInt32 getIndexedFaceSet_7_10_texCoordIndex()
		{
			MFInt32 IndexedFaceSet_7_10_texCoordIndex = new MFInt32()/*2.finalize*/
				.append(new MFInt32(getIndexedFaceSet_7_10_texCoordIndex_1()));
			return IndexedFaceSet_7_10_texCoordIndex;
		}

	/** 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 COMDESRON31 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 COMDESRON31().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.ModelDetailing.MilitaryCrestsAndSeals.COMDESRON31\" 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.ModelDetailing.MilitaryCrestsAndSeals.COMDESRON31 self-validation test confirmation: ");
                if (!validationResults.equals("success"))
                    System.out.println();
                System.out.println(validationResults.trim());

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