xviz/python/examples/write_scenario.py
kahkeng 3950154726
Add fixes for python GLB writing plus example writing script (#617)
* update circle example scenario after python module rename
* add alpha channel for colors so that the 3 points display properly.
* fix some issues with glb writing, and add some more tests
* add script to write a scenario to files on disk
* add support for converting polygon and polyline vertices into typed arrays in binary format
* add floating polygon to circle example scenario
* make server print out exception and stack trace
2020-10-30 12:12:07 -07:00

32 lines
702 B
Python

import sys, os, logging
import asyncio, json
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import xviz_avs
from xviz_avs.io import XVIZGLBWriter, DirectorySource
from scenarios.circle import CircleScenario
OUTPUT_DIR = './output/'
def main():
os.makedirs(OUTPUT_DIR, exist_ok=True)
sink = DirectorySource(OUTPUT_DIR)
writer = XVIZGLBWriter(sink)
duration = 10
scenario = CircleScenario(live=False, duration=duration)
writer.write_message(scenario.get_metadata())
t = 0
while t <= duration:
message = scenario.get_message(t)
writer.write_message(message)
t += 0.2
writer.close()
if __name__ == "__main__":
main()