File: render.py

package info (click to toggle)
lincity-ng 2.9~git20150314-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 191,124 kB
  • sloc: cpp: 34,384; xml: 25,862; sh: 3,218; ansic: 806; python: 302; makefile: 26
file content (60 lines) | stat: -rw-r--r-- 1,682 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import Blender
from Blender import *
from Blender.Scene import *

print "Hello World: ", Blender

scn = Scene.GetCurrent()

# Remove all lamps
for obj in scn.getChildren():
    if obj.getType() == 'Lamp':
        scn.unlink(obj)

c = Camera.New('ortho')     # create new ortho camera data
c.lens = 10.0               # set lens value
# c.setType("ortho")
ob = Object.New('Camera')   # make camera object
ob.link(c)                  # link camera data with this object
ob.setLocation(-10, -10, 10)
ob.setEuler([60.0/180.0 * 3.1415927, 0, -45.0/180.0 * 3.1415927])
scn.link(ob)                # link object into scene
scn.setCurrentCamera(ob)

l = Lamp.New('Lamp')            # create new 'Spot' lamp data
l.setEnergy(0.5)
#  l.setMode('square', 'shadow')   # set these two lamp mode flags
ob = Object.New('Lamp')         # create new lamp object
ob.link(l)
ob.setEuler([3.1415927/4.0, 0, 3.1415927/4.0])
ob.setLocation(10, -10, 14)
scn.link(ob)

l = Lamp.New('Sun')            # create new 'Spot' lamp data
l.setEnergy(1.0)
#  l.setMode('square', 'shadow')   # set these two lamp mode flags
ob = Object.New('Lamp')         # create new lamp object
ob.link(l)
ob.setEuler([60.0/180.0 * 3.1415927, 0, -45.0/180.0 * 3.1415927])
ob.setLocation(-10, -10, 10)
scn.link(ob)

# Rendering parameters
context = scn.getRenderingContext()
context.enableRGBAColor()
context.setImageType(Render.PNG)
context.setRenderWinSize(100)
context.imageSizeX(1024)
context.imageSizeY(768)
context.enableOversampling(1)
context.setOversamplingLevel(8)
context.setRenderPath("tmp/")
context.startFrame(1)
context.endFrame(1)

Blender.Save("tmp/tmp.blend", 1)

# context.renderAnim()
# Blender.Quit()

# EOF #