package Savage.AircraftHelicopters.AH1SuperCobraUnitedStates; /* 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.Geometry3D.*; import org.web3d.x3d.jsail.Grouping.*; import org.web3d.x3d.jsail.Interpolation.*; import org.web3d.x3d.jsail.Navigation.*; import org.web3d.x3d.jsail.PointingDeviceSensor.*; 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 annotations follow, see below for source. /** *

Prototypes a 4 blade main rotor and its shaft for a helicopter, rotating clockwise as seen from above.

Related links: FourBladeMainRotorPrototype.java source, FourBladeMainRotorPrototype catalog page, X3D Resources, X3D Scene Authoring Hints, and X3D Tooltips.

meta tags   Document Metadata
title FourBladeMainRotorPrototype.x3d
description Prototypes a 4 blade main rotor and its shaft for a helicopter, rotating clockwise as seen from above.
creator Jane Wu, Etsuko Lippi
created 21 March 2001
modified 14 February 2015
reference SuperCobraPrototype.x3d
identifier https://savage.nps.edu/Savage/AircraftHelicopters/AH1SuperCobra-UnitedStates/FourBladeMainRotorPrototype.x3d
generator X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit
license ../../license.html
 

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 Jane Wu, Etsuko Lippi */ public class FourBladeMainRotorPrototype { /** Default constructor to create this object. */ public FourBladeMainRotorPrototype () { 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("FourBladeMainRotorPrototype.x3d")) .addMeta(new metaObject().setName(metaObject.NAME_DESCRIPTION).setContent("Prototypes a 4 blade main rotor and its shaft for a helicopter, rotating clockwise as seen from above.")) .addMeta(new metaObject().setName(metaObject.NAME_CREATOR ).setContent("Jane Wu, Etsuko Lippi")) .addMeta(new metaObject().setName(metaObject.NAME_CREATED ).setContent("21 March 2001")) .addMeta(new metaObject().setName(metaObject.NAME_MODIFIED ).setContent("14 February 2015")) .addMeta(new metaObject().setName(metaObject.NAME_REFERENCE ).setContent("SuperCobraPrototype.x3d")) .addMeta(new metaObject().setName(metaObject.NAME_IDENTIFIER ).setContent("https://savage.nps.edu/Savage/AircraftHelicopters/AH1SuperCobra-UnitedStates/FourBladeMainRotorPrototype.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_LICENSE ).setContent("../../license.html"))) .setScene(new SceneObject() .addChild(new ProtoDeclareObject("FourBladeMainRotor").setName("FourBladeMainRotor") .setProtoInterface(new ProtoInterfaceObject() .addField(new fieldObject().setName("rotationOn").setType(fieldObject.TYPE_SFBOOL).setAccessType(fieldObject.ACCESSTYPE_INPUTONLY).setAppinfo("enable or disable rotor rotation"))) .setProtoBody(new ProtoBodyObject() .addChild(new TransformObject("MainRotor") .addComments(" Rotor Shaft ") .addChild(new TransformObject().setScale(0.6f,0.6f,0.6f) .addChild(new ShapeObject() .setAppearance(new AppearanceObject("ShaftColor") .setMaterial(new MaterialObject().setDiffuseColor(0.5f,0.5f,0.5f))) .setGeometry(new CylinderObject().setBottom(false).setHeight(1.5f).setRadius(0.1f).setTop(false))) .addChild(new TransformObject().setTranslation(0.0f,0.75f,0.0f) .addChild(new ShapeObject() .setAppearance(new AppearanceObject().setUSE("ShaftColor")) .setGeometry(new CylinderObject().setHeight(0.1f).setRadius(0.4f)))) .addChild(new TransformObject().setRotation(1.0f,0.0f,0.0f,1.57f).setTranslation(0.0f,0.75f,0.0f) .addChild(new ShapeObject("Arm") .setAppearance(new AppearanceObject().setUSE("ShaftColor")) .setGeometry(new CylinderObject().setHeight(1.75f).setRadius(0.05f)))) .addChild(new TransformObject().setRotation(0.0f,0.0f,1.0f,1.57f).setTranslation(0.0f,0.75f,0.0f) .addChild(new ShapeObject().setUSE("Arm"))) .addChild(new TransformObject().setTranslation(0.0f,-0.4f,0.0f) .addChild(new ShapeObject() .setAppearance(new AppearanceObject().setUSE("ShaftColor")) .setGeometry(new CylinderObject().setHeight(0.1f).setRadius(0.3f)))) .addChild(new TransformObject().setRotation(0.71f,0.02f,-0.71f,0.10f).setTranslation(0.23f,0.15f,0.23f) .addChild(new ShapeObject("Tube") .setAppearance(new AppearanceObject().setUSE("ShaftColor")) .setGeometry(new CylinderObject().setHeight(1.1f).setRadius(0.05f)))) .addChild(new TransformObject().setRotation(-0.71f,0.02f,0.71f,0.10f).setTranslation(-0.23f,0.15f,-0.23f) .addChild(new ShapeObject().setUSE("Tube"))) .addChild(new TransformObject().setRotation(0.71f,-0.02f,0.71f,0.10f).setTranslation(-0.23f,0.15f,0.23f) .addChild(new ShapeObject().setUSE("Tube"))) .addChild(new TransformObject().setRotation(-0.71f,-0.02f,-0.71f,0.10f).setTranslation(0.23f,0.15f,-0.23f) .addChild(new ShapeObject().setUSE("Tube")))) .addChild(new SwitchObject("RotationSwitch").setWhichChoice(0) .addChild(new GroupObject("FourBlades") .addComments(" Blade in x direction ") .addComments(" Rotate 90 + 15 degree along x ") .addChild(new TransformObject().setRotation(1.0f,0.0f,0.0f,1.83f).setTranslation(0.45f,0.375f,0.25f) .addChild(new ShapeObject("Blade") .setAppearance(new AppearanceObject("BladeColor") .setMaterial(new MaterialObject().setDiffuseColor(0.2f,0.2f,0.2f))) .setGeometry(new ExtrusionObject().setCcw(false).setCreaseAngle(0.8f).setCrossSection(new MFVec2fObject(new float[] {-0.10f,0.00f,0.06f,-0.01f,0.10f,-0.02f,0.16f,-0.03f,0.22f,-0.035f,0.28f,-0.03f,0.30f,-0.025f,0.32f,-0.02f,0.331f,0.00f,0.32f,0.016f,0.30f,0.018f,0.28f,0.02f,0.22f,0.02f,0.16f,0.02f,0.10f,0.018f,0.06f,0.01f,-0.10f,0.00f})).setSpine(new MFVec3fObject(new float[] {0.08f,0.0f,0.0f,5.3f,0.0f,0.0f}))))) .addComments(" Blade in -z direction ") .addComments(" Rotate 180 - 15 degree along z ") .addChild(new TransformObject().setRotation(0.0f,0.0f,1.0f,2.88f).setTranslation(0.25f,0.375f,-0.45f) .addChild(new ShapeObject() .setAppearance(new AppearanceObject().setUSE("BladeColor")) .setGeometry(new ExtrusionObject().setCcw(false).setCreaseAngle(0.8f).setCrossSection(new MFVec2fObject(new float[] {-0.10f,0.00f,0.06f,-0.01f,0.10f,-0.02f,0.16f,-0.03f,0.22f,-0.035f,0.28f,-0.03f,0.30f,-0.025f,0.32f,-0.02f,0.331f,0.00f,0.32f,0.016f,0.30f,0.018f,0.28f,0.02f,0.22f,0.02f,0.16f,0.02f,0.10f,0.018f,0.06f,0.01f,-0.10f,0.00f})).setSpine(new MFVec3fObject(new float[] {0.00f,0.0f,-0.08f,0.0f,0.0f,-5.3f}))))) .addComments(" Blade in -x direction ") .addComments(" Rotate 90 - 15 on x ") .addChild(new TransformObject().setRotation(1.0f,0.0f,0.0f,1.31f).setTranslation(-0.45f,0.375f,-0.25f) .addChild(new ShapeObject() .setAppearance(new AppearanceObject().setUSE("BladeColor")) .setGeometry(new ExtrusionObject().setCcw(false).setCreaseAngle(0.8f).setCrossSection(new MFVec2fObject(new float[] {-0.10f,0.00f,0.06f,-0.01f,0.10f,-0.02f,0.16f,-0.03f,0.22f,-0.035f,0.28f,-0.03f,0.30f,-0.025f,0.32f,-0.02f,0.331f,0.00f,0.32f,0.016f,0.30f,0.018f,0.28f,0.02f,0.22f,0.02f,0.16f,0.02f,0.10f,0.018f,0.06f,0.01f,-0.10f,0.00f})).setSpine(new MFVec3fObject(new float[] {-0.08f,0.0f,0.0f,-5.3f,0.0f,0.0f}))))) .addComments(" Blade in z direction ") .addComments(" Rotate 15 degreen on z ") .addChild(new TransformObject().setRotation(0.0f,0.0f,1.0f,0.26f).setTranslation(-0.25f,0.375f,0.45f) .addChild(new ShapeObject() .setAppearance(new AppearanceObject().setUSE("BladeColor")) .setGeometry(new ExtrusionObject().setCcw(false).setCreaseAngle(0.8f).setCrossSection(new MFVec2fObject(new float[] {-0.10f,0.00f,0.06f,-0.01f,0.10f,-0.02f,0.16f,-0.03f,0.22f,-0.035f,0.28f,-0.03f,0.30f,-0.025f,0.32f,-0.02f,0.331f,0.00f,0.32f,0.016f,0.30f,0.018f,0.28f,0.02f,0.22f,0.02f,0.16f,0.02f,0.10f,0.018f,0.06f,0.01f,-0.10f,0.00f})).setSpine(new MFVec3fObject(new float[] {0.00f,0.0f,0.08f,0.0f,0.0f,5.3f})))))) .addChild(new LODObject().setRange(new float[] {50.0f,200.0f}) .addChild(new GroupObject().setUSE("FourBlades")) .addChild(new GroupObject() .addChild(new TransformObject().setTranslation(0.0f,0.45f,0.0f) .addChild(new ShapeObject() .setAppearance(new AppearanceObject() .setMaterial(new MaterialObject().setDiffuseColor(0.2f,0.2f,0.2f).setTransparency(0.75f))) .setGeometry(new CylinderObject().setHeight(0.1f).setRadius(6f))))) .addChild(new WorldInfoObject().setTitle("null")))) .addChild(new ScriptObject("BladeRotationOnOffScript").setSourceCode("\n" + " " + "\n" + "ecmascript:" + "\n" + "\n" + "function rotationOn(value, timeStamp) {" + "\n" + " if (value == true)" + "\n" + " {" + "\n" + " clockEnabled = true;" + "\n" + " switchChoice = 1;" + "\n" + " }" + "\n" + " else" + "\n" + " {" + "\n" + " clockEnabled = false;" + "\n" + " switchChoice = 0;" + "\n" + " }" + "\n" + "}" + "\n") .addField(new fieldObject().setName("rotationOn").setType(fieldObject.TYPE_SFBOOL).setAccessType(fieldObject.ACCESSTYPE_INPUTONLY)) .addField(new fieldObject().setName("clockEnabled").setType(fieldObject.TYPE_SFBOOL).setAccessType(fieldObject.ACCESSTYPE_OUTPUTONLY)) .addField(new fieldObject().setName("switchChoice").setType(fieldObject.TYPE_SFINT32).setAccessType(fieldObject.ACCESSTYPE_OUTPUTONLY)) .setIS(new ISObject() .addConnect(new connectObject().setNodeField("rotationOn").setProtoField("rotationOn")))) .addComments(" Animation Clock ") .addChild(new TimeSensorObject("Clock").setEnabled(false).setLoop(true)) .addComments(" Animation Path ") .addChild(new OrientationInterpolatorObject("MainRotorPath").setKey(new float[] {0.0f,0.25f,0.5f,0.75f,1.0f}).setKeyValue(new MFRotationObject(new float[] {0.00f,-1.00f,0.0f,0.0f,0.00f,-1.00f,0.0f,1.571f,0.00f,-1.00f,0.0f,3.142f,0.00f,-1.00f,0.0f,4.712f,0.00f,-1.00f,0.0f,6.284f})))) .addChild(new ROUTEObject().setFromNode("BladeRotationOnOffScript").setFromField("clockEnabled").setToNode("Clock").setToField("set_enabled")) .addChild(new ROUTEObject().setFromNode("BladeRotationOnOffScript").setFromField("switchChoice").setToNode("RotationSwitch").setToField("whichChoice")) .addChild(new ROUTEObject().setFromNode("Clock").setFromField("fraction_changed").setToNode("MainRotorPath").setToField("set_fraction")) .addChild(new ROUTEObject().setFromNode("MainRotorPath").setFromField("value_changed").setToNode("MainRotor").setToField("set_rotation")))) .addComments(" ============================================================ ") .addChild(new WorldInfoObject().setTitle("FourBladeMainRotor Prototype")) .addChild(new BackgroundObject().setSkyColor(new MFColorObject(new float[] {0.9f,0.9f,0.9f}))) .addChild(new ViewpointObject().setDescription("Toggle Blade Status").setPosition(0.0f,1.0f,12.0f)) .addChild(new ViewpointObject().setDescription("At a distance").setPosition(0.0f,1.0f,50.0f)) .addChild(new ProtoInstanceObject("FourBladeMainRotor", "ExampleMainRotor")) .addChild(new TransformObject().setTranslation(0.0f,2.5f,0.0f) .addChild(new TouchSensorObject("ExampleBladeRotationToggle").setDescription("Toggle blade rotation on/off")) .addChild(new ShapeObject() .setAppearance(new AppearanceObject() .setMaterial(new MaterialObject("ToggleStatusColor").setDiffuseColor(0.6f,0.6f,0.0f))) .setGeometry(new TextObject().setString(new String[] {"Select Text to Toggle","Blade Rotation On/Off"}) .setFontStyle(new FontStyleObject().setJustify(FontStyleObject.JUSTIFY_MIDDLE_MIDDLE)))) .addChild(new ShapeObject() .setGeometry(new BoxObject().setSize(10.0f,2.0f,0.01f)) .setAppearance(new AppearanceObject() .setMaterial(new MaterialObject().setTransparency(1f))))) .addChild(new ScriptObject("ExampleSelection").setSourceCode("\n" + " " + "\n" + "ecmascript:" + "\n" + "\n" + "function toggleEnabled(value, ts) {" + "\n" + " if (armed == -1)" + "\n" + " {" + "\n" + " toggleEnabled = false;" + "\n" + " armed = 0;" + "\n" + " }" + "\n" + "\n" + " if (armed == 0)" + "\n" + " {" + "\n" + " armed = 1;" + "\n" + "\n" + " if (toggleEnabled == false)" + "\n" + " {" + "\n" + " status = true;" + "\n" + " statusColor = new SFColor(0, 0.8, 0);" + "\n" + " toggleEnabled = true;" + "\n" + " }" + "\n" + " else" + "\n" + " {" + "\n" + " status = false;" + "\n" + " statusColor = new SFColor(0.8, 0.8, 0);" + "\n" + " toggleEnabled = false;" + "\n" + " }" + "\n" + " }" + "\n" + " else" + "\n" + " {" + "\n" + " armed = 0;" + "\n" + " return;" + "\n" + " }" + "\n" + "}" + "\n") .addField(new fieldObject().setName("armed").setType(fieldObject.TYPE_SFINT32).setAccessType(fieldObject.ACCESSTYPE_INITIALIZEONLY).setValue(-1)) .addField(new fieldObject().setName("toggleEnabled").setType(fieldObject.TYPE_SFBOOL).setAccessType(fieldObject.ACCESSTYPE_INPUTONLY)) .addField(new fieldObject().setName("statusColor").setType(fieldObject.TYPE_SFCOLOR).setAccessType(fieldObject.ACCESSTYPE_OUTPUTONLY)) .addField(new fieldObject().setName("status").setType(fieldObject.TYPE_SFBOOL).setAccessType(fieldObject.ACCESSTYPE_OUTPUTONLY))) .addChild(new ROUTEObject().setFromNode("ExampleBladeRotationToggle").setFromField("isActive").setToNode("ExampleSelection").setToField("toggleEnabled")) .addChild(new ROUTEObject().setFromNode("ExampleSelection").setFromField("statusColor").setToNode("ToggleStatusColor").setToField("diffuseColor")) .addChild(new ROUTEObject().setFromNode("ExampleSelection").setFromField("status").setToNode("ExampleMainRotor").setToField("rotationOn"))); } // 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 FourBladeMainRotorPrototype 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 FourBladeMainRotorPrototype().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: \"FourBladeMainRotorPrototype\" 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 \"FourBladeMainRotorPrototype\" self-validation test results: "); String validationResults = thisExampleX3dObject.validationReport(); System.out.println(validationResults); } } }