5
5
__all__ = ['POVFile' , 'Vector' , 'Sphere' , 'Box' , 'Triangle' , 'Pigment' ,
6
6
'Blob' , 'Texture' , 'Finish' , 'Normal' , 'Camera' , 'LightSource' , 'Torus' ,
7
7
'Union' , 'Intersection' , 'Difference' , 'SkySphere' , 'Mesh' , 'Plane' ]
8
- HEADER = """
8
+ HEADER1 = """
9
9
// Persistence Of Vision Ray Tracer Scene Description pov_fib
10
10
// pov_fib: Generated by tracer.py
11
11
// tracer.py is based on http://code.activestate.com/recipes/205451/ (r1)
12
12
// For PovRAY Version: 3.7 (includes radiosity)
13
13
// Date: September 2011
14
14
// Auth: Martin Prout
15
- // +width 800 +height 600 for basic_scene example
15
+ """
16
+ HEADER2 = """
16
17
#version 3.7;
17
18
global_settings{
18
19
assumed_gamma 1.0
@@ -34,16 +35,22 @@ class POVFile(object):
34
35
35
36
"""
36
37
In the original recipe this was simply called file class, it seems sensible
37
- to use a more descriptive name
38
+ to use a more descriptive name, also included size, this can be useful.
39
+ PovRAY sketches should have a suggested size if only to set the aspect
40
+ ratio.
38
41
"""
39
- def __init__ (self , fnam = "out.pov" , * items ):
42
+ def __init__ (self , fnam = "out.pov" , size = ( 300 , 300 ), * items ):
40
43
"""
41
44
Initialize the POVFile object with hard coded HEADER, this
42
45
could easily be read from file for greater flexiblity
43
46
"""
44
47
self .file = open (fnam , "w" )
45
48
self .__indent = 0
46
- self .writeln (HEADER )
49
+ self .writeln (HEADER1 )
50
+ self .size = size # could use this data to set aspect ratio
51
+ # Split header to add suggested render size in comments
52
+ self .writeln ( '// width %s height %s' % size )
53
+ self .writeln (HEADER2 )
47
54
self .write (* items )
48
55
def include (self , name ):
49
56
"""
@@ -355,7 +362,7 @@ def basic_scene():
355
362
Basic external scene
356
363
Note the use of tuples to group scalar values for vector type
357
364
"""
358
- scene = POVFile ("basic_scene.pov" , "colors.inc" , "skies.inc" )
365
+ scene = POVFile ("basic_scene.pov" , ( 800 , 600 ), "colors.inc" , "skies.inc" )
359
366
cam = Camera (location = (0 , 2 , - 3 ), look_at = (0 , 1 , 2 ))
360
367
sky = SkySphere ("S_Cloud3" )
361
368
ground = Plane ((0.0 , 1.0 , 0.0 ), 0.0 ,
@@ -382,7 +389,7 @@ def spiral():
382
389
"""
383
390
from math import sqrt , pi , cos , sin
384
391
gamma = (sqrt (5 ) - 1 ) / 2
385
- fib = POVFile ()
392
+ fib = POVFile ("spiral.pov" )
386
393
Camera (location = (0 , 0 , - 128 ), look_at = (0 , 0 , 0 )).write (fib )
387
394
LightSource ((100 , 100 , - 100 ), color = (1 , 1 , 1 )).write (fib )
388
395
LightSource ((150 , 150 , - 100 ), color = (0 , 0 , 0.3 )).write (fib )
@@ -409,7 +416,7 @@ def test():
409
416
"""
410
417
The current test function is ...
411
418
"""
412
- basic_scene ()
419
+ spiral ()
413
420
414
421
if (__name__ == "__main__" ):
415
422
test ()
0 commit comments