The actors

The 3d-view is completly defined from our camera. The lights, zoom, orientation of the space, which actors are seen by the camera ,etc , more generally every element of the 3D-view depends of the camera.

camera.imageHeight=800 # in pixels
camera.angle=(20./180.*math.pi) #  use camera.zoom(x) to resize
        #the image by a factor x without computation headache
        # involving tangents and angles
camera.lookAt=point(0,0,0),0,1)# the upper vector in the photo
camera.directFrame=True  # By default, direct frame with Z vertical,X on the right, Y in front of us
camera.location=point(0,-4,2)  # sensible for units in meters. the positive y are in front of us.
camera.file="/tmp/pycaoOutput.pov" # the place to store the photo
camera.projection="perspective""povray" #  only possibility at the moment
camera.povraylights="light_source {<"+ str(camera.location[0])+","+str(camera.location[1])+","+str(camera.location[2]+10)+ "> color White " + "}\n\n"
camera.povrayPreamble='#include "" \n#include "" \nbackground {Blue}\n\n'

Choosing which objects are seen by the camera is quite common to focus on one group of objects. This is the variable camera.actors which controls what is seen by the camera. On the photo taken by camera.shoot, you will see the members of camera.actors and, recursivly, all the children of the actors.

For instance,, if you want to see just 2 objects object1,object2 and their children, you set camera.filmAllActors=False and you declare camera.actors=[object1,object2]

If you want to see everything, you may be helpled by the declaration camera.filmAllActors=True. This will add to your camera.actors list all objects that Pycao thinks interesting to see ( basically geometrical objects, but not points or pure mathematical objects).

We may define multiple cameras, for instance camera1 and camera2, each one looking from a specific position and/or disregarding some objects in the scene.

ground=plane(Z,origin) # a plane with normal the vector Z=vector(0,0,1) containing the origin
ground.color='Gray' # The possible colors are the colors described in in povray or a rgb color.

wall=Cube(1,2,3) # The two opposite corners of the cube are origin and point(1,2,3)
wall.move_at(origin+1.5*Z) # the cube is moved above the plane

cyl=Cylinder(start=origin+2*Y,end=origin+2*Y+Z,radius=0.5) # a vertical Cylinder

# A first camera showing several possible options
camera1.povraylights="light_source {<"+ str(light.location[0])+","+str(light.location[1])+","+str(light.location[2])+ "> color White " + "}\n\n"
camera1.imageHeight=800 # in pixels
camera1.shoot # creates camera1.file # creates a .png built on camera.file, here /tmp/cam1.png

# A second camera with different caracteristics
# The ground will be displayed together with its children. Thus the
#cylinder glued on the ground is displayed.
../../../../_images/camera1.png ../../../../_images/camera2.png


Usually, the camera.actors list allows a good control. But if the control using camera.actors is not granulated enough, (for instance if you want to include an object but not its children), you can get a better control with the visibility arguments.

Each objects has a visibility and the cameral has a visibility level : which can be set with:

object.visibility=number # 1 by default
object.booleanVisibility=number # 1 by default
camera.visibilityLevel=number # 1 by default

We recommand by convention to let the visibility level between 0 and 1 so that object imported from elsewhere will be seen if visibility=1 and wont’ be seen if visibility<0.

More precisely, an object which is not included in a union, intersection, or difference is visible if its visibility is at least the visibility of the camera. An object in a union behaves like an object alone.

For a difference A-B, what is seen by the camera is

  • nothing is visibility(A)<camera.visibilityLevel
  • A if visibility(A)>=camera.visibilityLevel and booleanVisibility(B)<camera.visibilityLevel
  • the difference A-B if visibility(A)>=camera.visibilityLevel and booleanVisibility(B)>=camera.visibilityLevel In this last case, a fullcopy of B is computed, adobted by A, and A is replaced by A-fullcopy(B).