package X3dForAdvancedModeling.GeometricShapes;
/*
Copyright (c) 1995-2022 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 (https://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 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.Lighting.*;
import org.web3d.x3d.jsail.Navigation.*;
import org.web3d.x3d.jsail.Shape.*;
// Javadoc annotations follow, see below for Java source code.
/**
*
Olympic Rings built for authoring course MV3204 using regulation colors, each approximately 5m radius. Debugging efforts showed difficulties with concave crossSection, important to set convex=false for proper rendering.
Related links: OlympicRings.java source, OlympicRings 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 Tobias Brennenstuhl
*/
public class OlympicRings
{
/** Default constructor to create this object. */
public OlympicRings ()
{
initialize();
}
/** Create and initialize the X3D model for this object. */
public final void initialize()
{
x3dModel = new X3D().setProfile(X3D.PROFILE_IMMERSIVE).setVersion(X3D.VERSION_3_3)
.setHead(new head()
.addMeta(new meta().setName(meta.NAME_TITLE ).setContent("OlympicRings.x3d"))
.addMeta(new meta().setName(meta.NAME_DESCRIPTION).setContent("Olympic Rings built for authoring course MV3204 using regulation colors, each approximately 5m radius. Debugging efforts showed difficulties with concave crossSection, important to set convex=false for proper rendering."))
.addMeta(new meta().setName(meta.NAME_CREATOR ).setContent("Tobias Brennenstuhl"))
.addMeta(new meta().setName(meta.NAME_CREATED ).setContent("10 December 2019"))
.addMeta(new meta().setName(meta.NAME_MODIFIED ).setContent("13 April 2020"))
.addMeta(new meta().setName(meta.NAME_REFERENCE ).setContent("CircleCalculator.xlsx"))
.addMeta(new meta().setName(meta.NAME_REFERENCE ).setContent("https://en.wikipedia.org/wiki/Olympic_symbols"))
.addMeta(new meta().setName(meta.NAME_DRAWING ).setContent("https://en.wikipedia.org/wiki/Olympic_symbols#/media/File:Olympic_rings_without_rims.svg"))
.addMeta(new meta().setName(meta.NAME_IMAGE ).setContent("OlympicRings.FreeWRL.png"))
.addMeta(new meta().setName(meta.NAME_IMAGE ).setContent("OlympicRings.H3dViewer.png"))
.addMeta(new meta().setName(meta.NAME_IMAGE ).setContent("OlympicRings.InstantReality.png"))
.addMeta(new meta().setName(meta.NAME_IMAGE ).setContent("OlympicRings.Octaga.png"))
.addMeta(new meta().setName(meta.NAME_IMAGE ).setContent("OlympicRings.view3dScene.png"))
.addMeta(new meta().setName(meta.NAME_IMAGE ).setContent("OlympicRings.XJ3dBrowser.png"))
.addMeta(new meta().setName(meta.NAME_REFERENCE ).setContent("OlympicRingsBlender.blend"))
.addMeta(new meta().setName(meta.NAME_REFERENCE ).setContent("OlympicRingsBlender.png"))
.addMeta(new meta().setName(meta.NAME_REFERENCE ).setContent("OlympicRingsBlender.original.txt"))
.addMeta(new meta().setName(meta.NAME_REFERENCE ).setContent("OlympicRingsBlender.x3d"))
.addMeta(new meta().setName(meta.NAME_REFERENCE ).setContent("ExtrusionCrossSectionSelfIntersectingView3dsceneVisualization.mp4"))
.addMeta(new meta().setName(meta.NAME_REFERENCE ).setContent("https://twitter.com/Web3DConsortium/status/1245370306417418240"))
.addMeta(new meta().setName(meta.NAME_SUBJECT ).setContent("Olympic Rings"))
.addMeta(new meta().setName(meta.NAME_GENERATOR ).setContent("X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"))
.addMeta(new meta().setName(meta.NAME_REFERENCE ).setContent("https://gitlab.nps.edu/Savage/mv3204x3dforwebauthors/blob/master/assignments/DirectedStudy/Tobias/Scenes/OlympicRings.x3d"))
.addMeta(new meta().setName(meta.NAME_IDENTIFIER ).setContent("https://x3dgraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/OlympicRings.x3d"))
.addMeta(new meta().setName(meta.NAME_LICENSE ).setContent("../license.html")))
.setScene(new Scene()
.addChild(new WorldInfo().setTitle("OlympicRings.x3d"))
.addChild(new NavigationInfo().setHeadlight(false))
.addChild(new PointLight("PointLight").setLocation(0.0,0.0,45.0))
.addChild(new Viewpoint("OlympicRingsFromInFront").setDescription("Regulation color Olympic Rings").setPosition(0.0,0.0,45.0))
.addChild(new Background().setSkyColor(new MFColor(new double[] {0.2,0.2,0.2})))
.addChild(new Transform("AllRings").setTranslation(0.0,2.0,0.0)
.addChild(new Transform().setRotation(1.0,0.0,0.0,1.6).setTranslation(-11.0,2.5,0.1)
.addChild(new Shape()
.setGeometry(new Extrusion("RingExtrusion").setConvex(false).setCrossSection(getRingExtrusion_6_32_crossSection()).setSolid(false)
.addComments(" spine is open, crossSection is closed "))
.setAppearance(new Appearance()
.setMaterial(new Material("StrongBlue").setDiffuseColor(0.003922,0.52549,0.768627)))))
.addChild(new Transform().setRotation(1.0,0.0,0.0,1.54).setTranslation(0.0,2.5,-0.1)
.addChild(new Shape()
.setGeometry(new Extrusion().setUSE("RingExtrusion"))
.setAppearance(new Appearance()
.setMaterial(new Material("SolidBlack").setDiffuseColor(0.0,0.0,0.0)))))
.addChild(new Transform().setRotation(1.0,0.0,0.0,1.50).setTranslation(11.0,2.5,-0.21)
.addChild(new Shape()
.setGeometry(new Extrusion().setUSE("RingExtrusion"))
.setAppearance(new Appearance()
.setMaterial(new Material("StrongRed").setDiffuseColor(0.933333333,0.188235294,0.298039216)))))
.addChild(new Transform().setRotation(1.0,0.0,0.0,1.57).setTranslation(-5.5,-3.0,0.0)
.addChild(new Shape()
.setGeometry(new Extrusion().setUSE("RingExtrusion"))
.setAppearance(new Appearance()
.setMaterial(new Material("MustardYellow").setDiffuseColor(0.984313725,0.701960784,0.184313725)))))
.addChild(new Transform().setRotation(1.0,0.0,0.0,1.52).setTranslation(5.5,-3.0,0.1)
.addChild(new Shape()
.setGeometry(new Extrusion().setUSE("RingExtrusion"))
.setAppearance(new Appearance()
.setMaterial(new Material("OlympicGreen").setDiffuseColor(0.082352941,0.549019608,0.223529412)))))));
}
// end of initialize() method
/** Large attribute array: Extrusion DEF='RingExtrusion' crossSection field, scene-graph level=6, element #32, 150 total numbers made up of 75 2-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 MFVec2f getRingExtrusion_6_32_crossSection()
{
MFVec2f RingExtrusion_6_32_crossSection = new MFVec2f(new double[] {4.924039,0.868241,4.698463,1.710101,4.330127,2.5,3.830222,3.213938,3.213938,3.830222,2.5,4.330127,1.710101,4.698463,0.868241,4.924039,0.0,5.0,-0.868241,4.924039,-1.710101,4.698463,-2.5,4.330127,-3.213938,3.830222,-3.830222,3.213938,-4.330127,2.5,-4.698463,1.710101,-4.924039,0.868241,-5.0,0.0,-4.924039,-0.868241,-4.698463,-1.710101,-4.330127,-2.5,-3.830222,-3.213938,-3.213938,-3.830222,-2.5,-4.330127,-1.710101,-4.698463,-0.868241,-4.924039,-0.0,-5.0,0.868241,-4.924039,1.710101,-4.698463,2.5,-4.330127,3.213938,-3.830222,3.830222,-3.213938,4.330127,-2.5,4.698463,-1.710101,4.924039,-0.868241,5.0,-0.0,4.5,0.0,4.431635,-0.781417,4.228617,-1.539091,3.897114,-2.25,3.4472,-2.892544,2.892544,-3.4472,2.25,-3.897114,1.539091,-4.228617,0.781417,-4.431635,-0.0,-4.5,-0.781417,-4.431635,-1.539091,-4.228617,-2.25,-3.897114,-2.892544,-3.4472,-3.4472,-2.892544,-3.897114,-2.25,-4.228617,-1.539091,-4.431635,-0.781417,-4.5,0.0,-4.431635,0.781417,-4.228617,1.539091,-3.897114,2.25,-3.4472,2.892544,-2.892544,3.4472,-2.25,3.897114,-1.539091,4.228617,-0.781417,4.431635,0.0,4.5,0.781417,4.431635,1.539091,4.228617,2.25,3.897114,2.892544,3.4472,3.4472,2.892544,3.897114,2.25,4.228617,1.539091,4.431635,0.781417,4.5,0.0,5.0,0.0,4.924039,0.868241});
return RingExtrusion_6_32_crossSection;
}
/** The initialized model object, created within initialize() method. */
private X3D x3dModel;
/**
* Provide a
* shallow copy
* of the X3D model.
* @see X3D
* @return OlympicRings 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 X3D.handleArguments(args)
* @see X3D.validationReport()
* @see CommandLine
* @see CommandLine.USAGE
* @see ConfigurationProperties
*/
public static void main(String args[])
{
X3D thisExampleX3dModel = new OlympicRings().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(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: \"X3dForAdvancedModeling.GeometricShapes.OlympicRings\" 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.print("Java program \"X3dForAdvancedModeling.GeometricShapes.OlympicRings\" self-validation test results: ");
String validationResults = thisExampleX3dModel.validationReport();
if (validationResults.startsWith("\n"))
System.out.println();
System.out.println(validationResults.trim());
}
}
}