Blender automatic render python script for 32-bit graphics

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
User avatar
brupje
Transport Coordinator
Transport Coordinator
Posts: 288
Joined: 03 Oct 2006 07:17
Location: The hague, Netherlands

Blender automatic render python script for 32-bit graphics

Post by brupje »

I created a python script that will render from different angles with different sizes automaticly.

It will create a directory for each file you render and puts the png files there. For example if you set as rootpath "C:\\myrenders\\" and your file is called "myfile.blend" you will have a directory
c:\myrenders\myfile
containing
myfile_1_25.png (frame 1, 25%)
myfile_1_50.png (frame 1, 50%)
myfile_1_100.png (frame 1, 100%)
myfile_2_25.png (frame 2, 25%)
...
myfile_4_100.png (frame 4, 25%)


How to use:

1. Open the file to be rendered
2. Download the script, or copy this text into Blender
3. Change "RootPath = "c:\\ottdrenders\\"" into a directory of your own choice. Note the "\\" instead of "\"!!
4. Press alt-p (or run script)
5. Wait for a certain amount of time depending on what is rendered, your computer specs and the position of mars relative to the earth
6. Upload your work ;)

Code: Select all

import Blender
from Blender import *
from Blender.Scene import Render

# change this!
RootPath = "c:\\ottdrenders\\"

zoomLevels = [100,50,25]
myBlend = Blender.Object.Get();

print "Init success, continue"

curScene = Scene.GetCurrent()
myContext = curScene.getRenderingContext()
myContext.imageType = Render.PNG

curFile = sys.makename( Blender.Get('filename'),strip=1)
curPath = RootPath + curFile +"\\"
print "Output to: ", curPath
myContext.setRenderPath(curPath);

# assuming 4 frames, each frame will be rendered at 3 zoom levels
for i in range(1,5,1):
	print "Frame #" , i
	myContext.currentFrame(i)
		
	for d in zoomLevels:
		print "Zoom level ", d ,"%"
		myContext.setRenderWinSize(d)
		myContext.render()
		myContext.saveRenderedImage(curFile + "_" + str(i) + "_" + str(d) +".png")
[/code]
Attachments
BlendRender.rar
(539 Bytes) Downloaded 858 times
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Post by athanasios »

Even I don't use Blender yet, I suppose this will help a lot. BRAVO.
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Bing [Bot] and 19 guests