# Trackball¶

class Trackball

Trackball acts like Performer in trackball mode. It can either spin around a piece of geometry directly, or it can spin around a camera with the inverse transform to make it appear that the whole world is spinning.

The Trackball object actually just places a transform in the data graph; parent a Transform2SG node under it to actually transform objects (or cameras) in the world.

Inheritance diagram

enum ControlMode
enumerator CM_default = 0
enumerator CM_truck = 1

Normally mouse 1

enumerator CM_pan = 2

Normally mouse 2

enumerator CM_dolly = 3

Normally mouse 3

enumerator CM_roll = 4

Normally mouse 2 + 3

explicit Trackball(std::string const &name)
Trackball(Trackball const&) = default
static TypeHandle get_class_type(void)
ControlMode get_control_mode(void) const

Returns the control mode. See set_control_mode().

CoordinateSystem get_coordinate_system(void) const

Returns the coordinate system of the Trackball. See set_coordinate_system().

PN_stdfloat get_forward_scale(void) const

Returns the scale factor applied to forward and backward motion. See set_forward_scale().

PN_stdfloat get_h(void) const
LVecBase3 get_hpr(void) const

Return the trackball’s orientation.

bool get_invert(void) const

Returns the invert flag. When this is set, the inverse matrix is generated, suitable for joining to a camera, instead of parenting the scene under it.

LMatrix4 const &get_mat(void) const

Returns the matrix represented by the trackball rotation.

LPoint3 get_origin(void) const

Returns the current center of rotation.

PN_stdfloat get_p(void) const
LPoint3 const &get_pos(void) const

Return the offset from the center of rotation.

PN_stdfloat get_r(void) const
NodePath const &get_rel_to(void) const

Returns the NodePath that all trackball manipulations are relative to, or the empty path.

LMatrix4 const &get_trans_mat(void) const

Returns the actual transform that will be applied to the scene graph. This is the same as get_mat(), unless invert is in effect.

PN_stdfloat get_x(void) const
PN_stdfloat get_y(void) const
PN_stdfloat get_z(void) const
void move_origin(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)

Moves the center of rotation by the given amount.

void reset(void)

Reinitializes all transforms to identity.

void reset_origin_here(void)

Reposition the center of rotation to coincide with the current translation offset. Future rotations will be about the current origin.

void set_control_mode(Trackball::ControlMode control_mode)

Sets the control mode. Normally this is CM_default, which means each mouse button serves its normal function. When it is CM_truck, CM_pan, CM_dolly, or CM_roll, all of the mouse buttons serve the indicated function instead of their normal function. This can be used in conjunction with some external way of changing modes.

void set_coordinate_system(CoordinateSystem cs)

Sets the coordinate system of the Trackball. Normally, this is the default coordinate system. This changes the axes the Trackball manipulates so that the user interface remains consistent across different coordinate systems.

void set_forward_scale(PN_stdfloat fwdscale)

Changes the scale factor applied to forward and backward motion. The larger this number, the faster the model will move in response to dollying in and out.

void set_h(PN_stdfloat h)
void set_hpr(LVecBase3 const &hpr)
void set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r)

Directly set the mover’s orientation.

void set_invert(bool flag)

Sets the invert flag. When this is set, the inverse matrix is generated, suitable for joining to a camera, instead of parenting the scene under it.

void set_mat(LMatrix4 const &mat)

Stores the indicated transform in the trackball. This is a transform in global space, regardless of the rel_to node.

void set_origin(LVecBase3 const &origin)

Directly sets the center of rotation.

void set_p(PN_stdfloat p)
void set_pos(LVecBase3 const &vec)
void set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)

Directly set the offset from the rotational origin.

void set_r(PN_stdfloat r)
void set_rel_to(NodePath const &rel_to)

Sets the NodePath that all trackball manipulations are to be assumed to be relative to. For instance, set your camera node here to make the trackball motion camera relative. The default is the empty path, which means trackball motion is in global space.

void set_x(PN_stdfloat x)
void set_y(PN_stdfloat y)
void set_z(PN_stdfloat z)