Panda3D
 All Classes Functions Variables Enumerations
trackball.cxx
1 // Filename: trackball.cxx
2 // Created by: drose (12Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "trackball.h"
16 #include "buttonEvent.h"
17 #include "buttonEventList.h"
18 #include "dataNodeTransmit.h"
19 #include "compose_matrix.h"
20 #include "mouseData.h"
21 #include "modifierButtons.h"
22 #include "linmath_events.h"
23 #include "mouseButton.h"
24 #include "keyboardButton.h"
25 #include "config_tform.h"
26 
27 TypeHandle Trackball::_type_handle;
28 
29 // These are used internally.
30 #define B1_MASK 0x01
31 #define B2_MASK 0x02
32 #define B3_MASK 0x04
33 
34 ////////////////////////////////////////////////////////////////////
35 // Function: Trackball::Constructor
36 // Access: Public
37 // Description:
38 ////////////////////////////////////////////////////////////////////
39 Trackball::
40 Trackball(const string &name) :
41  MouseInterfaceNode(name)
42 {
43  _pixel_xy_input = define_input("pixel_xy", EventStoreVec2::get_class_type());
44 
45  _transform_output = define_output("transform", TransformState::get_class_type());
46 
47  _transform = TransformState::make_identity();
48 
49  _rotscale = 0.3;
50  _fwdscale = 0.3;
51 
52  _last_button = 0;
53  _lastx = _lasty = 0.5f;
54 
55  _rotation = LMatrix4::ident_mat();
56  _translation.set(0.0f, 0.0f, 0.0f);
57  _mat = LMatrix4::ident_mat();
58  _orig = LMatrix4::ident_mat();
59  _invert = true;
60  _cs = get_default_coordinate_system();
61  _control_mode = CM_default;
62 
63  // We want to track the state of these buttons.
64  watch_button(MouseButton::one());
65  watch_button(MouseButton::two());
66  watch_button(MouseButton::three());
67 
68  if (trackball_use_alt_keys) {
69  // In OSX mode, we need to use the command and option key in
70  // conjunction with the (one) mouse button.
71  watch_button(KeyboardButton::control());
72  watch_button(KeyboardButton::meta());
73  watch_button(KeyboardButton::alt());
74  }
75 }
76 
77 ////////////////////////////////////////////////////////////////////
78 // Function: Trackball::Destructor
79 // Access: Published
80 // Description:
81 ////////////////////////////////////////////////////////////////////
82 Trackball::
83 ~Trackball() {
84 }
85 
86 ////////////////////////////////////////////////////////////////////
87 // Function: Trackball::reset
88 // Access: Published
89 // Description: Reinitializes all transforms to identity.
90 ////////////////////////////////////////////////////////////////////
91 void Trackball::
92 reset() {
93  _rotation = LMatrix4::ident_mat();
94  _translation.set(0.0f, 0.0f, 0.0f);
95  _orig = LMatrix4::ident_mat();
96  _mat = LMatrix4::ident_mat();
97 }
98 
99 ////////////////////////////////////////////////////////////////////
100 // Function: Trackball::get_forward_scale
101 // Access: Published
102 // Description: Returns the scale factor applied to forward and
103 // backward motion. See set_forward_scale().
104 ////////////////////////////////////////////////////////////////////
105 PN_stdfloat Trackball::
107  return _fwdscale;
108 }
109 
110 ////////////////////////////////////////////////////////////////////
111 // Function: Trackball::set_forward_scale
112 // Access: Published
113 // Description: Changes the scale factor applied to forward and
114 // backward motion. The larger this number, the faster
115 // the model will move in response to dollying in and
116 // out.
117 ////////////////////////////////////////////////////////////////////
118 void Trackball::
119 set_forward_scale(PN_stdfloat fwdscale) {
120  _fwdscale = fwdscale;
121 }
122 
123 
124 ////////////////////////////////////////////////////////////////////
125 // Function: Trackball::get_pos
126 // Access: Published
127 // Description: Return the offset from the center of rotation.
128 ////////////////////////////////////////////////////////////////////
129 const LPoint3 &Trackball::
130 get_pos() const {
131  return _translation;
132 }
133 
134 PN_stdfloat Trackball::
135 get_x() const {
136  return _translation[0];
137 }
138 
139 PN_stdfloat Trackball::
140 get_y() const {
141  return _translation[1];
142 }
143 
144 PN_stdfloat Trackball::
145 get_z() const {
146  return _translation[2];
147 }
148 
149 
150 ////////////////////////////////////////////////////////////////////
151 // Function: Trackball::set_pos
152 // Access: Published
153 // Description: Directly set the offset from the rotational origin.
154 ////////////////////////////////////////////////////////////////////
155 void Trackball::
156 set_pos(const LVecBase3 &vec) {
157  _translation = vec;
158  recompute();
159 }
160 
161 void Trackball::
162 set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
163  _translation.set(x, y, z);
164  recompute();
165 }
166 
167 void Trackball::
168 set_x(PN_stdfloat x) {
169  _translation[0] = x;
170  recompute();
171 }
172 
173 void Trackball::
174 set_y(PN_stdfloat y) {
175  _translation[1] = y;
176  recompute();
177 }
178 
179 void Trackball::
180 set_z(PN_stdfloat z) {
181  _translation[2] = z;
182  recompute();
183 }
184 
185 
186 ////////////////////////////////////////////////////////////////////
187 // Function: Trackball::get_hpr
188 // Access: Published
189 // Description: Return the trackball's orientation.
190 ////////////////////////////////////////////////////////////////////
192 get_hpr() const {
193  LVecBase3 scale, shear, hpr, translate;
194  decompose_matrix(_rotation, scale, shear, hpr, translate);
195  return hpr;
196 }
197 
198 PN_stdfloat Trackball::
199 get_h() const {
200  LVecBase3 scale, shear, hpr, translate;
201  decompose_matrix(_rotation, scale, shear, hpr, translate);
202  return hpr[0];
203 }
204 
205 PN_stdfloat Trackball::
206 get_p() const {
207  LVecBase3 scale, shear, hpr, translate;
208  decompose_matrix(_rotation, scale, shear, hpr, translate);
209  return hpr[1];
210 }
211 
212 PN_stdfloat Trackball::
213 get_r() const {
214  LVecBase3 scale, shear, hpr, translate;
215  decompose_matrix(_rotation, scale, shear, hpr, translate);
216  return hpr[2];
217 }
218 
219 
220 ////////////////////////////////////////////////////////////////////
221 // Function: Trackball::set_hpr
222 // Access: Published
223 // Description: Directly set the mover's orientation.
224 ////////////////////////////////////////////////////////////////////
225 void Trackball::
226 set_hpr(const LVecBase3 &hpr) {
227  LVecBase3 scale, shear, old_hpr, translate;
228  decompose_matrix(_rotation, scale, shear, old_hpr, translate);
229  compose_matrix(_rotation, scale, shear, hpr, translate);
230  recompute();
231 }
232 
233 void Trackball::
234 set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
235  LVecBase3 scale, shear, hpr, translate;
236  decompose_matrix(_rotation, scale, shear, hpr, translate);
237  hpr.set(h, p, r);
238  compose_matrix(_rotation, scale, shear, hpr, translate);
239  recompute();
240 }
241 
242 void Trackball::
243 set_h(PN_stdfloat h) {
244  LVecBase3 scale, shear, hpr, translate;
245  decompose_matrix(_rotation, scale, shear, hpr, translate);
246  hpr[0] = h;
247  compose_matrix(_rotation, scale, shear, hpr, translate);
248  recompute();
249 }
250 
251 void Trackball::
252 set_p(PN_stdfloat p) {
253  LVecBase3 scale, shear, hpr, translate;
254  decompose_matrix(_rotation, scale, shear, hpr, translate);
255  hpr[1] = p;
256  compose_matrix(_rotation, scale, shear, hpr, translate);
257  recompute();
258 }
259 
260 void Trackball::
261 set_r(PN_stdfloat r) {
262  LVecBase3 scale, shear, hpr, translate;
263  decompose_matrix(_rotation, scale, shear, hpr, translate);
264  hpr[2] = r;
265  compose_matrix(_rotation, scale, shear, hpr, translate);
266  recompute();
267 }
268 
269 
270 ////////////////////////////////////////////////////////////////////
271 // Function: Trackball::reset_origin_here
272 // Access: Published
273 // Description: Reposition the center of rotation to coincide with
274 // the current translation offset. Future rotations
275 // will be about the current origin.
276 ////////////////////////////////////////////////////////////////////
277 void Trackball::
279  recompute();
280  _rotation = _orig;
281  _translation.set(0.0f, 0.0f, 0.0f);
282 }
283 
284 
285 ////////////////////////////////////////////////////////////////////
286 // Function: Trackball::move_origin
287 // Access: Published
288 // Description: Moves the center of rotation by the given amount.
289 ////////////////////////////////////////////////////////////////////
290 void Trackball::
291 move_origin(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
292  _rotation = LMatrix4::translate_mat(LVecBase3(x, y, z)) * _rotation;
293 }
294 
295 ////////////////////////////////////////////////////////////////////
296 // Function: Trackball::get_origin
297 // Access: Published
298 // Description: Returns the current center of rotation.
299 ////////////////////////////////////////////////////////////////////
301 get_origin() const {
302  return _rotation.get_row3(3);
303 }
304 
305 ////////////////////////////////////////////////////////////////////
306 // Function: Trackball::set_origin
307 // Access: Published
308 // Description: Directly sets the center of rotation.
309 ////////////////////////////////////////////////////////////////////
310 void Trackball::
311 set_origin(const LVecBase3 &origin) {
312  _rotation.set_row(3, LVecBase3(0.0f, 0.0f, 0.0f));
313  _rotation = LMatrix4::translate_mat(-origin) * _rotation;
314 }
315 
316 
317 ////////////////////////////////////////////////////////////////////
318 // Function: Trackball::set_invert
319 // Access: Published
320 // Description: Sets the invert flag. When this is set, the inverse
321 // matrix is generated, suitable for joining to a
322 // camera, instead of parenting the scene under it.
323 ////////////////////////////////////////////////////////////////////
324 void Trackball::
325 set_invert(bool flag) {
326  _invert = flag;
327 }
328 
329 ////////////////////////////////////////////////////////////////////
330 // Function: Trackball::get_invert
331 // Access: Published
332 // Description: Returns the invert flag. When this is set, the
333 // inverse matrix is generated, suitable for joining to
334 // a camera, instead of parenting the scene under it.
335 ////////////////////////////////////////////////////////////////////
336 bool Trackball::
337 get_invert() const {
338  return _invert;
339 }
340 
341 ////////////////////////////////////////////////////////////////////
342 // Function: Trackball::set_control_mode
343 // Access: Published
344 // Description: Sets the control mode. Normally this is CM_default,
345 // which means each mouse button serves its normal
346 // function. When it is CM_truck, CM_pan, CM_dolly, or
347 // CM_roll, all of the mouse buttons serve the indicated
348 // function instead of their normal function. This can
349 // be used in conjunction with some external way of
350 // changing modes.
351 ////////////////////////////////////////////////////////////////////
352 void Trackball::
354  _control_mode = control_mode;
355 }
356 
357 ////////////////////////////////////////////////////////////////////
358 // Function: Trackball::get_control_mode
359 // Access: Published
360 // Description: Returns the control mode. See set_control_mode().
361 ////////////////////////////////////////////////////////////////////
364  return _control_mode;
365 }
366 
367 ////////////////////////////////////////////////////////////////////
368 // Function: Trackball::set_rel_to
369 // Access: Published
370 // Description: Sets the NodePath that all trackball manipulations
371 // are to be assumed to be relative to. For instance,
372 // set your camera node here to make the trackball
373 // motion camera relative. The default is the empty
374 // path, which means trackball motion is in global
375 // space.
376 ////////////////////////////////////////////////////////////////////
377 void Trackball::
378 set_rel_to(const NodePath &rel_to) {
379  _rel_to = rel_to;
380 }
381 
382 ////////////////////////////////////////////////////////////////////
383 // Function: Trackball::get_rel_to
384 // Access: Published
385 // Description: Returns the NodePath that all trackball manipulations
386 // are relative to, or the empty path.
387 ////////////////////////////////////////////////////////////////////
388 const NodePath &Trackball::
389 get_rel_to() const {
390  return _rel_to;
391 }
392 
393 
394 ////////////////////////////////////////////////////////////////////
395 // Function: Trackball::set_coordinate_system
396 // Access: Published
397 // Description: Sets the coordinate system of the Trackball.
398 // Normally, this is the default coordinate system.
399 // This changes the axes the Trackball manipulates so
400 // that the user interface remains consistent across
401 // different coordinate systems.
402 ////////////////////////////////////////////////////////////////////
403 void Trackball::
404 set_coordinate_system(CoordinateSystem cs) {
405  _cs = cs;
406 }
407 
408 ////////////////////////////////////////////////////////////////////
409 // Function: Trackball::get_coordinate_system
410 // Access: Published
411 // Description: Returns the coordinate system of the Trackball.
412 // See set_coordinate_system().
413 ////////////////////////////////////////////////////////////////////
414 CoordinateSystem Trackball::
416  return _cs;
417 }
418 
419 ////////////////////////////////////////////////////////////////////
420 // Function: Trackball::set_mat
421 // Access: Published
422 // Description: Stores the indicated transform in the trackball.
423 // This is a transform in global space, regardless of
424 // the rel_to node.
425 ////////////////////////////////////////////////////////////////////
426 void Trackball::
427 set_mat(const LMatrix4 &mat) {
428  _orig = mat;
429  if (_invert) {
430  _mat = invert(_orig);
431  } else {
432  _mat = _orig;
433  }
434 
435  reextract();
436 }
437 
438 
439 ////////////////////////////////////////////////////////////////////
440 // Function: Trackball::get_mat
441 // Access: Published
442 // Description: Returns the matrix represented by the trackball
443 // rotation.
444 ////////////////////////////////////////////////////////////////////
445 const LMatrix4 &Trackball::
446 get_mat() const {
447  return _orig;
448 }
449 
450 ////////////////////////////////////////////////////////////////////
451 // Function: Trackball::get_trans_mat
452 // Access: Published
453 // Description: Returns the actual transform that will be applied to
454 // the scene graph. This is the same as get_mat(),
455 // unless invert is in effect.
456 ////////////////////////////////////////////////////////////////////
457 const LMatrix4 &Trackball::
458 get_trans_mat() const {
459  return _mat;
460 }
461 
462 
463 ////////////////////////////////////////////////////////////////////
464 // Function: Trackball::apply
465 // Access: Private
466 // Description: Applies the operation indicated by the user's mouse
467 // motion to the current state. Returns the matrix
468 // indicating the new state.
469 ////////////////////////////////////////////////////////////////////
470 void Trackball::
471 apply(double x, double y, int button) {
472  if (button && !_rel_to.is_empty()) {
473  // If we have a rel_to node, we must first adjust our rotation and
474  // translation to be in those local coordinates.
475  reextract();
476  }
477 
478  if (button == B1_MASK && _control_mode != CM_default) {
479  // We have a control mode set; this may change the meaning of
480  // button 1. Remap button to match the current control mode
481  // setting.
482  switch (_control_mode) {
483  case CM_truck:
484  button = B1_MASK;
485  break;
486 
487  case CM_pan:
488  button = B2_MASK;
489  break;
490 
491  case CM_dolly:
492  button = B3_MASK;
493  break;
494 
495  case CM_roll:
496  button = B2_MASK | B3_MASK;
497  break;
498 
499  case CM_default:
500  // Not possible due to above logic.
501  nassertv(false);
502  }
503  }
504 
505  if (button == B1_MASK) {
506  // Button 1: translate in plane parallel to screen.
507 
508  _translation +=
509  x * _fwdscale * LVector3::right(_cs) +
510  y * _fwdscale * LVector3::down(_cs);
511 
512  } else if (button == (B2_MASK | B3_MASK)) {
513  // Buttons 2 + 3: rotate about the vector perpendicular to the
514  // screen.
515 
516  _rotation *=
517  LMatrix4::rotate_mat_normaxis((x - y) * _rotscale,
518  LVector3::forward(_cs), _cs);
519 
520  } else if ((button == B2_MASK) || (button == (B1_MASK | B3_MASK))) {
521  // Button 2, or buttons 1 + 3: rotate about the right and up
522  // vectors. (We alternately define this as buttons 1 + 3, to
523  // support two-button mice.)
524 
525  _rotation *=
526  LMatrix4::rotate_mat_normaxis(x * _rotscale, LVector3::up(_cs), _cs) *
527  LMatrix4::rotate_mat_normaxis(y * _rotscale, LVector3::right(_cs), _cs);
528 
529  } else if ((button == B3_MASK) || (button == (B1_MASK | B2_MASK))) {
530  // Button 3, or buttons 1 + 2: dolly in and out along the forward
531  // vector. (We alternately define this as buttons 1 + 2, to
532  // support two-button mice.)
533  _translation -= y * _fwdscale * LVector3::forward(_cs);
534  }
535 
536  if (button) {
537  recompute();
538  }
539 }
540 
541 
542 ////////////////////////////////////////////////////////////////////
543 // Function: Trackball::reextract
544 // Access: Private
545 // Description: Given a correctly computed _orig matrix, rederive the
546 // translation and rotation elements.
547 ////////////////////////////////////////////////////////////////////
548 void Trackball::
549 reextract() {
550  LMatrix4 m = _orig;
551  if (!_rel_to.is_empty()) {
552  NodePath root;
553  m = _orig * root.get_transform(_rel_to)->get_mat();
554  }
555 
556  m.get_row3(_translation,3);
557  _rotation = m;
558  _rotation.set_row(3, LVecBase3(0.0f, 0.0f, 0.0f));
559 }
560 
561 ////////////////////////////////////////////////////////////////////
562 // Function: Trackball::recompute
563 // Access: Private
564 // Description: Rebuilds the matrix according to the stored rotation
565 // and translation components.
566 ////////////////////////////////////////////////////////////////////
567 void Trackball::
568 recompute() {
569  _orig = _rotation * LMatrix4::translate_mat(_translation);
570 
571  if (!_rel_to.is_empty()) {
572  NodePath root;
573  _orig = _orig * _rel_to.get_transform(root)->get_mat();
574  }
575 
576  if (_invert) {
577  _mat = invert(_orig);
578  } else {
579  _mat = _orig;
580  }
581 }
582 
583 
584 ////////////////////////////////////////////////////////////////////
585 // Function: Trackball::do_transmit_data
586 // Access: Protected, Virtual
587 // Description: The virtual implementation of transmit_data(). This
588 // function receives an array of input parameters and
589 // should generate an array of output parameters. The
590 // input parameters may be accessed with the index
591 // numbers returned by the define_input() calls that
592 // were made earlier (presumably in the constructor);
593 // likewise, the output parameters should be set with
594 // the index numbers returned by the define_output()
595 // calls.
596 ////////////////////////////////////////////////////////////////////
597 void Trackball::
598 do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input,
599  DataNodeTransmit &output) {
600  // First, update our modifier buttons.
601  bool required_buttons_match;
602  check_button_events(input, required_buttons_match);
603 
604  // Now, check for mouse motion.
605  if (required_buttons_match && input.has_data(_pixel_xy_input)) {
606  const EventStoreVec2 *pixel_xy;
607  DCAST_INTO_V(pixel_xy, input.get_data(_pixel_xy_input).get_ptr());
608  const LVecBase2 &p = pixel_xy->get_value();
609  PN_stdfloat this_x = p[0];
610  PN_stdfloat this_y = p[1];
611  int this_button = 0;
612 
613  if (is_down(MouseButton::one())) {
614  if (is_down(KeyboardButton::alt())) {
615  // B1 + alt (option) = B2.
616  this_button |= B2_MASK;
617  if (is_down(KeyboardButton::meta()) || is_down(KeyboardButton::control())) {
618  this_button |= B3_MASK;
619  }
620 
621  } else if (is_down(KeyboardButton::meta()) || is_down(KeyboardButton::control())) {
622  // B1 + meta (command) = B3.
623  this_button |= B3_MASK;
624 
625  } else {
626  // Without a special key, B1 is B1.
627  this_button |= B1_MASK;
628  }
629  }
630  if (is_down(MouseButton::two())) {
631  this_button |= B2_MASK;
632  }
633  if (is_down(MouseButton::three())) {
634  this_button |= B3_MASK;
635  }
636 
637  PN_stdfloat x = this_x - _lastx;
638  PN_stdfloat y = this_y - _lasty;
639 
640  if (this_button == _last_button) {
641  apply(x, y, this_button);
642  }
643 
644  _last_button = this_button;
645  _lastx = this_x;
646  _lasty = this_y;
647  } else {
648  _last_button = 0;
649  }
650 
651  // Now send our matrix down the pipe.
652  _transform = TransformState::make_mat(_mat);
653  output.set_data(_transform_output, EventParameter(_transform));
654 }
static const LMatrix4f & ident_mat()
Returns an identity matrix.
Definition: lmatrix.h:903
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
void set_mat(const LMatrix4 &mat)
Stores the indicated transform in the trackball.
Definition: trackball.cxx:427
static ButtonHandle three()
Returns the ButtonHandle associated with the third mouse button.
Definition: mouseButton.cxx:72
static ButtonHandle two()
Returns the ButtonHandle associated with the second mouse button.
Definition: mouseButton.cxx:61
const LPoint3 & get_pos() const
**** Translation ****
Definition: trackball.cxx:130
void set_control_mode(ControlMode control_mode)
Sets the control mode.
Definition: trackball.cxx:353
static LMatrix4f translate_mat(const LVecBase3f &trans)
Returns a matrix that applies the indicated translation.
Definition: lmatrix.h:2397
An optional parameter associated with an event.
const TransformState * get_transform(Thread *current_thread=Thread::get_current_thread()) const
Returns the complete transform object set on this node.
Definition: nodePath.cxx:925
void set_invert(bool flag)
Sets the invert flag.
Definition: trackball.cxx:325
static ButtonHandle one()
Returns the ButtonHandle associated with the first mouse button.
Definition: mouseButton.cxx:50
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
CoordinateSystem get_coordinate_system() const
Returns the coordinate system of the Trackball.
Definition: trackball.cxx:415
A handy class object for storing simple values (like integers or strings) passed along with an Event ...
Definition: paramValue.h:109
PN_stdfloat get_forward_scale() const
Returns the scale factor applied to forward and backward motion.
Definition: trackball.cxx:106
void set_coordinate_system(CoordinateSystem cs)
Sets the coordinate system of the Trackball.
Definition: trackball.cxx:404
static LVector3f forward(CoordinateSystem cs=CS_default)
Returns the forward vector for the given coordinate system.
Definition: lvector3.h:565
const NodePath & get_rel_to() const
Returns the NodePath that all trackball manipulations are relative to, or the empty path...
Definition: trackball.cxx:389
ControlMode
**** Misc ****
Definition: trackball.h:84
void set_data(int index, const EventParameter &data)
Sets the data for the indicated parameter.
LVecBase3 get_hpr() const
**** Rotation ****
Definition: trackball.cxx:192
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
void reset()
Reinitializes all transforms to identity.
Definition: trackball.cxx:92
LPoint3 get_origin() const
Returns the current center of rotation.
Definition: trackball.cxx:301
const EventParameter & get_data(int index) const
Extracts the data for the indicated index, if it has been stored, or the empty parameter if it has no...
This is the base class for all two-component vectors and points.
Definition: lvecBase2.h:105
void move_origin(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Moves the center of rotation by the given amount.
Definition: trackball.cxx:291
static LVector3f right(CoordinateSystem cs=CS_default)
Returns the right vector for the given coordinate system.
Definition: lvector3.h:554
ControlMode get_control_mode() const
Returns the control mode.
Definition: trackball.cxx:363
This is the base class for some classes that monitor the mouse and keyboard input and perform some ac...
const Type & get_value() const
Retrieves the value stored in the parameter.
Definition: paramValue.I:136
static LVector3f down(CoordinateSystem cs=CS_default)
Returns the down vector for the given coordinate system.
Definition: lvector3.h:596
const LMatrix4 & get_mat() const
Returns the matrix represented by the trackball rotation.
Definition: trackball.cxx:446
const LMatrix4 & get_trans_mat() const
Returns the actual transform that will be applied to the scene graph.
Definition: trackball.cxx:458
void set_origin(const LVecBase3 &origin)
Directly sets the center of rotation.
Definition: trackball.cxx:311
static LMatrix4f rotate_mat_normaxis(float angle, const LVecBase3f &axis, CoordinateSystem cs=CS_default)
Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vect...
Definition: lmatrix.h:2440
void set_rel_to(const NodePath &rel_to)
Sets the NodePath that all trackball manipulations are to be assumed to be relative to...
Definition: trackball.cxx:378
TypedWritableReferenceCount * get_ptr() const
Retrieves a pointer to the actual value stored in the parameter.
bool is_empty() const
Returns true if the NodePath contains no nodes.
Definition: nodePath.I:236
bool get_invert() const
Returns the invert flag.
Definition: trackball.cxx:337
void set_row(int row, const LVecBase4f &v)
Replaces the indicated row of the matrix.
Definition: lmatrix.h:1187
LVecBase3f get_row3(int row) const
Retrieves the row column of the matrix as a 3-component vector, ignoring the last column...
Definition: lmatrix.h:1312
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
void set_hpr(const LVecBase3 &hpr)
Directly set the mover's orientation.
Definition: trackball.cxx:226
void set_forward_scale(PN_stdfloat fwdscale)
Changes the scale factor applied to forward and backward motion.
Definition: trackball.cxx:119
bool has_data(int index) const
Returns true if the indicated parameter has been stored, false otherwise.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
static LVector3f up(CoordinateSystem cs=CS_default)
Returns the up vector for the given coordinate system.
Definition: lvector3.h:527
void set_pos(const LVecBase3 &vec)
Directly set the offset from the rotational origin.
Definition: trackball.cxx:156
Encapsulates the data generated from (or sent into) any particular DataNode.
void reset_origin_here()
**** Origin of Rotation ****
Definition: trackball.cxx:278
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...