#!/usr/bin/env python
# MIT or general permissive
import os, sys
from sys import platform
def pre_amble():
s = """
"""
return s
def post_amble():
s = """
"""
return s
level = 0
error = [50, 5, .5, .06]
size = [1000,100,100,100]
nlevel = 4
def make_tabs(level):
s = ""
for i in range(0,level):
s = s + '\t'
return s
def make_obbox(x,y,z,sx,sy,sz):
hsx = sx/2.0
hsy = sy/2.0
hsz = sz/2.0
s = ""
s = s+ "{} {} {}, {} {} {}, {} {} {}, {} {} {}".format(x,y,z,hsx,0,0,0,hsy,0,0,0,hsz)
return s
tile_stack = """
"""
def make_tile(icol,irow,ncol,nrow):
s = tile_stack
s = s.replace("_TILE_3_","TILE_{}_{}_{}".format(3,icol,irow))
s = s.replace("_TILE_2_","TILE_{}_{}_{}".format(2,icol,irow))
s = s.replace("_TILE_1_","TILE_{}_{}_{}".format(1,icol,irow))
s = s.replace("_INLINE_3_","INLINE_{}_{}_{}".format(3,icol,irow))
s = s.replace("_INLINE_2_","INLINE_{}_{}_{}".format(2,icol,irow))
s = s.replace("_INLINE_1_","INLINE_{}_{}_{}".format(1,icol,irow))
sxz = 100.0
sy = 10.0
x = (icol - ncol/2) * sxz
z = (irow - nrow/2) * sxz
y = 0.0
s = s.replace("_translation3_","{} {} {}".format(x,y,z))
s = s.replace("_translation2_","{} {} {}".format(x,y,z))
s = s.replace("_translation1_","{} {} {}".format(x,y,z))
s = s.replace("_boundingVolume_",make_obbox(x,y,z,sxz,sy,sxz))
s = s.replace("_contentVolume_",make_obbox(x,y,z,sxz,sy,sxz))
return s
def make_grid():
nrow = 11
ncol = 11
s = ""
for icol in range(0,ncol):
for irow in range(0,nrow):
s = s + make_tile(icol,irow,ncol,nrow)
return s
def generate_scene():
scene = pre_amble();
scene = scene + make_grid()
scene = scene + post_amble()
return scene
if __name__ == "__main__":
outstr = generate_scene()
fname = "tile_scene47.x3d"
f = open(fname,"w+")
f.write(outstr)
f.close()