###################################
### DM2_w25 # AGruber@tugraz.at ###
### animatzi DEMO G_222222222222222
###################################

##############################
import rhinoscriptsyntax as rs
import random, time, sys, os   ###
sys.path.append("P:/")     ###
import DM_lib as dm        ### dm.reload_lib(dm)
##############################    

#rs.ViewDisplayMode(view=None, mode="wireframe")
rs.ShowGrid(view=None, show=False)
dm.PointRadius(displayModeX=1001, rad=1, styl=2, verbose=0)             # style 0,2 square; 1,3 round: outline, solid .. 4,5 active_point
dm.PointRadius(displayModeX=7, rad=2, styl=2, verbose=0)             # 7 = pen
dm.PointRadius(displayModeX=0, rad=1, styl=3, verbose=0)             # 0 = wireframe
dm.printDisplay(False)                                                  # nomen est omen
rs.EnableRedraw(False)
rs.Redraw()

dm.newEmptyLayer("animate", [200,80,80] )

bBox = rs.BoundingBox( rs.ObjectsByLayer("Frauenhaus_OG") )
#dm.textDots( bBox )

crv = rs.AddCurve( bBox, 2 )
crv = rs.AddInterpCurve( bBox, 2 )

anzahl = 250
camCoords = rs.DivideCurve( crv, anzahl, 1)
target = dm.pntCentroid( camCoords )

camCoords = [ rs.VectorAdd(cor, [0,0,100.1])  for cor in camCoords ]

deltaZoom = (100 - 10 )/anzahl
path = "D:/Bilder/"
if not os.path.exists(path): os.makedirs(path)

framNr = 0
for i in range(anzahl):
    dm.esc()
    #rs.AddLine( camCoords[i], target )
    dm.setCameraTarget(camera=camCoords[i], target=target, lens=100-deltaZoom*i, rota=0, upVec=0, verbose=0)
    if i%1==0:
        rs.Redraw()
        imageNameX = dm.makeName(name='ue_09', frameNumber=framNr, anzahl=4, format='jpg')
        rs.Command("-_viewCaptureToFile Width=640 Height=360 Scale=2 TransparentBackground="+dm.trans["png" in imageNameX]+" "+path+imageNameX, False)

        print i, "zoom", 100-deltaZoom*i, "-", imageNameX
        framNr += 1

    
    


