# Cameras

## 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=Camera()
camera.imageHeight=800 # in pixels
camera.imageWidth=900
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)
camera.sky=point(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.actors=[]
camera.filmAllActors=True
camera.file="/tmp/pycaoOutput.pov" # the place to store the photo
camera.visibilityLevel=1
camera.projection="perspective"
camera.technology="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 "colors.inc" \n#include "metals.inc" \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 colors.inc 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.color="Brown"
wall.move_at(origin+1.5*Z) # the cube is moved above the plane

cyl.color='SpicyPink'
cyl.glued_on(ground)

# A first camera showing several possible options
camera1=Camera()
camera1.location=origin+5*Y+5*Z
camera1.povraylights="light_source {<"+ str(light.location[0])+","+str(light.location[1])+","+str(light.location[2])+ "> color White " + "}\n\n"
camera1.file="camera1.pov"
camera1.lookAt=wall.center+2*Y
camera1.imageHeight=800 # in pixels
camera1.imageWidth=900
camera1.zoom(0.1)
camera1.shoot # creates camera1.file
camera1.show # creates a .png built on camera.file, here /tmp/cam1.png

# A second camera with different caracteristics
camera2=Camera()
camera2.filmAllActors=False
camera2.actors=[ground]
# The ground will be displayed together with its children. Thus the
#cylinder glued on the ground is displayed.
camera2.zoom(.4)
camera2.lookAt=cyl.center
camera2.file="camera2.pov"
camera2.shoot.show


## Visibility

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).