#################################################################################################### # # Invoking X3D model self-test: # # $ python RearWindow.py # # Python package x3d.py package is available on PyPI for import. # This approach simplifies Python X3D deployment and use. # https://pypi.org/project/x3d # # Installation: # pip install x3d # or # python -m pip install x3d # # Developer options for loading x3d package in other Python programs: # # from x3d import * # preferred approach, terser source that avoids x3d.* class prefixes # # or # import x3d # traditional way to subclass x3d package, all classes require x3d.* prefix, # # but python source is very verbose, for example x3d.Material x3d.Shape etc. # # X3dToPython.xslt stylesheet insertPackagePrefix=true supports this option. # #################################################################################################### from x3d import * newModel=X3D(profile='Immersive',version='3.1', head=head( children=[ meta(content='RearWindow.x3d',name='title'), meta(content='Rear window from the balck midsize truck',name='description'), meta(content='Donald Coomes',name='creator'), meta(content='25 August 2006',name='created'), meta(content='20 October 2019',name='modified'), meta(content='X3D-Edit, Wings3d, and Flux Studio',name='generator'), meta(content='https://savage.nps.edu/Savage/GroundVehicles/Truck/RearWindow.x3d',name='identifier'), meta(content='../../license.html',name='license')]), Scene=Scene( children=[ WorldInfo(title='RearWindow.x3d'), Group(DEF='WindowRear', children=[ Transform(DEF='RearWindow', children=[ Shape( appearance=Appearance( material=Material(DEF='ClearGlass',diffuseColor=(0,0,.25),transparency=.5)), geometry=IndexedFaceSet(colorIndex=[0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,-1],coordIndex=[0,5,16,-1,0,16,19,-1,0,19,18,-1,0,18,3,-1,1,2,11,-1,1,11,10,-1,1,10,9,-1,1,9,4,-1,2,7,8,-1,2,8,11,-1,3,18,17,-1,3,17,6,-1,4,7,15,-1,4,15,14,-1,4,9,8,-1,4,8,7,-1,4,14,13,-1,4,13,5,-1,5,6,17,-1,5,17,16,-1,5,13,12,-1,5,12,6,-1,6,12,15,-1,6,15,7,-1,8,9,10,-1,8,10,11,-1,12,13,14,-1,12,14,15,-1,16,17,18,-1,16,18,19,-1],creaseAngle=0.524, coord=Coordinate(point=[(-1.9369,1.57058,-2.11829),(1.91838,1.5812,-2.11852),(1.83455,1.58097,-2.08952),(-1.85159,1.57081,-2.08979),(1.76023,1.69121,-2.11851),(-1.75893,1.68151,-2.1183),(-1.73,1.68159,-2.08964),(1.73278,1.69113,-2.08967),(1.7344,.99762,-2.08967),(1.76185,.99769,-2.11851),(1.92,.88768,-2.11852),(1.83617,.88745,-2.08952),(-1.72838,.98808,-2.08964),(-1.75731,.988,-2.1183),(1.76185,.99769,-2.11851),(1.7344,.99762,-2.08967),(-1.75731,.988,-2.1183),(-1.72838,.98808,-2.08964),(-1.84997,.8773,-2.08979),(-1.93528,.87706,-2.11829)])))]), TimeSensor(DEF='RearWindowClock',cycleInterval=8.000), TouchSensor(DEF='RearWindowSensor',description='Touch to roll down rear window')]), PositionInterpolator(DEF='RearWindowPI',key=[0,.25,.49997,.75,1],keyValue=[(0,0,0),(0,-.4,0),(0,-.65,0),(0,-.4,0),(0,0,0)]), ROUTE(fromField='fraction_changed',fromNode='RearWindowClock',toField='set_fraction',toNode='RearWindowPI'), ROUTE(fromField='value_changed',fromNode='RearWindowPI',toField='set_translation',toNode='RearWindow'), ROUTE(fromField='touchTime',fromNode='RearWindowSensor',toField='startTime',toNode='RearWindowClock')]) ) # X3D model complete #################################################################################################### # Self-test diagnostics #################################################################################################### print('Self-test diagnostics for RearWindow.py:') if metaDiagnostics(newModel): # built-in utility method in X3D class print(metaDiagnostics(newModel)) # display meta info, hint, warning, error, TODO values in this model # print('check newModel.XML() serialization...') newModelXML= newModel.XML() # test export method XML() for exceptions during export newModel.XMLvalidate() # print(newModelXML) # diagnostic try: # print('check newModel.VRML() serialization...') newModelVRML=newModel.VRML() # test export method VRML() for exceptions during export # print(prependLineNumbers(newModelVRML)) # debug print("Python-to-VRML export of VRML output successful", flush=True) except Exception as err: # usually BaseException # https://stackoverflow.com/questions/18176602/how-to-get-the-name-of-an-exception-that-was-caught-in-python print("*** Python-to-VRML export of VRML output failed:", type(err).__name__, err) if newModelVRML: # may have failed to generate print(prependLineNumbers(newModelVRML, err.lineno)) try: # print('check newModel.JSON() serialization...') newModelJSON=newModel.JSON() # test export method JSON() for exceptions during export # print(prependLineNumbers(newModelJSON)) # debug print("Python-to-JSON export of JSON output successful (under development)") except Exception as err: # usually SyntaxError print("*** Python-to-JSON export of JSON output failed:", type(err).__name__, err) if newModelJSON: # may have failed to generate print(prependLineNumbers(newModelJSON,err.lineno)) print("python RearWindow.py load and self-test diagnostics complete.")