HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SOHO/Hello3.py
1 #
2 # This document is under CC-3.0 Attribution-Share Alike 3.0
3 # http://creativecommons.org/licenses/by-sa/3.0/
4 # Attribution: There is no requirement to attribute the author.
5 
6 # Create a simple SOHO scene and traverse the objects
7 import soho, sys
8 
9 # Evaluate the 'camera' parameter as a string.
10 # If the 'camera' parameter # doesn't exist, use ['/obj/cam1'].
11 # SOHO always returns lists of values.
12 camera = soho.getDefaultedString('camera', ['/obj/cam1'])[0]
13 
14 # However, for our purposes, we don't actually need a camera, so...
15 camera = None
16 
17 # Evaluate an intrinsic parameter (see HDK_SOHO_API::evaluate())
18 # The 'state:time' parameter evaluates the time from the ROP.
19 evaltime = soho.getDefaultedFloat('state:time', [0.0])[0]
20 
21 # Initialize SOHO with the camera.
22 if not soho.initialize(evaltime, camera):
23  soho.error('Unable to initialize rendering module with camera: %s' %
24  repr(camera))
25 
26 # Now, add objects to our scene
27 # addObjects(time, geometry, light, fog, use_display_flags)
28 soho.addObjects(evaltime, "*", "*", "*", True)
29 
30 # Before we can evaluate the scene from SOHO, we need to lock the object lists.
31 soho.lockObjects(evaltime)
32 
33 # Now, traverse all the objects
34 def outputObjects(fp, prefix, list):
35  fp.write('%s = {' % prefix)
36  for obj in list:
37  fp.write('"%s",' % obj.getName())
38  fp.write('}\n')
39  fp.flush()
40 
41 fp = sys.stdout
42 outputObjects(fp, 'Geometry', soho.objectList('objlist:instance'))
43 outputObjects(fp, 'Light', soho.objectList('objlist:light'))
44 outputObjects(fp, 'Fog', soho.objectList('objlist:fog'))