Viewports: ENS_VPORT
Methods:
- foo.createviewport([description=s]): only available on the default viewport(ensight.objs.core.DEFAULTVPORT[0]). It creates a new viewport, returning the created viewport.
- foo.destroy(): available on all but the default and first viewport. It destroys the viewport object (’foo’ in this example).
- foo.interpolate(a,b,t[,normalize=1][,shortestpath=1]): performs linear interpolation between vectors A and B (Python lists). T is the weight factor (0.0->A, 1.0->B). If normalized is set, the output vector will be normalized before being returned. This effectively implements 'nlerp()' interpolation useful for quaternions. If shortestpath is set, the sign of the B components will be swapped if the dot product between A and B is negative. For quaternion interpolation, this effectively interpolates through the shortest angle between the two rotations.
Attributes:
- DESCRIPTION: string name of the viewport
- SELECTED: the current selection state of the viewport
- ID: the command language ID of the viewport. This is a read-only value.
- BACKGROUND: the enve image object for the background image.
- LOOKATPOINT: the x,y,z value for the point in space the camera is looking at
- LOOKFROMPOINT: the x,y,z value for the point in space the camera is looking from
- PERSPECTIVEANGLE: the camera perspective angle
- ROTATION: the current viewport rotation as a 4 float quaternion list
- TRANSLATION: the current viewport translation as a 3 float list [tx,ty,tz]
- SCALE: the current viewport scale as a 3 float list [sx,sy,sz]
- TRANSFORMCENTER: the current viewport center of transformation as a 3 float list [x,y,z]
- COMPOSITEMATRIX: the 4x4 matrix representing rotation, translation and scale using the center of transformation. This is a read-only value.
- ZCLIPLIMITS: a two value list of the near and far z clip plane. Note: this is only used if dynamic depth limits are disabled.
The ROTATION quaternion should be interpolated using "nlerp" interpolation as demonstrated in the code below (or use the interpolate() method):
def nlerp(a,b,t,shortest=False):
dot = a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3]
out = []
scale = 1.0
if ((dot < 0.) and shortest):
scale = -1.0
out.append(a[0]+t*(scale*b[0] - a[0]))
out.append(a[1]+t*(scale*b[1] - a[1]))
out.append(a[2]+t*(scale*b[2] - a[2]))
out.append(a[3]+t*(scale*b[3] - a[3]))
f = out[0]*out[0]
f = f + out[1]*out[1]
f = f + out[2]*out[2]
f = f + out[3]*out[3]
f = 1.0/math.sqrt(f)
out[0] = out[0]*f
out[1] = out[1]*f
out[2] = out[2]*f
out[3] = out[3]*f
return out