#################################################################################################### # # Invoking X3D model self-test: # # $ python BlackMidSizeTruck.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='BlackMidSizeTruck.x3d',name='title'), meta(content='Donald Coomes',name='creator'), meta(content='MV3204',name='Class'), meta(content='22:29: 9',name='ExportTime'), meta(content='9/12/2006',name='ExportDate'), meta(content="No warnings, but hints for better scene portability and the inside of the rear wheel covers aren't drawn correctly from the underside",name='hints'), meta(content='complete3.fxw',name='FluxStudioSource'), meta(content='10 September 2006',name='created'), meta(content='20 October 2019',name='modified'), meta(content='A model of my 2004 Toyota Tacoma 4x4 Extended Cab Truck',name='description'), meta(content='https://savage.nps.edu/Savage/GroundVehicles/Truck/BlackMidSizeTruck.x3d',name='identifier'), meta(content='../../license.html',name='license')]), Scene=Scene( children=[ WorldInfo(info=["This Web3D World was created with Flux Studio, a Web3D authoring tool","www.mediamachines.com","Individual parts were created using Wings3D"],title='Complete3'), Group(DEF='ViewPoints', children=[ Transform(rotation=(0,0,1,-.15), children=[ Viewpoint(DEF='RightSideView',description='RightSide View of the truck',orientation=(0,1,0,-1.57),position=(-11,1.5,-2))]), Transform(rotation=(1,0,0,-.3), children=[ Viewpoint(DEF='FrontView',description='Frontal View of the truck',position=(0,1.5,12))]), Transform(rotation=(0,0,1,.15), children=[ Viewpoint(DEF='LeftSideView',description='LeftSide View of the truck',orientation=(0,1,0,1.57),position=(11,1.5,-2))]), Transform(center=(1.25,1.2,-1.42),rotation=(1,0,0,.15), children=[ Viewpoint(DEF='DriverView',description="View From Driver's Perspective",orientation=(0,1,0,3.05),position=(1.25,1.2,-1.42))]), Transform(center=(0,3.0,-11),rotation=(1,0,0,.4), children=[ Viewpoint(DEF='RearView',description='Rear View of Truck',orientation=(0,1,0,3.14),position=(0,3.0,-11))]), Transform(center=(1.2,5,-6),rotation=(0,1,0,2.4), children=[ Viewpoint(DEF='TruckBed',description='View of the bed of the truck',orientation=(1,0,0,-.1),position=(1.2,.5,-6))]), Transform(center=(1.25,.75,-1.75),rotation=(0,0,1,.3), children=[ Viewpoint(DEF='BackSeatView',description='A view of the back seat from just behind the driver',orientation=(0,1,0,1.8),position=(1.25,.75,-1.75))]), Transform(center=(0,1.0,-1.45),rotation=(1,0,0,.45), children=[ Viewpoint(DEF='ConsoleView',description='A view of the dash and console of the truck',orientation=(0,1,0,3.05),position=(0,1.0,-1.45))])]), Background(groundColor=[(0,0,1)],skyColor=[(0,0,1)]), Inline(DEF='TruckCabAndWindShield',url=["CabWithWindShield.x3d","https://savage.nps.edu/Savage/GroundVehicles/Truck/CabWithWindShield.x3d","CabWithWindShield.wrl","https://savage.nps.edu/Savage/GroundVehicles/Truck/CabWithWindShield.wrl"]), Inline(DEF='TruckDoors',url=["Doors.x3d","https://savage.nps.edu/Savage/GroundVehicles/Truck/Doors.x3d","Doors.wrl","https://savage.nps.edu/Savage/GroundVehicles/Truck/Doors.wrl"]), Inline(DEF='RearWindow',url=["RearWindow.x3d","https://savage.nps.edu/Savage/GroundVehicles/Truck/RearWindow.x3d","RearWindow.wrl","https://savage.nps.edu/Savage/GroundVehicles/Truck/RearWindow.wrl"]), Inline(DEF='TruckBox',url=["TruckBox.x3d","https://savage.nps.edu/Savage/GroundVehicles/Truck/TruckBox.x3d","TruckBox.wrl","https://savage.nps.edu/Savage/GroundVehicles/Truck/TruckBox.wrl"]), Inline(DEF='RimsAndTires',url=["RimsAndTires.x3d","https://savage.nps.edu/Savage/GroundVehicles/Truck/RimsAndTires.x3d","RimsAndTires.wrl","https://savage.nps.edu/Savage/GroundVehicles/Truck/RimsAndTires.wrl"]), Inline(DEF='LightsAndTurnSignals',url=["LightsAndTurnSignals.x3d","https://savage.nps.edu/Savage/GroundVehicles/Truck/LightsAndTurnSignals.x3d","LightsAndTurnSignals.wrl","https://savage.nps.edu/Savage/GroundVehicles/Truck/LightsAndTurnSignals.wrl"]), Inline(DEF='CabInterior',url=["CabInterior.x3d","https://savage.nps.edu/Savage/GroundVehicles/Truck/CabInterior.x3d","CabInterior.wrl","https://savage.nps.edu/Savage/GroundVehicles/Truck/CabInterior.wrl"]), Inline(DEF='Remainder',url=["Remainder.x3d","https://savage.nps.edu/Savage/GroundVehicles/Truck/Remainder.x3d","Remainder.wrl","https://savage.nps.edu/Savage/GroundVehicles/Truck/Remainder.wrl"])]) ) # X3D model complete #################################################################################################### # Self-test diagnostics #################################################################################################### print('Self-test diagnostics for BlackMidSizeTruck.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 BlackMidSizeTruck.py load and self-test diagnostics complete.")