[x3d-public] I played a little. Re: Scene Access Interface: autogenerating Python

John Carlson yottzumm at gmail.com
Fri Aug 11 05:41:28 PDT 2017


Hi Masaki, I am well aware of the shortcomings of X3Dautoclass.py, but do
not have an instant solution.   We either need to upgrade pyjnius, or
generate a more complete API instead of X3Dautoclass.py which interfaces
with X3DJSAIL, or generate a pure Python API.  Or potentially there's some
setup issue.

My reasoning behind showing HelloWorld.py was to show a baseline concrete
API usage so that we could easily generate from X3D XML or X3D JSON.
Ideally, concrete classes in the future Python API would follow this
pattern to make it similar to the Java API.

I am showing a use case or a user story which the Python API should try to
match.

This was Don's request.   I can provide many more examples and a whole
testing environment for generating example python from X3D Resources
examples.  I can also modify my Python serializer to generate alternate
Python, if you have something else in mind.

I am looking forward to working with you on the Python API testing.

Sincerely,

John Carlson

On Aug 11, 2017 8:13 AM, "Masaki Aono" <aono at tut.jp> wrote:

> Dear John Carlson,  to whom it may concern;
>
> Thank you for sending HelloWorld.py.
>
> I could play with it to some extent on my laptop (Windows 10).
>
> I am not certain if I send an error report to you all.
>
> If this is not the place for discussion, please forgive me.
>
>
> C:\Aono\ISO-H29\Arlington\Python\pythonSAI>python
> Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:25:24)
> [MSC v.1900 64 bit (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from jnius import autoclass
> >>> from X3Dautoclass import *
> >>> X3D0 =  X3DObject().setProfile("Immersive").setVersion("3.3")
> >>> head1 = headObject()
> >>> meta2 = metaObject().setName("title").setContent("HelloWorld.x3d")
> >>> meta3 = metaObject().setName("description").setContent("Simple X3D
> scene example: Hello World!")
> >>> head1.addMeta(meta3)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b1aabf68
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f955928 at 0x247b460aa50>>
> >>> meta4 = metaObject().setName("created").setContent("30 October 2000")
> >>> head1.addMeta(meta4)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b46cfe08
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f955948 at 0x247b4629870>>
> >>> meta5 = metaObject().setName("modified").setContent("14 April 2017")
> >>> head1.addMeta(meta5)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b46cfa40
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f955970 at 0x247b4629cb0>>
> >>> meta6 = metaObject().setName("creator").setContent("Don Brutzman")
> >>> head1.addMeta(meta6)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b46cfaf0
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f955998 at 0x247b4629b90>>
> >>> meta7 = metaObject().setName("Image").setContent("HelloWorld.tall.
> png")
> >>> head1.addMeta(meta7)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b46cf2b0
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f9559c0 at 0x247b4629a50>>
> >>> meta8 = metaObject().setName("reference").setContent("http:/
> /en.wikipedia.org/wiki/Hello_world"
> <http://en.wikipedia.org/wiki/Hello_world>)
> >>> head1.addMeta(meta8)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b49f9af0
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f9559e0 at 0x247b4629150>>
> >>> meta9 = metaObject().setName("reference").setContent("https:
> //en.wikipedia.org/wiki/Hello#.22Hello.2C_World.22_computer_program"
> <https://en.wikipedia.org/wiki/Hello#.22Hello.2C_World.22_computer_program>
> )
> >>> head1.addMeta(meta9)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b49f9eb8
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f955a00 at 0x247b4629070>>
> >>> meta10 = metaObject().setName("reference").setContent("https:
> //en.wikipedia.org/wiki/\" <https://en.wikipedia.org/wiki/%5C>Hell
> o,_World!\"_program")
> >>> head1.addMeta(meta10)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b46b2a98
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f955a60 at 0x247b46290d0>>
> >>> head1.addMeta(meta10)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b49f9af0
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f955a68 at 0x247b4629a50>>
> >>> meta11 = metaObject().setName("reference").setContent("http:/
> /en.wikibooks.org/w/index.php?title=Computer_Programming/Hello_world"
> <http://en.wikibooks.org/w/index.php?title=Computer_Programming/Hello_world>
> )
> >>> head1.addMeta(meta11)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b46b24c0
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f955a88 at 0x247b4629730>>
> >>> meta12 = metaObject().setName("reference").setContent("http:/
> /www.HelloWorldExample.net" <http://www.HelloWorldExample.net>)
> >>> head1.addMeta(meta12)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b49f9eb8
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f955aa8 at 0x247b4629170>>
> >>> meta13 = metaObject().setName("reference").setContent("http:/
> /www.web3D.org" <http://www.web3D.org>)
> >>> head1.addMeta(meta13)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b46b2468
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f955ac8 at 0x247b46292b0>>
> >>> meta14 = metaObject().setName("reference").setContent("http:/
> /www.web3d.org/realtime-3d/news/internationalization-x3d"
> <http://www.web3d.org/realtime-3d/news/internationalization-x3d>)
> >>> head1.addMeta(meta14)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b46b2d58
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f955ae8 at 0x247b4629430>>
> >>> meta15 = metaObject().setName("reference").setContent("http:/
> /www.web3d.org/x3d/content/examples/HelloWorld.x3d"
> <http://www.web3d.org/x3d/content/examples/HelloWorld.x3d>)
> >>> head1.addMeta(meta15)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b493f360
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f955b18 at 0x247b4629390>>
> >>> meta16 = metaObject().setName("reference").setContent("http:/
> /X3dGraphics.com/examples/X3dForAdvancedModeling/HelloWorldScenes"
> <http://X3dGraphics.com/examples/X3dForAdvancedModeling/HelloWorldScenes>)
> >>> head1.addMeta(meta16)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b493f468
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f955b38 at 0x247b46295d0>>
> >>> meta17 = metaObject().setName("identifier").setContent("http:
> //X3dGraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/
> HelloWorld.x3d"
> <http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorld.x3d>
> )
> >>> head1.addMeta(meta17)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b493f410
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f954798 at 0x247b4629670>>
> >>> meta18 = metaObject().setName("license").setContent("http://www.
> web3d.org/x3d/content/examples/license.html"
> <http://www.web3d.org/x3d/content/examples/license.html>)
> >>> head1.addMeta(meta18)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b493f4c0
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f9547c0 at 0x247b4629690>>
> >>> meta19 = metaObject().setName("generator").setContent("X3D-Edit 3.3,
> https://savage.nps.edu/X3D-Edit")
> >>> head1.addMeta(meta19)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b493f570
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f9547e8 at 0x247b46296b0>>
> >>> meta20 = metaObject().setName("reference").setContent("
> HelloWorld.wrl")
> >>> head1.addMeta(meta20)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b493fb48
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f954808 at 0x247b46295b0>>
> >>> meta21 = metaObject().setName("reference").setContent("
> HelloWorld.x3dv")
> >>> head1.addMeta(meta21)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b493f5c8
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f954828 at 0x247b46296d0>>
> >>> meta22 = metaObject().setName("reference").setContent("
> HelloWorld.x3db")
> >>> head1.addMeta(meta22)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b493fa40
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f954850 at 0x247b46296f0>>
> >>> meta23 = metaObject().setName("reference").setContent("
> HelloWorld.xhtml")
> >>> head1.addMeta(meta23)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b4a118e0
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f954878 at 0x247b4629750>>
> >>> meta24 = metaObject().setName("reference").setContent("
> HelloWorld.json")
> >>> head1.addMeta(meta24)
> <org.web3d.x3d.jsail.Core.headObject at 0x247b4a11048
> jclass=org/web3d/x3d/jsail/Core/headObject jself=<LocalRef
> obj=0x-4f955f58 at 0x247b4629950>>
> >>>
> >>> head1.addComments(CommentsBlock("Alternate encodings: VRML97, X3D
> ClassicVRML Encoding, X3D Compressed Binary Encoding (CBE), X3DOM, JSON"))
> <org.web3d.x3d.jsail.X3DConcreteElement at 0x247b46e1048
> jclass=org/web3d/x3d/jsail/X3DConcreteElement jself=<LocalRef
> obj=0x-4f955c80 at 0x247b460aa30>>
> >>> X3D0.setHead(head1)
> <org.web3d.x3d.jsail.Core.X3DObject at 0x247b49f9af0
> jclass=org/web3d/x3d/jsail/Core/X3DObject jself=<LocalRef obj=0x-4f954dc8
> at 0x247b46299b0>>
> >>> Scene25 = SceneObject()
> >>>
> >>> Scene25.addComments(CommentsBlock("Example scene to illustrate X3D
> nodes and fields (XML elements and attributes)"))
> <org.web3d.x3d.jsail.X3DConcreteElement at 0x247b4a1fe60
> jclass=org/web3d/x3d/jsail/X3DConcreteElement jself=<LocalRef
> obj=0x-4f954de0 at 0x247b46299f0>>
> >>> WorldInfo26 = WorldInfoObject().setTitle("Hello world!")
> >>> Scene25.addChild(WorldInfo26)
> <org.web3d.x3d.jsail.Core.SceneObject at 0x247b4a48678
> jclass=org/web3d/x3d/jsail/Core/SceneObject jself=<LocalRef
> obj=0x-4f955838 at 0x247b4629a10>>
> >>> Group27 = GroupObject()
> >>> Viewpoint28 = ViewpointObject().setDEF("ViewUpClose").
> setCenterOfRotation([0,-1,0]).setDescription("Hello
> world!").setPosition([0,-1,7])
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> AttributeError: 'org.web3d.x3d.sai.Navigation.X3DViewpointNode' object
> has no attribute 'setCenterOfRotation'
>
>
> At this point, I encountered the above error.
>
> It looks like "setCenterOfRotation" may not be in X3DViewpointNode (I may
> be wrong).
>
> Please note that Python 3.6 (which is not Python 2.7) is not a problem
> here, I think.
>
> Sincerely,
>
>
>
>
> On 2017/08/11 8:11, John Carlson wrote:
>
> Here is HelloWorld.py as generated from my PythonSerializer.js.   Note
> that I do not use chained calls.
>
> This is because I was trying to get pyjnius to work. If we had some way of
> getting code like this running, it would be great.  I could modify my
> PythonSerializer.js and perhaps include the serializer in X3DJSAIL.
>
>
>
> My JavaScript serializer does not work in X3DJSAIL yet, and I have not
> been working on it since my initial attempt.  I have compatible,
> containable changes to the X3DJSAIL stylesheet so that X3DJSAIL should be
> able to generate JavaScript “SAI”/Nashorn application code.
>
>
>
> The problem appears to be getting the JavaScript XML parsers integrated
> with X3DJSAIL. We may be able to use JSON instead: XML -> JSON -> DOM ->
> python.  The long way around, instead of XML -> DOM -> python.
>
>
>
> Or we can just use my serializer in JavaScript, and translate JSON -> DOM
> -> python. The XML to JSON would be handled by X3dToJson.xslt (X3DJSAIL).
>
>
>
> I do have examples of Java -> TypeScript and JavaScript, but they don’t
> work.
>
>
>
> I do not have a Java -> Python translator.  Good luck finding one.
>
>
>
> John
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>
> *From: *Don Brutzman <brutzman at nps.edu>
> *Sent: *Thursday, August 10, 2017 5:31 PM
> *To: *Myeong Won Lee <mwlee at suwon.ac.kr>; Masaki Aono <aono at tut.jp>; Roy
> Walmsley <roy.walmsley at ntlworld.com>; John Carlson <yottzumm at gmail.com>
> *Cc: *X3D Graphics public mailing list <x3d-public at web3d.org>
> *Subject: *Scene Access Interface: autogenerating Python
>
>
>
> Myeong Won Lee and Masaki Aono:
>
>
>
> Thank you for meeting today to discuss X3D Object Model transformation by
> applying an XSLT stylesheet to autogenerate of SAI codebases.
>
>
>
> Myeong Won Lee, I also thought that your Unity HAnim player is wonderful.
> I recommend that you include some examples in the public release, they will
> generate strong interest.  Having some public examples while also allowing
> private examples provides appealing choices and the best possible support
> for your students.
>
>
>
> Here is summary excerpted from this week's Web3D meeting report.
>
> ================================================================
>
> 3.            Object Model for X3D (OM4X3D)
>
> a.            The Object Model for X3D (OM4X3D) is a full set of
> object-oriented interfaces for all nodes, fields and statements in the X3D
> Abstract Specification.
>
> b.            OM4X3D is produced by decorating the X3D XML Schema with
> carefully structured annotations that describe the entire object-oriented
> nature of the X3D scene graph. http://www.web3d.org/specifications/OM4X3D/
> ObjectModelForX3dCreation.png
>
> c.             Instantiation: Object Model for X3D definitions are
> explicitly listed in X3DObjectModel 3.3.xml with corresponding XML schema
> x3dObjectModel.xsd
>
> d.            Ongoing public/private dialog using the x3d-public at web3D.org
> mailing list and presentation at Web3D 2017 Conference has been productive.
> http://www.web3d.org/specifications/OM4X3D/ObjectModelForX3dMasterClassWe
> b3dConference2017June7.pdf
>
> e.            Demonstration of strict object model in X3D JSON Encoding,
> which is 98% complete and undergoing extensive review and testing,
> initial-draft specification has been prepared.
>
> f.             Initial implementations are available in JavaScript, Java,
> and C++.  Also planning to prepare programming-language implementations for
> C, C#.
>
> g.            Two new versions for Python are started, with dialog
> occurring to discern best practices.
>
> h.            SAI no longer just Script node in Browser object, includes
> full application-oriented API.  This will lead to some changes and
> generalizations in 19775-2 Abstract SAI specification.
>
> i.              Multiple emerging SAI specifications and implementations
> are shown on updated  draft X3D Specifications Relationships diagram
> (attached)
>
> j.             Implementation: X3D JSON Loader (X3DJSONLD)
> https://github.com/coderextreme/X3DJSONLD
>
> k.            Implementation: X3D Java Scene Access Interface Library
> (X3DJSAIL) http://www.web3d.org/specifications/java/
> X3dJavaSceneAuthoringInterface.html
>
> l.              Under consideration: integration into X3D Abstract
> Specification 19775-1 to more thoroughly expand on current abstract
> interface hierarchy.
>
> m.           Emerging capability: coherent X3D center, multiple different
> programming languages that offer common design patterns to programmers to
> create identical scene graphs.
>
> ================================================================
>
>
>
> The essence of autogeneration is that proper code patterns must first
> exist.  Once we get a few classes with the design patterns of interest, and
> generation of a few classes, then creation of all classes follows in a
> straightforward manner.
>
>
>
> I recommend that the first example we work with is HelloWorld.x3d into .c
> .cpp .cs and .py source.
>
>                 http://www.web3d.org/x3d/content/examples/HelloWorld.x3d
>
>                 http://www.web3d.org/x3d/content/examples/HelloWorld.html
>
>
>
> Regarding Python: John Carlson has done intriguing work that
> auto-translates Java source in X3DJSAIL to Python.  This is interesting
> because it would keep the codebases closely aligned, making it easier to
> learn and debug.  Consistency is easily maintained across X3D versions and
> X3D bugfixes by re-running each distribution.  Flexibility is also possible
> since each codebase will include custom utility classes, methods and
> examples.
>
>
>
> Next steps for Python: recommend that we
>
> - Examine Masaki's work and compare it with the pyjnius conversions.
>
> - Autogenerate Python library (X3DPSAIL perhaps?) to provide Python
> codebase support.
>
> - Iterate until we have a good design pattern for HelloWorld and other
> exemplars.
>
> - Create an X3dToPython.xslt stylesheet that can convert someModel.x3d to
> someModel.py source.
>
> - run that across all scenes X3D Example Archives, detect and resolve
> errors, publish builds.
>
> - make T-shirts  8)
>
>
>
> As with JavaScript and Java, it is good to use the x3d-public list for
> this work.  Also suitable for a weekly update reports and monthly telcon
> item for X3D Working Group.
>
>
>
> 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 <(831)%20656-2149>
>
> X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/
> brutzman
>
>
>
>
> --
> ******************************************************
> 青野雅樹
> 豊橋技術科学大学 情報・知能工学系
> 知識データ工学・情報検索研究室
> 〒441-8580 豊橋市天伯町雲雀ヶ丘1-1TEL:(0532) <(0532)> 44-6764
> FAX:(0532) 44-6757
>
> Masaki Aono
> Professor
> Knowledge Data Engineering Laboratory
> Dept. of Computer Science and Engineering
> Toyohashi University of Technology
> 1-1 Hibarigaoka, Tempaku-cho,
> Toyohashi-shi, Aichi 441-8580 JAPAN
> TEL: 81+532-44-6764
> FAX:81+532-44-6757
> email: aono at tut.jp
> ******************************************************
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170811/4a4c9f70/attachment-0001.html>


More information about the x3d-public mailing list