Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/tform/trackball.h

Go to the documentation of this file.
00001 // Filename: trackball.h
00002 // Created by:  drose (12Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef TRACKBALL_H
00020 #define TRACKBALL_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "dataNode.h"
00025 #include "nodePath.h"
00026 #include "modifierButtons.h"
00027 #include "luse.h"
00028 #include "transformState.h"
00029 
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //       Class : Trackball
00033 // Description : Trackball acts like Performer in trackball mode.  It
00034 //               can either spin around a piece of geometry directly,
00035 //               or it can spin around a camera with the inverse
00036 //               transform to make it appear that the whole world is
00037 //               spinning.
00038 //
00039 //               The Trackball object actually just places a transform
00040 //               in the data graph; parent a Transform2SG node under
00041 //               it to actually transform objects (or cameras) in the
00042 //               world.
00043 ////////////////////////////////////////////////////////////////////
00044 class EXPCL_PANDA Trackball : public DataNode {
00045 PUBLISHED:
00046   Trackball(const string &name);
00047   ~Trackball();
00048 
00049   void reset();
00050 
00051   float get_forward_scale() const;
00052   void set_forward_scale(float fwdscale);
00053 
00054   /// **** Translation ****
00055 
00056   const LPoint3f &get_pos() const;
00057   float get_x() const;
00058   float get_y() const;
00059   float get_z() const;
00060   void set_pos(const LVecBase3f &vec);
00061   void set_pos(float x, float y, float z);
00062   void set_x(float x);
00063   void set_y(float y);
00064   void set_z(float z);
00065 
00066   /// **** Rotation ****
00067 
00068   LVecBase3f get_hpr() const;
00069   float get_h() const;
00070   float get_p() const;
00071   float get_r() const;
00072   void set_hpr(const LVecBase3f &hpr);
00073   void set_hpr(float h, float p, float r);
00074   void set_h(float h);
00075   void set_p(float p);
00076   void set_r(float r);
00077 
00078   /// **** Origin of Rotation ****
00079 
00080   void reset_origin_here();
00081   void move_origin(float x, float y, float z);
00082 
00083   LPoint3f get_origin() const;
00084   void set_origin(const LVecBase3f &origin);
00085 
00086   /// **** Misc ****
00087 
00088   void set_invert(bool flag);
00089   bool get_invert() const;
00090 
00091   void set_rel_to(const NodePath &_rel_to);
00092   const NodePath &get_rel_to() const;
00093 
00094   void set_coordinate_system(CoordinateSystem cs);
00095   CoordinateSystem get_coordinate_system() const;
00096 
00097   void set_mat(const LMatrix4f &mat);
00098   const LMatrix4f &get_mat() const;
00099   const LMatrix4f &get_trans_mat() const;
00100 
00101 
00102 private:
00103   void apply(double x, double y, int button);
00104 
00105   void reextract();
00106   void recompute();
00107 
00108 
00109   float _lastx, _lasty;
00110 
00111   float _rotscale;
00112   float _fwdscale;
00113 
00114   LMatrix4f _rotation;
00115   LPoint3f _translation;
00116   LMatrix4f _mat, _orig;
00117   bool _invert;
00118   NodePath _rel_to;
00119   CoordinateSystem _cs;
00120 
00121   // Remember which mouse buttons are being held down.
00122   ModifierButtons _mods;
00123 
00124 
00125 protected:
00126   // Inherited from DataNode
00127   virtual void do_transmit_data(const DataNodeTransmit &input,
00128                                 DataNodeTransmit &output);
00129 
00130 private:
00131   // inputs
00132   int _pixel_xy_input;
00133   int _button_events_input;
00134 
00135   // outputs
00136   int _transform_output;
00137 
00138   PT(EventStoreTransform) _transform;
00139 
00140 public:
00141   static TypeHandle get_class_type() {
00142     return _type_handle;
00143   }
00144   static void init_type() {
00145     DataNode::init_type();
00146     register_type(_type_handle, "Trackball",
00147                   DataNode::get_class_type());
00148   }
00149   virtual TypeHandle get_type() const {
00150     return get_class_type();
00151   }
00152   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00153 
00154 private:
00155   static TypeHandle _type_handle;
00156 };
00157 
00158 #endif

Generated on Fri May 2 00:44:31 2003 for Panda by doxygen1.3