Changeset 630


Ignore:
Timestamp:
11/08/16 23:53:51 (7 years ago)
Author:
sz
Message:

added the option to write a separate "camerapath.inc" instead of updating the source ".pov" files

File:
1 edited

Legend:

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

    r629 r630  
    304304    return [obj.location.x, obj.location.y, obj.location.z, obj.location.x-m[0][2], obj.location.y-m[1][2], obj.location.z-m[2][2]]
    305305
    306 def povUpdateScene(obj):
     306def povUpdateScene(obj,writepath):
    307307    global Folder,FirstFrame,FrameCount,Files,FirstPOV
    308308    print("Updating scene %s" % obj.name)
     
    311311        print("No files found for "+obj.name)
    312312        return
     313
     314    if writepath:
     315        f=open(os.path.join(Folder,'camerapath.inc'),'w',encoding='latin-1')
     316        f.write("#local CameraPathFirst=1;\n")
     317        f.write("#local CameraPath=array["+str(len(Files))+"*2]\n")
     318        f.write("{\n")
     319
    313320    FirstFrame=obj.framspov_frame
    314321    FrameCount=obj.framspov_count
     
    326333        cam[4]-=obj.location.y
    327334        cam[5]-=obj.location.z
    328         povUpdateFile(os.path.join(Folder,Files[k]),cam)
     335        if writepath:
     336            f.write(("  <%g,%g,%g>,<%g,%g,%g>," % tuple(cam))+" //"+Files[k]+"\n")
     337        else:
     338            povUpdateFile(os.path.join(Folder,Files[k]),cam)
     339
     340    if writepath:
     341        f.write('''
     342}
     343#if ((AnimFrame>=CameraPathFirst) & ((AnimFrame-CameraPathFirst)<(dimension_size(CameraPath,1)/2)))
     344  #local i=2*(AnimFrame-CameraPathFirst);
     345  Camera(CameraPath[i],CameraPath[i+1])
     346#end
     347''')
     348        f.close()
    329349
    330350####################################
     
    373393        row = layout.row()
    374394        row.operator("framspov.updatecam",icon='SCRIPT')
     395        row = layout.row()
     396        row.operator("framspov.writecamerapath",icon='SCRIPT')
    375397
    376398
     
    380402 
    381403    def execute(self, context):
    382         povUpdateScene(context.object)
     404        povUpdateScene(context.object,False)
     405        return{'FINISHED'}
     406
     407class VIEW3D_OT_WritePOVCameraPath(bpy.types.Operator):
     408    bl_idname = "framspov.writecamerapath"
     409    bl_label = "Write camerapath.inc"
     410 
     411    def execute(self, context):
     412        povUpdateScene(context.object,True)
    383413        return{'FINISHED'}
    384414
     
    389419    bpy.utils.register_class(FramsticksPOVImporter)
    390420    bpy.utils.register_class(VIEW3D_OT_UpdatePOVCamera)
     421    bpy.utils.register_class(VIEW3D_OT_WritePOVCameraPath)
    391422    bpy.utils.register_class(OBJECT_PT_framspov)
    392423    bpy.types.INFO_MT_file_import.append(menu_func_import)
     
    395426    bpy.utils.unregister_class(FramsticksPOVImporter)
    396427    bpy.utils.unregister_class(VIEW3D_OT_UpdatePOVCamera)
     428    bpy.utils.unregister_class(VIEW3D_OT_WritePOVCameraPath)
    397429    bpy.utils.unregister_class(OBJECT_PT_framspov)
    398430    bpy.types.INFO_MT_file_import.remove(menu_func_import)
Note: See TracChangeset for help on using the changeset viewer.