package Savage.AircraftHelicopters.AH1WUnitedStates;
/*
Copyright (c) 1995-2019 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.fields.*;
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.Sound.*;
import org.web3d.x3d.jsail.Time.*;
// Javadoc annotations follow, see below for source.
/**
*
A demonstration of a Cobra helicopter section using cruise turn principles to conserve fuel.
Related links: SuperCobraSectionFormBearingDisplay.java source, SuperCobraSectionFormBearingDisplay catalog page, X3D Resources, X3D Scene Authoring Hints, and X3D Tooltips.
This program uses the
X3D Java Scene Access Interface Library (X3DJSAIL).
It has been produced using the
X3dToJava.xslt
stylesheet to create Java source code from an .x3d
model.
* @author Maj C. B. Lakey, USMC
*/
public class SuperCobraSectionFormBearingDisplay
{
/** Default constructor to create this object. */
public SuperCobraSectionFormBearingDisplay ()
{
initialize();
}
/** Create and initialize the X3D model for this object. */
public final void initialize()
{
x3dModel = new X3DObject().setProfile(X3DObject.PROFILE_IMMERSIVE).setVersion(X3DObject.VERSION_3_0)
.setHead(new headObject()
.addMeta(new metaObject().setName(metaObject.NAME_TITLE ).setContent("SuperCobraSectionFormBearingDisplay.x3d"))
.addMeta(new metaObject().setName(metaObject.NAME_DESCRIPTION).setContent("A demonstration of a Cobra helicopter section using cruise turn principles to conserve fuel"))
.addMeta(new metaObject().setName(metaObject.NAME_CREATOR ).setContent("Maj C. B. Lakey, USMC"))
.addMeta(new metaObject().setName(metaObject.NAME_TRANSLATOR ).setContent("Xeena VRML importer, X3D-Edit 3.1, http://www.web3d.org/x3d/content/README.X3D-Edit.html"))
.addMeta(new metaObject().setName(metaObject.NAME_CREATED ).setContent("10 March 2005"))
.addMeta(new metaObject().setName(metaObject.NAME_TRANSLATED ).setContent("10 March 2005"))
.addMeta(new metaObject().setName(metaObject.NAME_MODIFIED ).setContent("12 January 2014"))
.addMeta(new metaObject().setName(metaObject.NAME_REFERENCE ).setContent("AH1wSuperCobra-MV3204FinalProjectReport.pdf"))
.addMeta(new metaObject().setName(metaObject.NAME_IDENTIFIER ).setContent("https://savage.nps.edu/Savage/AircraftHelicopters/AH1W-UnitedStates/SuperCobraSectionFormBearingDisplay.x3d"))
.addMeta(new metaObject().setName(metaObject.NAME_GENERATOR ).setContent("X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit"))
.addMeta(new metaObject().setName(metaObject.NAME_GENERATOR ).setContent("Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html"))
.addMeta(new metaObject().setName(metaObject.NAME_REFERENCE ).setContent("http://www.goldwave.com; Goldwave commercial audio creation software used to generate wav file representing sound of rotors turning"))
.addMeta(new metaObject().setName(metaObject.NAME_LICENSE ).setContent("../../license.html")))
.setScene(new SceneObject()
.addComments(" Background simulates an overwater scene ")
.addChild(new BackgroundObject().setGroundColor(new MFColorObject(new float[] {0.0f,0.0f,0.0f})).setBackUrl(new String[] {"urn:web3d:media:textures/panoramas/ocean_2_back.jpg","../../../Basic/UniversalMediaPanoramas/ocean_2_back.jpg","http://www.web3d.org/WorkingGroups/media/textures/panoramas/ocean_2_back.jpg","http://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/ocean_2_back.jpg","http://www.web3dmedia.com/UniversalMedia/textures/panoramas/ocean_2_back.jpg","http://www.officetowers.com/UniversalMedia/textures/panoramas/ocean_2_back.jpg","http://geometrek.com/UniversalMedia/textures/panoramas/ocean_2_back.jpg","http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/ocean_2_back.jpg"}).setBottomUrl(new String[] {"urn:web3d:media:textures/panoramas/ocean_2_bottom.jpg","ocean_2_bottom.jpg","file:///c:/www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/ocean_2_bottom.jpg","http://www.web3d.org/WorkingGroups/media/textures/panoramas/ocean_2_bottom.jpg","http://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/ocean_2_bottom.jpg","http://www.web3dmedia.com/UniversalMedia/textures/panoramas/ocean_2_bottom.jpg","http://www.officetowers.com/UniversalMedia/textures/panoramas/ocean_2_bottom.jpg","http://geometrek.com/UniversalMedia/textures/panoramas/ocean_2_bottom.jpg","http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/ocean_2_bottom.jpg"}).setFrontUrl(new String[] {"urn:web3d:media:textures/panoramas/ocean_2_front.jpg","../../../Basic/UniversalMediaPanoramas/ocean_2_front.jpg","http://www.web3d.org/WorkingGroups/media/textures/panoramas/ocean_2_front.jpg","http://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/ocean_2_front.jpg","http://www.web3dmedia.com/UniversalMedia/textures/panoramas/ocean_2_front.jpg","http://www.officetowers.com/UniversalMedia/textures/panoramas/ocean_2_front.jpg","http://geometrek.com/UniversalMedia/textures/panoramas/ocean_2_front.jpg","http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/ocean_2_front.jpg"}).setLeftUrl(new String[] {"urn:web3d:media:textures/panoramas/ocean_2_left.jpg","../../../Basic/UniversalMediaPanoramas/ocean_2_left.jpg","http://www.web3d.org/WorkingGroups/media/textures/panoramas/ocean_2_left.jpg","http://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/ocean_2_left.jpg","http://www.web3dmedia.com/UniversalMedia/textures/panoramas/ocean_2_left.jpg","http://www.officetowers.com/UniversalMedia/textures/panoramas/ocean_2_left.jpg","http://geometrek.com/UniversalMedia/textures/panoramas/ocean_2_left.jpg","http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/ocean_2_left.jpg"}).setRightUrl(new String[] {"urn:web3d:media:textures/panoramas/ocean_2_right.jpg","../../../Basic/UniversalMediaPanoramas/ocean_2_right.jpg","http://www.web3d.org/WorkingGroups/media/textures/panoramas/ocean_2_right.jpg","http://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/ocean_2_right.jpg","http://www.web3dmedia.com/UniversalMedia/textures/panoramas/ocean_2_right.jpg","http://www.officetowers.com/UniversalMedia/textures/panoramas/ocean_2_right.jpg","http://geometrek.com/UniversalMedia/textures/panoramas/ocean_2_right.jpg","http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/ocean_2_right.jpg"}).setTopUrl(new String[] {"urn:web3d:media:textures/panoramas/ocean_2_top.jpg","ocean_2_top.jpg","../../../Basic/UniversalMediaPanoramas/ocean_2_top.jpg","http://www.web3d.org/WorkingGroups/media/textures/panoramas/ocean_2_top.jpg","http://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/ocean_2_top.jpg","http://www.web3dmedia.com/UniversalMedia/textures/panoramas/ocean_2_top.jpg","http://www.officetowers.com/UniversalMedia/textures/panoramas/ocean_2_top.jpg","http://geometrek.com/UniversalMedia/textures/panoramas/ocean_2_top.jpg","http://www.sc.ehu.es/ccwgamoa/UniversalMedia/textures/panoramas/ocean_2_top.jpg"}))
.addChild(new GroupObject("TwoAircraftAnimatedGroup")
.addChild(new TimeSensorObject("AircraftPathClock").setCycleInterval(20).setLoop(true))
.addComments(" The aircraft path transform acts as a 'hinge' for moving the section in a circular path ")
.addChild(new TransformObject("AircraftPathTransformation").setCenter(-30.0f,0.0f,0.0f).setTranslation(30.0f,0.0f,0.0f)
.addChild(new GroupObject("SingleAircraftOrientationGroup")
.addChild(new TransformObject("AircraftRollTransformation").setRotation(0.0f,0.0f,1.0f,0.785f)
.addComments(" The single aircraft group contains an inline of an AH-1W SuperCobra model; it currently uses the model with no animated lights; although there is also a model with lights animated, it is not advisable to inline it unless the CPU used is capable of high clock cycles (> 3 GHz) ")
.addChild(new GroupObject("SingleAircraftGroup")
.addChild(new TransformObject().setRotation(0.0f,1.0f,0.0f,-1.57079f)
.addChild(new InlineObject().setUrl(new String[] {"SuperCobra.x3d","https://savage.nps.edu/Savage/AircraftHelicopters/AH1W-UnitedStates/SuperCobra.x3d","SuperCobra.wrl","https://savage.nps.edu/Savage/AircraftHelicopters/AH1W-UnitedStates/SuperCobra.wrl"})))
.addChild(new SoundObject().setMaxBack(150f).setMaxFront(150f).setMinBack(3f).setMinFront(3f)
.setSource(new AudioClipObject().setDescription("Helicopter rotors turning").setLoop(true).setUrl(new String[] {"sounds/rotors.wav","https://savage.nps.edu/Savage/AircraftHelicopters/AH1W-UnitedStates/rotors.wav"})))))
.addComments(" The DashTwo AnimatedGroup contains all transformations that are distinc from the Lead aircraft (i.e., roll angle and bearing) ")
.addChild(new GroupObject("DashTwoAnimatedGroup")
.addChild(new TimeSensorObject("DashTwoBearingClock").setCycleInterval(15).setLoop(true))
.addChild(new TransformObject("DashTwoBearingTransformation").setTranslation(10.0f,1.0f,-10.0f)
.addChild(new GroupObject("DashTwoOrientationGroup")
.addComments(" DashTwoRollTransformation contains a'USE' node for the single aircraft, as well as two viewing nodes; the viewing nodes are slaved to the wingman position: one is a cockpit view, while the other is stationed approximately 20 meters behind the wingman ")
.addChild(new TransformObject("DashTwoRollTransformation").setRotation(0.0f,0.0f,1.0f,-0.15f)
.addChild(new GroupObject().setUSE("SingleAircraftGroup"))
.addChild(new ViewpointObject("Chasecam1").setDescription("Dash two chase camera").setFieldOfView(1f).setOrientation(0.0f,1.0f,0.0f,3.14f).setPosition(0.0f,5.0f,-20.0f))
.addChild(new ViewpointObject("Chasecam2").setDescription("Dash two cockpit camera").setFieldOfView(1f).setOrientation(0.0f,1.0f,0.0f,3.14f).setPosition(0.0f,0.0f,2.2f))))
.addComments(" The itnerpolators and routing nodes combine to describe the roll and position changes of the wingman ")
.addChild(new PositionInterpolatorObject("DashTwoBearingPositionInterpolator").setKey(new float[] {0.00f,0.01f,0.05f,0.25f,0.45f,0.49f,0.50f,0.51f,0.55f,0.75f,0.95f,0.9999f}).setKeyValue(new MFVec3fObject(new float[] {15.0f,5.0f,-15.0f,14.0f,5.0f,-15.0f,12.0f,5.0f,-15.0f,0.0f,5.0f,-12.0f,-12.0f,5.0f,-8.0f,-14.0f,5.0f,-6.0f,-15.0f,5.0f,-5.0f,-14.0f,5.0f,-6.0f,-12.0f,5.0f,-8.0f,0.0f,5.0f,-12.0f,12.0f,5.0f,-15.0f,14.0f,5.0f,-15.0f})))
.addChild(new ROUTEObject().setFromNode("DashTwoBearingClock").setFromField("fraction_changed").setToNode("DashTwoBearingPositionInterpolator").setToField("set_fraction"))
.addChild(new ROUTEObject().setFromNode("DashTwoBearingPositionInterpolator").setFromField("value_changed").setToNode("DashTwoBearingTransformation").setToField("set_translation"))
.addChild(new OrientationInterpolatorObject("DashTwoRollOrientationInterpolator").setKey(new float[] {0.000f,0.004f,0.005f,0.010f,0.050f,0.250f,0.450f,0.490f,0.495f,0.496f,0.500f,0.504f,0.505f,0.510f,0.550f,0.750f,0.950f,0.990f,0.995f,0.996f}).setKeyValue(new MFRotationObject(new float[] {0.0f,0.0f,1.0f,1.000f,0.0f,0.0f,1.0f,1.000f,0.0f,0.0f,1.0f,1.000f,0.0f,0.0f,1.0f,0.990f,0.0f,0.0f,1.0f,0.950f,0.0f,0.0f,1.0f,0.600f,0.0f,0.0f,1.0f,0.050f,0.0f,0.0f,1.0f,0.010f,0.0f,0.0f,1.0f,0.000f,0.0f,0.0f,1.0f,0.000f,0.0f,0.0f,1.0f,0.000f,0.0f,0.0f,1.0f,0.000f,0.0f,0.0f,1.0f,0.000f,0.0f,0.0f,1.0f,0.010f,0.0f,0.0f,1.0f,0.050f,0.0f,0.0f,1.0f,0.600f,0.0f,0.0f,1.0f,0.950f,0.0f,0.0f,1.0f,0.990f,0.0f,0.0f,1.0f,1.000f,0.0f,0.0f,1.0f,1.000f})))
.addChild(new ROUTEObject().setFromNode("DashTwoBearingClock").setFromField("fraction_changed").setToNode("DashTwoRollOrientationInterpolator").setToField("set_fraction"))
.addChild(new ROUTEObject().setFromNode("DashTwoRollOrientationInterpolator").setFromField("value_changed").setToNode("DashTwoRollTransformation").setToField("set_rotation")))))
.addChild(new ViewpointObject("Chasecam3").setDescription("Section chase camera").setFieldOfView(1f).setOrientation(0.0f,1.0f,0.0f,3.14f).setPosition(0.0f,5.0f,-35.0f)))
.addChild(new OrientationInterpolatorObject("AircraftPathOrientationInterpolator").setKey(new float[] {0.0f,0.5f,1.0f}).setKeyValue(new MFRotationObject(new float[] {0.0f,1.0f,0.0f,0.0f,0.0f,1.0f,0.0f,-3.14f,0.0f,1.0f,0.0f,-6.28f})))
.addChild(new ROUTEObject().setFromNode("AircraftPathClock").setFromField("fraction_changed").setToNode("AircraftPathOrientationInterpolator").setToField("set_fraction"))
.addChild(new ROUTEObject().setFromNode("AircraftPathOrientationInterpolator").setFromField("value_changed").setToNode("AircraftPathTransformation").setToField("set_rotation"))
.addComments(" The overhead view is transformed up along the Y-axis prior to orienting it straight downward ")
.addChild(new TransformObject("OverheadViewTransform").setTranslation(0.0f,40.0f,0.0f)
.addChild(new ViewpointObject("Overheadcam").setDescription("Overhead view of cruise turns").setFieldOfView(2f).setOrientation(1.0f,0.0f,0.0f,-1.57f)))));
}
// end of initialize() method
/** The initialized model object, created within initialize() method. */
private X3DObject x3dModel;
/** Provide a
* shallow copy
* of the X3D model.
* @see X3DObject
* @return SuperCobraSectionFormBearingDisplay model
*/
public X3DObject 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 X3DObject.handleArguments(args)
* @see X3DObject.validationReport()
* @see CommandLine
* @see CommandLine.USAGE
* @see ConfigurationProperties
*/
public static void main(String args[])
{
X3DObject thisExampleX3dObject = new SuperCobraSectionFormBearingDisplay().getX3dModel();
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(X3DObject.FILE_EXTENSION_X3D) ||
arg.toLowerCase().endsWith(X3DObject.FILE_EXTENSION_CLASSICVRML) ||
arg.toLowerCase().endsWith(X3DObject.FILE_EXTENSION_X3DB) ||
arg.toLowerCase().endsWith(X3DObject.FILE_EXTENSION_VRML97) ||
arg.toLowerCase().endsWith(X3DObject.FILE_EXTENSION_EXI) ||
arg.toLowerCase().endsWith(X3DObject.FILE_EXTENSION_GZIP) ||
arg.toLowerCase().endsWith(X3DObject.FILE_EXTENSION_ZIP) ||
arg.toLowerCase().endsWith(X3DObject.FILE_EXTENSION_HTML) ||
arg.toLowerCase().endsWith(X3DObject.FILE_EXTENSION_XHTML))
{
argumentsLoadNewModel = true;
fileName = arg;
}
}
}
if (argumentsLoadNewModel)
System.out.println("WARNING: \"SuperCobraSectionFormBearingDisplay\" 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
thisExampleX3dObject.handleArguments(args);
if (validate)
{
System.out.print("Java program \"SuperCobraSectionFormBearingDisplay\" self-validation test results: ");
String validationResults = thisExampleX3dObject.validationReport();
System.out.println(validationResults);
}
}
}