import classpath

from org.web3d.x3d.jsail.Core.X3DObject import X3DObject as X3D
from org.web3d.x3d.jsail.fields.SFStringObject import SFStringObject as SFString
from org.web3d.x3d.jsail.Core.headObject import headObject as head
from org.web3d.x3d.jsail.Core.metaObject import metaObject as meta
from org.web3d.x3d.jsail.Core.SceneObject import SceneObject as Scene
from org.web3d.x3d.jsail.Grouping.GroupObject import GroupObject as Group
from org.web3d.x3d.jsail.Navigation.ViewpointObject import ViewpointObject as Viewpoint
from org.web3d.x3d.jsail.fields.SFVec3fObject import SFVec3fObject as SFVec3f
from org.web3d.x3d.jsail.Grouping.TransformObject import TransformObject as Transform
from org.web3d.x3d.jsail.fields.SFRotationObject import SFRotationObject as SFRotation
from org.web3d.x3d.jsail.Shape.ShapeObject import ShapeObject as Shape
from org.web3d.x3d.jsail.Geometry3D.SphereObject import SphereObject as Sphere
from org.web3d.x3d.jsail.Shape.AppearanceObject import AppearanceObject as Appearance
from org.web3d.x3d.jsail.Shape.MaterialObject import MaterialObject as Material
from org.web3d.x3d.jsail.fields.SFColorObject import SFColorObject as SFColor
from org.web3d.x3d.jsail.Texturing.ImageTextureObject import ImageTextureObject as ImageTexture
from org.web3d.x3d.jsail.fields.MFStringObject import MFStringObject as MFString
from org.web3d.x3d.jsail.Text.TextObject import TextObject as Text
from org.web3d.x3d.jsail.Text.FontStyleObject import FontStyleObject as FontStyle

X3D0 = (X3D().setProfile("Immersive").setVersion("3.3")
      .setHead(head()
        .addMeta(meta().setContent("HelloWorld.x3d").setName("title"))
        .addMeta(meta().setContent("Simple X3D scene example: Hello World!").setName("description"))
        .addMeta(meta().setContent("30 October 2000").setName("created"))
        .addMeta(meta().setContent("28 July 2015").setName("modified"))
        .addMeta(meta().setContent("Don Brutzman").setName("creator"))
        .addMeta(meta().setContent("HelloWorld.tall.png").setName("Image"))
        .addMeta(meta().setContent("http://en.wikipedia.org/wiki/Hello_world").setName("reference"))
        .addMeta(meta().setContent("https://en.wikipedia.org/wiki/Hello#.22Hello.2C_World.22_computer_program").setName("reference"))
        .addMeta(meta().setContent("https://en.wikipedia.org/wiki/\"Hello,_World!\"_program").setName("reference"))
        .addMeta(meta().setContent("http://en.wikibooks.org/w/index.php?title=Computer_Programming/Hello_world").setName("reference"))
        .addMeta(meta().setContent("http://www.HelloWorldExample.net").setName("reference"))
        .addMeta(meta().setContent("http://www.web3D.org").setName("reference"))
        .addMeta(meta().setContent("http://www.web3d.org/realtime-3d/news/internationalization-x3d").setName("reference"))
        .addMeta(meta().setContent("http://www.web3d.org/x3d/content/examples/HelloWorld.x3d").setName("reference"))
        .addMeta(meta().setContent("http://X3dGraphics.com/examples/X3dForAdvancedModeling/HelloWorldScenes").setName("reference"))
        .addMeta(meta().setContent("http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorld.x3d").setName("identifier"))
        .addMeta(meta().setContent("http://www.web3d.org/x3d/content/examples/license.html").setName("license"))
        .addMeta(meta().setContent("X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit").setName("generator"))
        # Alternate encodings: VRML97, X3D ClassicVRML Encoding, X3D Compressed Binary Encoding (CBE), X3DOM, JSON 
        .addMeta(meta().setContent("HelloWorld.wrl").setName("reference"))
        .addMeta(meta().setContent("HelloWorld.x3dv").setName("reference"))
        .addMeta(meta().setContent("HelloWorld.x3db").setName("reference"))
        .addMeta(meta().setContent("HelloWorld.xhtml").setName("reference"))
        .addMeta(meta().setContent("HelloWorld.json").setName("reference")))
      .setScene(Scene()
        # Example scene to illustrate X3D nodes and fields (XML elements and attributes) 
        .addChild(Group()
          .addChild(Viewpoint().setDEF("ViewUpClose").setCenterOfRotation(0,-1,0).setDescription("Hello world!").setPosition(0,-1,7))
          .addChild(Transform().setRotation(0,1,0,3)
            .addChild(Shape()
              .setGeometry(Sphere())
              .setAppearance(Appearance()
                .setMaterial(Material().setDEF("MaterialLightBlue").setDiffuseColor(0.1,0.5,1))
                .setTexture(ImageTexture().setDEF("ImageCloudlessEarth").setUrl(["earth-topo.png","earth-topo.jpg","earth-topo-small.gif","http://www.web3d.org/x3d/content/examples/Basic/earth-topo.png","http://www.web3d.org/x3d/content/examples/Basic/earth-topo.jpg","http://www.web3d.org/x3d/content/examples/Basic/earth-topo-small.gif"])))))
          .addChild(Transform().setTranslation(0,-2,0)
            .addChild(Shape()
              .setGeometry(Text().setDEF("TextMessage").setString(["Hello","world!"])
                .setFontStyle(FontStyle().setJustify(["MIDDLE","MIDDLE"])))
              .setAppearance(Appearance()
                .setMaterial(Material().setUSE("MaterialLightBlue"))))))))

X3D0.toFileX3D("/x3d-code/www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter01TechnicalOverview//HelloWorld_RoundTrip.x3d")
