Beispiel #1
0
def main():
    '''
        Main code that render the file
    '''

    #Parameters of the image
    formatInput = "INPUT_FORMAT"
    formatOutput = "OUTPUT_FORMAT"
    name = "FILE_NAME"
    inputFolder = "INPUT_FOLDER"
    outputFolder = "OUTPUT_FOLDER"
    fileNameInput = os.path.join(inputFolder, name + formatInput)
    fileNameOutput = os.path.join(outputFolder, name + formatOutput)

    # Create the new scene without lighting or cube or anything
    # the way with the new scene would be better i guess, but render does not work
    oldScn = bpy.data.scenes['Scene']
    for obj in bpy.context.visible_objects:
        oldScn.objects.unlink(obj)

    #Import - b2.57
    import_x3d.load_web3d(fileNameInput)
    
    # Setting the active camera
    for obj in bpy.context.visible_objects:
        if obj.type == 'CAMERA':
            viewpoint = obj
    
    ops.object.camera_add(location = viewpoint.location, rotation=viewpoint.rotation_euler)
    bpy.context.scene.camera = viewpoint

    # Add sample diffuse light - called here area light 
    # TODO: set the light source behind the camera (view point)
    areaLampVector = [0, 0, 20]
    bpy.ops.object.lamp_add(type='HEMI', location=areaLampVector)

    # get render settings
    renderSettings = context.scene.render
    # TODO: make sure the render uses the nice things

    # Get the render
    ops.render.render(scene='Scene')
    img = bpy.data.images['Render Result']

    # TODO: get the properties of the saved file
    img.save_render(filepath=fileNameOutput)
Beispiel #2
0
output ="renders/"

# Get the names right
fileNameInput = input + name  + formatInput
fileNameOutput = output + name + formatOutput

# Create the new scene wihout lighting or cube or anyting
# the way with the new scene would be better i guess, but render does not work
oldScn  = bpy.data.scenes['Scene']
for obj in bpy.context.visible_objects:
	oldScn.objects.unlink(obj)



#Import - b2.57
import_x3d.load_web3d(fileNameInput) 

# Add sample diffuse light - caled here area light 
# TODO: set the light source behind the camera (view point)
areaLampVector = [0,0,20] 
bpy.ops.object.lamp_add(type='HEMI',location=areaLampVector)

# get render settings
renderSettings = context.scene.render
# TODO: make sure the render uses the nice things

# Get the render
ops.render.render(scene='Scene')
img = bpy.data.images['Render Result']

# TODO: get the properties of the saved file