# panda3d.core.Trackball¶

from panda3d.core import 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

__init__(param0: Trackball) → None
__init__(name: str) → None
reset() → None

Reinitializes all transforms to identity.

getForwardScale() → float

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

setForwardScale(fwdscale: float) → None

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.

getPos() → LPoint3

Return the offset from the center of rotation.

Return type

LPoint3

getX() → float
getY() → float
getZ() → float
setPos(vec: LVecBase3) → None

Directly set the offset from the rotational origin.

setPos(x: float, y: float, z: float) → None
setX(x: float) → None
setY(y: float) → None
setZ(z: float) → None
getHpr() → LVecBase3

Return the trackball’s orientation.

Return type

LVecBase3

getH() → float
getP() → float
getR() → float
setHpr(hpr: LVecBase3) → None

Directly set the mover’s orientation.

setHpr(h: float, p: float, r: float) → None
setH(h: float) → None
setP(p: float) → None
setR(r: float) → None
resetOriginHere() → None

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

moveOrigin(x: float, y: float, z: float) → None

Moves the center of rotation by the given amount.

getOrigin() → LPoint3

Returns the current center of rotation.

Return type

LPoint3

setOrigin(origin: LVecBase3) → None

Directly sets the center of rotation.

setControlMode(control_mode: ControlMode) → None

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.

getControlMode() → ControlMode

Returns the control mode. See setControlMode().

Return type

ControlMode

setInvert(flag: bool) → None

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.

getInvert() → bool

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.

setRelTo(rel_to: NodePath) → None

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.

getRelTo() → NodePath

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

Return type

NodePath

setCoordinateSystem(cs: CoordinateSystem) → None

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.

getCoordinateSystem() → CoordinateSystem

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

Return type

CoordinateSystem

setMat(mat: LMatrix4) → None

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

getMat() → LMatrix4

Returns the matrix represented by the trackball rotation.

Return type

LMatrix4

getTransMat() → LMatrix4

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

Return type

LMatrix4

static getClassType() → TypeHandle
Return type

TypeHandle

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