Forum: Poser - OFFICIAL


Subject: Getting the same view from dolly/orbiting cameras

3dcheapskate opened this issue on May 09, 2014 · 21 posts


3dcheapskate posted Wed, 21 May 2014 at 12:28 AM

It's now almost working for the posing/face/hand cameras too - simply by adding the code in orange (using the face camera as an example - using 'hip'/'rHand'/'lHand' the same principle works with posing/hand cameras) I'm getting the dolly camera almost spot-on, but not quite...

I've noticed that the posing/face/hand cameras have additional x/y/zOffset parameters which seem to have very small values (less than 0.1 PNU), and these should probably be factored in somewhere? But I can't find/work out what they represent - anybody know?

Get the mid-point of the relevant bone, which is the centre of rotation

act=fig.ActorByInternalName("head")
ori=act.Origin()
ep=act.EndPoint()
oriX=(ep[0]+ori[0])/2.0
oriY=(ep[1]+ori[1])/2.0
oriZ=(ep[2]+ori[2])/2.0 

cam = scn.ActorByInternalName("FACE_CAMERA")
if cam:
    xd=cam.Parameter("dollyX").Value()
    yd=cam.Parameter("dollyY").Value()
    zd=cam.Parameter("dollyZ").Value()
    rx=cam.Parameter("pitch").Value()
    ry=cam.Parameter("yaw").Value()
    
    # Empirically derived offset of camera viewpoint from camera dollyX/Y/Z position
    # (appears to be a fixed value independent of any other camera parameters - same in Poser 6/9)
    Dz = 1.1
    
    # The camera viewpoint position with x/y/zOrbit all zeroed would be...
    x0=xd
    y0=yd
    z0=zd+Dz
    # ...and converting these to polar coordinates
    E0 = todegs(math.atan2(-y0,z0))
    A0 = todegs(math.atan2(x0,z0))
    D0 = math.hypot(y0,math.hypot(x0,z0))
    
    # yOrbit/xOrbit values are simply added to polar azimuth/elevation respectively...
    Ec=E0+rx
    Ac=A0+ry
    if Ec > 90:
        Ec=180-Ec
        Ac+=180
    if Ec < -90:
        Ec=-180+Ec
        Ac+=180
    Dc=D0
    
    # ...and convert back to cartesian. This is where the main camera viewpoint is located
    yc=-Dcmath.sin(torads(Ec))
    d=Dc
math.cos(torads(Ec))
    xc=dmath.sin(torads(Ac))
    zc=d
math.cos(torads(Ac))

    # xc/yc/zc are wrt the centre of rotation, so add the coordinates of that
    xc+=oriX
    yc+=oriY
    zc+=oriZ
 
    # Move Dolly camera to this point
    dcam = scn.ActorByInternalName("STD_CAMERA")
    if dcam:
        dcam.Parameter("dollyX").SetValue(xc)
        dcam.Parameter("dollyY").SetValue(yc)
        dcam.Parameter("dollyZ").SetValue(zc)
        # Dolly camera yaw/pitch are set the same as the Main camera's yOrit/xOrbit
        dcam.Parameter("pitch").SetValue(rx)
        dcam.Parameter("yaw").SetValue(ry)
        dcam.Parameter("roll").SetValue(0.0)

TIA

Pete


The 3Dcheapskate* occasionally posts sensible stuff. Usually by accident. And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU or something else.
*soon only to be available in two flavours - 
 DAZ and Renderosity