Ignore:
Timestamp:
08/09/16 21:29:40 (8 years ago)
Author:
sz
Message:

object creation and removal is now reflected in the blender scene view (using the "hide" property keyframes)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • blender-povray-animation/frams-pov-import.py

    r499 r578  
    173173# build or update blender objects from a POV file
    174174def updateBlender(SceneParent,num):
    175     global Folder, Files, Current
     175    global Folder, Files, Current, RecentlyCreated, RecentlyDisappeared
    176176    Incoming=analysePOV(os.path.join(Folder,Files[num]))
     177    RecentlyCreated=[]
     178    RecentlyDisappeared=[]
    177179    for oname,obj in Incoming.items():
    178180        if not oname in Current:
    179181            # add object properties
    180182            print('Creature added:',oname)
     183            RecentlyCreated.append(oname)
    181184            newobj=[] # will contain: [ parent, joint0, joint1, ... ]
    182185            Current[oname]=newobj
     
    216219            for field in ['location','rotation_euler','scale']:
    217220                bo.keyframe_insert(data_path=field,frame=bpy.context.scene.frame_current)
     221    for oname,obj in Current.items():
     222        if not oname in Incoming:
     223            RecentlyDisappeared.append(oname)
     224            print('Creature disappeared:',oname)
    218225
    219226# import a sequence of POV files, create object hiererchy, animate
     
    222229       global  Folder, FileName
    223230       global  Current, FirstFrame, FrameCount
     231       global  RecentlyCreated, RecentlyDisappeared
    224232       global  SceneParent
    225233       global  SkipFrames
     
    249257               break
    250258           print("Frame %d - loading POV %s" % (bpy.context.scene.frame_current,Files[k]))
    251            updateBlender(SceneParent,k)
     259           updateBlender(SceneParent,k)
     260           if len(RecentlyDisappeared)>0 or len(RecentlyCreated)>0:
     261               bpy.context.scene.frame_set(FirstFrame-FirstPOV+k-1)
     262               for oname in RecentlyCreated:
     263                   obj=Current[oname]
     264                   for bo in obj:
     265                       bo.hide=True
     266                       bo.keyframe_insert(data_path="hide",frame=bpy.context.scene.frame_current)
     267               for oname in RecentlyDisappeared:
     268                   obj=Current[oname]
     269                   for bo in obj:
     270                       bo.hide=False
     271                       bo.keyframe_insert(data_path="hide",frame=bpy.context.scene.frame_current)
     272               bpy.context.scene.frame_set(FirstFrame-FirstPOV+k)
     273               for oname in RecentlyCreated:
     274                   obj=Current[oname]
     275                   for bo in obj:
     276                       bo.hide=False
     277                       bo.keyframe_insert(data_path="hide",frame=bpy.context.scene.frame_current)
     278               for oname in RecentlyDisappeared:
     279                   obj=Current[oname]
     280                   for bo in obj:
     281                       bo.hide=True
     282                       bo.keyframe_insert(data_path="hide",frame=bpy.context.scene.frame_current)
     283                   Current.pop(oname)
     284
    252285
    253286###############################
Note: See TracChangeset for help on using the changeset viewer.