[x3d-public] Status, X3DPSAIL: clean build achieved! next steps on Python syntax

Brutzman, Donald (Don) (CIV) brutzman at nps.edu
Tue Apr 30 09:52:56 PDT 2019


All the example archives have been published.  Am still compiling/testing the simple syntax, but only the pipeline syntax is published.

	http://www.web3d.org/x3d/content/examples/X3dResources.html#Examples

http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorldIndex.html
http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorld.py

Current version attached for perusal and archival retention, since we are likely to keep improving syntax.

Now we are finally getting to some of the more fun stuff... Here are some suggested changes in python syntax, what do you think?

- - - -

a. Work to avoid need for superfluous typing, for example SFString("hello") and SFInt32(1) and SFFloat(5.0) etc.

- - - -

b. Work to avoid need for more complex typing, as more Pythonic; most of these might be supported already, as shown in Java examples. For example:

	.setDiffuseColor(SFColor([0.1,0.5,1]))

ought to work as

	.setDiffuseColor([0.1,0.5,1))

or even
	.setDiffuseColor(0.1,0.5,1)

- - - -

c. continue field setting on single line for each node, matching readability of Java examples.  For example:

      .addChild(Transform() \
       .setTranslation(SFVec3f([0,-2,0])) \
       .addChild(Shape() \
        .setGeometry(Text() \
         .setDEF(SFString("TextMessage")) \
         .setString(MFString(["Hello","world!"])) \
         .setFontStyle(FontStyle() \
          .setJustify(MFString(["MIDDLE","MIDDLE"])) \
         ) \
        ) \
        .setAppearance(Appearance() \
         .setMaterial(Material() \
          .setUSE(SFString("MaterialLightBlue")) \
         ) \
        ) \
       ) \

to
      .addChild(Transform().setTranslation(SFVec3f([0,-2,0])) \
        .addChild(Shape() \
          .setGeometry(Text().setDEF(SFString("TextMessage")).setString(MFString(["Hello","world!"])) \
            .setFontStyle(FontStyle().setJustify(MFString(["MIDDLE","MIDDLE"])))) \
          .setAppearance(Appearance() \
            .setMaterial(Material().setUSE(SFString("MaterialLightBlue"))))) \

perhaps eye-of-the-beholder but i like indentation with 2 space characters, as shown here, since the result shows scene-graph structure.  also isolates all errors for a single node, simplifying troubleshooting.

- - - -

d. Are we ever going to be able to condense all of the imports into a single line or two?  Currently way too much work for a plain old programmer looking for something that works.

Perhaps this awaits pip module.  Or perhaps we can move the full customization into pyjnius (or even X3DJSAIL) somehow?

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

onward and upward, getting terser as we go...  having fun with X3D Python!  8)


On 4/27/2019 8:36 PM, Brutzman, Donald (Don) (CIV) wrote:
> John, great news we have long been working towards: we now have clean builds running for both syntax forms using scripts in the java/src/pyjnius directory.  8)
> 
> Example output attached for HelloWorld.x3D round tripping.  Fixed some diagnostics in X3DJSAIL also.
> 
> Everything is checked in.  Please look at the subversion diffs to see what happened, i made multiple small modifications to .xml .py and .js files but all your code is essentially intact.
> https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/java/src/python/pyjnius/
> 
> Tonite am running full regression on all X3D example archive scenes, mostly running cleanly.  Will upload log and report when done.  Unless you made a converter change, all of the SceneName.py and SceneName.future.py files will be unchanged from last time.
> 
> Suggested next steps:
> 
> a. review and tweak, further corrections, list open issues.
> b. rename our two syntax examples SceneName1.py and SceneName2.py (others may occur), republish archives.
> c. begin looking at whether pip install is possible for X3DPSAIL with a java dependency.
> d. document everything fully.
> 
> Request: am hoping you could add some more prose to your workflow powerpoint to explain what is going on at each transformation.  Some files are source, others are products.  Current version attached, TIA.
> 
> Big corner turned... incremental improvement is much easier than digging around in the fog!  Thanks for your sustained efforts on this one, totally crucial.  Higher ground is coming into view.
> 
> Have fun with X3D Python!   8)


all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: HelloWorld.py
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190430/45ad8b7f/attachment-0001.ksh>


More information about the x3d-public mailing list