# * Scene clipping done using bounding box instead of object center
# * Fix camera type selection for blender>2.43 (Thanks to Thomas Lachmann)
# * Compatibility with python 2.3
+# * Process only object that are on visible layers.
#
# ---------------------------------------------------------------------
polygons = dict()
polygons['SHOW'] = True
polygons['SHADING'] = 'FLAT' # FLAT or TOON
- polygons['HSR'] = 'PAINTER' # PAINTER or NEWELL
+ polygons['HSR'] = 'NEWELL' # PAINTER or NEWELL
# Hidden to the user for now
polygons['EXPANSION_TRICK'] = True
# Render from the currently active camera
#self.cameraObj = self._SCENE.getCurrentCamera()
- # Get the list of lighting sources
- obj_lst = self._SCENE.getChildren()
- self.lights = [ o for o in obj_lst if o.getType() == 'Lamp']
-
- # When there are no lights we use a default lighting source
- # that have the same position of the camera
- if len(self.lights) == 0:
- l = Lamp.New('Lamp')
- lobj = Object.New('Lamp')
- lobj.loc = self.cameraObj.loc
- lobj.link(l)
- self.lights.append(lobj)
+ self.lights = []
##
# global processing of the scene
+ self._filterHiddenObjects(workScene)
+
+ self._buildLightSetup(workScene)
+
self._doSceneClipping(workScene)
self._doConvertGeometricObjsToMesh(workScene)
# Per object activities
Objects = workScene.getChildren()
+
print "Total Objects: %d" % len(Objects)
for i,obj in enumerate(Objects):
print "\n\n-------"
# Scene methods
+ def _filterHiddenObjects(self, scene):
+ """Discard object that are on hidden layers in the scene.
+ """
+
+ Objects = scene.getChildren()
+
+ visible_obj_list = [ obj for obj in Objects if
+ set(obj.layers).intersection(set(scene.getLayers())) ]
+
+ for o in Objects:
+ if o not in visible_obj_list:
+ scene.unlink(o)
+
+ scene.update()
+
+
+
+ def _buildLightSetup(self, scene):
+ # Get the list of lighting sources
+ obj_lst = scene.getChildren()
+ self.lights = [ o for o in obj_lst if o.getType() == 'Lamp' ]
+
+ # When there are no lights we use a default lighting source
+ # that have the same position of the camera
+ if len(self.lights) == 0:
+ l = Lamp.New('Lamp')
+ lobj = Object.New('Lamp')
+ lobj.loc = self.cameraObj.loc
+ lobj.link(l)
+ self.lights.append(lobj)
+
+
def _doSceneClipping(self, scene):
"""Clip whole objects against the View Frustum.
fovy = fovy * 360.0/pi
Objects = scene.getChildren()
+
for o in Objects:
if o.getType() != 'Mesh': continue;
#geometricObjTypes = ['Mesh', 'Surf', 'Curve']
Objects = scene.getChildren()
+
objList = [ o for o in Objects if o.getType() in geometricObjTypes ]
for obj in objList:
old_obj = obj
Objects = scene.getChildren()
+
#Objects.sort(by_obj_center_pos)
Objects.sort(by_nearest_bbox_point)