Does somebody know script which match camera to (camera perpendicular looking to faces) selected faces ???
Don’t know if one already existed, but I wrote a quick one for you. Simply select the face and then run the script.
import Blender
from Blender import Object, Scene, Draw, Window, Constraint
###########################################################
distance = 10 # distance between camera and selected face #
###########################################################
objects = Object.GetSelected()
camera = Scene.GetCurrent().getCurrentCamera()
if len(objects)==0:
Draw.PupMenu("Error%t|No object selected")
elif not camera:
Draw.PupMenu("Error%t|No camera in scene")
else:
object = False
for i in objects:
if i.getType()=='Mesh' and object == False:
object = i
if not object:
Draw.PupMenu("Error%t|No mesh selected")
else:
mesh = Blender.Mesh.Get(object.getData(name_only=True))
editmode = False
if Window.EditMode():
editmode = True
Window.EditMode(0)
faces = mesh.faces.selected()
if len(faces)==0:
Draw.PupMenu("Error%t|No face selected")
else:
face = faces[0]
loc = Blender.Mathutils.Vector(object.getLocation('worldspace'))
cent = mesh.faces[face].cent*object.getMatrix('worldspace')
locface = loc+cent
normal = mesh.faces[face].no*object.getMatrix('worldspace')
normal_offset = normal*distance
newloc = locface+normal_offset
camera.setLocation(newloc)
try:
empty = Object.Get('perpendicular_face')
except:
empty = Object.New('Empty','perpendicular_face')
Scene.GetCurrent().link(empty)
empty.setLocation(locface)
constraint = False
if len(camera.constraints)>0:
for i in camera.constraints:
if i.type==2 and i[Constraint.Settings.TARGET] == empty and i[Constraint.Settings.TRACK] == 5 and i[Constraint.Settings.UP] == 1:
constraint = True
if not constraint:
camera.constraints.append(2)
index = len(camera.constraints)-1
camera.constraints[index][Constraint.Settings.TARGET] = empty
camera.constraints[index][Constraint.Settings.TRACK] = 5
camera.constraints[index][Constraint.Settings.UP] = 1
if editmode:
Window.EditMode(1)
Blender.Redraw()