klampt.vis.glviewport module

class klampt.vis.glviewport.GLViewport[source]

Bases: object

A class describing an OpenGL camera view.

x,y

upper left hand corner of the view in the OpenGL canvas, in screen pixels.

Type

int

w,h

width and height of the view, in screen pixels.

Type

int

screenDeviceScale

if not 1, multiply screen pixel coordinates by this to get OpenGL pixel coordinates (usually Mac Retina displays)

Type

float

orthogonal

if true, does an orthogonal projection. (Not supported yet.)

Type

bool

camera

an orbit camera controlling the target, zoom, and orientation of the “trackball” (see orbit)

fov

the camera field of view in x direction, in degrees

Type

float

clippingplanes

a pair containing the near and far clipping planes

Type

pair of floats

click_ray(x, y)[source]

Returns a pair of 3-tuples indicating the ray source and direction in world coordinates for a screen-coordinate point (x,y)

contains(x, y)[source]
fit(center, radius)[source]

Fits the viewport to an object filling a sphere of a certain center and radius

getTransform(convention='standard')[source]

Deprecated soon: use get_transform

get_transform(convention='standard')[source]

Gets the pose of the camera, with T given in world coordinates.

If convention = ‘openGL’, the Z axis of T is the backward direction of the camera, with Y pointing up and X pointing to the right.

If convention = ‘standard’, the Z axis of T is the forward direction of the camera, with Y pointing down and X pointing to the right

load_file(fn)[source]

Loads from a viewport txt file. The file format is compatible with the RobotTest, RobotPose, and SimTest apps.

project(pt, clip=True)[source]

Given a point in world space, returns the (x,y,z) coordinates of the projected pixel. z is given in absolute coordinates, while x,y are given in pixel values.

If clip=True and the point is out of the viewing volume, then None is returned. Otherwise, if the point is exactly at the focal plane then the middle of the viewport is returned.

save_file(fn)[source]

Saves to a viewport txt file. The file format is compatible with the RobotTest, RobotPose, and SimTest apps.

setCurrentGL()[source]

Deprecated soon: use set_current_GL

setTransform(T, convention='standard')[source]

Deprecated soon: use set_transform

set_current_GL()[source]

Sets up the view in the current OpenGL context

set_transform(T, convention='standard')[source]

Sets the pose of the camera, with T given in world coordinates.

If convention = ‘openGL’, the Z axis of T is the backward direction of the camera, with Y pointing up and X pointing to the right.

If convention = ‘standard’, the Z axis of T is the forward direction of the camera, with Y pointing down and X pointing to the right

toViewport()[source]

Deprecated soon: use to_viewport.

to_viewport()[source]

Returns a Klampt C++ Viewport() instance corresponding to this view. This is used to interface with the Widget classes