Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
fa325c0072

+ 2 - 0
direct/src/distributed/ClientRepository.py

@@ -99,6 +99,7 @@ class ClientRepository(DirectObject.DirectObject):
                                                        "." + \
                                                        "." + \
                                                        cdc.name),
                                                        cdc.name),
                                                   doId, di)
                                                   doId, di)
+        distObj.generate()
         return None
         return None
 
 
     def handleGenerateWithRequiredOther(self, di):
     def handleGenerateWithRequiredOther(self, di):
@@ -114,6 +115,7 @@ class ClientRepository(DirectObject.DirectObject):
                                                             "." + \
                                                             "." + \
                                                             cdc.name),
                                                             cdc.name),
                                                        doId, di)
                                                        doId, di)
+        distObj.generate()
         return None
         return None
 
 
     def generateWithRequiredFields(self, cdc, constructor, doId, di):
     def generateWithRequiredFields(self, cdc, constructor, doId, di):

+ 6 - 0
direct/src/distributed/DistributedObject.py

@@ -24,6 +24,12 @@ class DistributedObject(PandaObject):
         Inheritors should redefine this to take appropriate action on delete
         Inheritors should redefine this to take appropriate action on delete
         """
         """
         pass
         pass
+
+    def generate(self):
+        """generate(self)
+        Inheritors should redefine this to take appropriate action on generate
+        """
+        pass
     
     
     def getDoId(self):
     def getDoId(self):
         """getDoId(self)
         """getDoId(self)

+ 4 - 4
panda/src/chan/animControl.cxx

@@ -68,7 +68,7 @@ play(int from, int to, const CPT_Event &stop_event) {
 
 
   nassertv(from >= 0 && from < get_num_frames());
   nassertv(from >= 0 && from < get_num_frames());
   nassertv(to >= 0 && to < get_num_frames());
   nassertv(to >= 0 && to < get_num_frames());
-  _as_of_time = ClockObject::get_global_clock()->get_time();
+  _as_of_time = ClockObject::get_global_clock()->get_frame_time();
   _playing = true;
   _playing = true;
 
 
   _actions = _user_actions;
   _actions = _user_actions;
@@ -92,7 +92,7 @@ void AnimControl::
 loop(bool restart) {
 loop(bool restart) {
   nassertv(get_num_frames() > 0);
   nassertv(get_num_frames() > 0);
 
 
-  _as_of_time = ClockObject::get_global_clock()->get_time();
+  _as_of_time = ClockObject::get_global_clock()->get_frame_time();
   _playing = true;
   _playing = true;
 
 
   _actions = _user_actions;
   _actions = _user_actions;
@@ -122,7 +122,7 @@ loop(bool restart, int from, int to) {
 
 
   nassertv(from >= 0 && from < get_num_frames());
   nassertv(from >= 0 && from < get_num_frames());
   nassertv(to >= 0 && to < get_num_frames());
   nassertv(to >= 0 && to < get_num_frames());
-  _as_of_time = ClockObject::get_global_clock()->get_time();
+  _as_of_time = ClockObject::get_global_clock()->get_frame_time();
   _playing = true;
   _playing = true;
 
 
   _actions = _user_actions;
   _actions = _user_actions;
@@ -197,7 +197,7 @@ pose(int frame) {
   nassertv(get_num_frames() > 0);
   nassertv(get_num_frames() > 0);
 
 
   nassertv(frame >= 0 && frame < get_num_frames());
   nassertv(frame >= 0 && frame < get_num_frames());
-  _as_of_time = ClockObject::get_global_clock()->get_time();
+  _as_of_time = ClockObject::get_global_clock()->get_frame_time();
   _playing = false;
   _playing = false;
 
 
   _actions = _user_actions;
   _actions = _user_actions;

+ 1 - 1
panda/src/char/character.cxx

@@ -101,7 +101,7 @@ safe_to_transform() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void Character::
 void Character::
 app_traverse() {
 app_traverse() {
-  double now = ClockObject::get_global_clock()->get_time();
+  double now = ClockObject::get_global_clock()->get_frame_time();
   get_bundle()->advance_time(now);
   get_bundle()->advance_time(now);
 
 
   if (char_cat.is_debug()) {
   if (char_cat.is_debug()) {

+ 1 - 1
panda/src/device/clientBase.cxx

@@ -184,7 +184,7 @@ void ClientBase::
 do_poll() {
 do_poll() {
   ClockObject *global_clock = ClockObject::get_global_clock();
   ClockObject *global_clock = ClockObject::get_global_clock();
   _last_poll_frame = global_clock->get_frame_count();
   _last_poll_frame = global_clock->get_frame_count();
-  _last_poll_time = global_clock->get_time();
+  _last_poll_time = global_clock->get_frame_time();
 }
 }
 
 
 #ifdef HAVE_IPC
 #ifdef HAVE_IPC

+ 65 - 10
panda/src/express/clockObject.I

@@ -18,10 +18,10 @@ INLINE ClockObject::
 //  Description: Changes the mode of the clock, e.g. from normal
 //  Description: Changes the mode of the clock, e.g. from normal
 //               (real-time) to non-real-time.  In non-real-time mode,
 //               (real-time) to non-real-time.  In non-real-time mode,
 //               tick() will add the value of dt to the value returned
 //               tick() will add the value of dt to the value returned
-//               by get_time(), regardless of how much time has
+//               by get_frame_time(), regardless of how much time has
 //               actually passed.  In normal, real-time mode, tick()
 //               actually passed.  In normal, real-time mode, tick()
-//               will set the value returned by get_time() to the
-//               current real time.
+//               will set the value returned by get_frame_time() to
+//               the current real time.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE void ClockObject::
 INLINE void ClockObject::
 set_mode(ClockObject::Mode mode) {
 set_mode(ClockObject::Mode mode) {
@@ -40,7 +40,7 @@ get_mode() const {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ClockObject::get_time
+//     Function: ClockObject::get_frame_time
 //       Access: Public
 //       Access: Public
 //  Description: Returns the time in seconds as of the last time
 //  Description: Returns the time in seconds as of the last time
 //               tick() was called (typically, this will be as of the
 //               tick() was called (typically, this will be as of the
@@ -52,8 +52,8 @@ get_mode() const {
 //               frame remains in sync with each other.
 //               frame remains in sync with each other.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE double ClockObject::
 INLINE double ClockObject::
-get_time() const {
-  return _reported_time;
+get_frame_time() const {
+  return _reported_frame_time;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -71,7 +71,7 @@ get_time() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE double ClockObject::
 INLINE double ClockObject::
 get_intra_frame_time() const {
 get_intra_frame_time() const {
-  return get_real_time() - _frame_time;
+  return get_real_time() - _actual_frame_time;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -95,15 +95,46 @@ get_real_time() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE void ClockObject::
 INLINE void ClockObject::
 reset() {
 reset() {
-  set_time(0.0);
+  set_real_time(0.0);
+  set_frame_time(0.0);
   set_frame_count(0);
   set_frame_count(0);
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: ClockObject::set_real_time
+//       Access: Public
+//  Description: Resets the clock to the indicated time.  This
+//               changes only the real time of the clock as reported
+//               by get_real_time(), but does not immediately change
+//               the time reported by get_frame_time()--that will
+//               change after the next call to tick().  Also see
+//               reset(), set_frame_time(), and set_frame_count().
+////////////////////////////////////////////////////////////////////
+INLINE void ClockObject::
+set_real_time(double time) {
+  _start_time = _true_clock->get_real_time() - time;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ClockObject::set_frame_time
+//       Access: Public
+//  Description: Changes the time as reported for the current frame to
+//               the indicated time.  Normally, the way to adjust the
+//               frame time is via tick(); this function is provided
+//               only for occasional special adjustments.
+////////////////////////////////////////////////////////////////////
+INLINE void ClockObject::
+set_frame_time(double time) {
+  _actual_frame_time = time;
+  _reported_frame_time = time;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ClockObject::set_frame_count
 //     Function: ClockObject::set_frame_count
 //       Access: Public
 //       Access: Public
 //  Description: Resets the number of frames counted to the indicated
 //  Description: Resets the number of frames counted to the indicated
-//               number.  Also see reset() and set_time().
+//               number.  Also see reset(), set_real_time(), and
+//               set_frame_time().
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE void ClockObject::
 INLINE void ClockObject::
 set_frame_count(int frame_count) {
 set_frame_count(int frame_count) {
@@ -132,7 +163,7 @@ get_frame_count() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE double ClockObject::
 INLINE double ClockObject::
 get_frame_rate() const {
 get_frame_rate() const {
-  return (double)get_frame_count() / get_time();
+  return (double)get_frame_count() / get_frame_time();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -178,3 +209,27 @@ get_global_clock() {
   }
   }
   return _global_clock;
   return _global_clock;
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: ClockObject::get_time
+//       Access: Public
+//  Description: Returns get_frame_time().  The use of this function
+//               is deprecated and the function will soon disappear;
+//               use get_frame_time() instead.
+////////////////////////////////////////////////////////////////////
+INLINE double ClockObject::
+get_time() const {
+  return get_frame_time();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ClockObject::set_time
+//       Access: Public
+//  Description: Calls set_real_time().  The use of this function
+//               is deprecated and the function will soon disappear;
+//               use set_real_time() instead.
+////////////////////////////////////////////////////////////////////
+INLINE void ClockObject::
+set_time(double time) {
+  set_real_time(time);
+}

+ 12 - 34
panda/src/express/clockObject.cxx

@@ -19,56 +19,34 @@ ClockObject() {
   _mode = M_normal;
   _mode = M_normal;
   _start_time = _true_clock->get_real_time();
   _start_time = _true_clock->get_real_time();
   _frame_count = 0;
   _frame_count = 0;
-  _frame_time = 0.0;
-  _reported_time = 0.0;
+  _actual_frame_time = 0.0;
+  _reported_frame_time = 0.0;
   _dt = 0.0;
   _dt = 0.0;
 }
 }
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: ClockObject::set_time
-//       Access: Public
-//  Description: Resets the clock to the indicated time.  Also see
-//               reset() and set_frame_count().
-////////////////////////////////////////////////////////////////////
-void ClockObject::
-set_time(double time) {
-  double true_time = _true_clock->get_real_time();
-  _start_time = true_time - time;
-  _frame_time = time;
-
-  switch (_mode) {
-  case M_normal:
-    _reported_time = _frame_time;
-    break;
-
-  case M_non_real_time:
-    _reported_time = time;
-    break;
-  }
-}
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ClockObject::tick
 //     Function: ClockObject::tick
 //       Access: Public
 //       Access: Public
 //  Description: Instructs the clock that a new frame has just begun.
 //  Description: Instructs the clock that a new frame has just begun.
-//               In normal, real-time mode, get_time() will henceforth
-//               report the time as of this instant as the current
-//               start-of-frame time.  In non-real-time mode,
-//               get_time() will be incremented by the value of dt.
+//               In normal, real-time mode, get_frame_time() will
+//               henceforth report the time as of this instant as the
+//               current start-of-frame time.  In non-real-time mode,
+//               get_frame_time() will be incremented by the value of
+//               dt.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void ClockObject::
 void ClockObject::
 tick() {
 tick() {
-  double old_time = _frame_time;
-  _frame_time = get_real_time();
+  double old_time = _actual_frame_time;
+  _actual_frame_time = get_real_time();
 
 
   switch (_mode) {
   switch (_mode) {
   case M_normal:
   case M_normal:
-    _dt = _frame_time - old_time;
-    _reported_time = _frame_time;
+    _dt = _actual_frame_time - old_time;
+    _reported_frame_time = _actual_frame_time;
     break;
     break;
 
 
   case M_non_real_time:
   case M_non_real_time:
-    _reported_time += _dt;
+    _reported_frame_time += _dt;
     break;
     break;
   }
   }
 
 

+ 9 - 5
panda/src/express/clockObject.h

@@ -48,13 +48,13 @@ PUBLISHED:
   INLINE void set_mode(Mode mode);
   INLINE void set_mode(Mode mode);
   INLINE Mode get_mode() const;
   INLINE Mode get_mode() const;
 
 
-  INLINE double get_time() const;
+  INLINE double get_frame_time() const;
   INLINE double get_intra_frame_time() const;
   INLINE double get_intra_frame_time() const;
   INLINE double get_real_time() const;
   INLINE double get_real_time() const;
 
 
   INLINE void reset();
   INLINE void reset();
-
-  void set_time(double time);
+  INLINE void set_real_time(double time);
+  INLINE void set_frame_time(double time);
   INLINE void set_frame_count(int frame_count);
   INLINE void set_frame_count(int frame_count);
 
 
   INLINE int get_frame_count() const;
   INLINE int get_frame_count() const;
@@ -67,13 +67,17 @@ PUBLISHED:
 
 
   INLINE static ClockObject *get_global_clock();
   INLINE static ClockObject *get_global_clock();
 
 
+  // Deprecated functions.
+  INLINE double get_time() const;
+  INLINE void set_time(double time);
+
 private:
 private:
   TrueClock *_true_clock;
   TrueClock *_true_clock;
   Mode _mode;
   Mode _mode;
   double _start_time;
   double _start_time;
   int _frame_count;
   int _frame_count;
-  double _frame_time;
-  double _reported_time;
+  double _actual_frame_time;
+  double _reported_frame_time;
   double _dt;
   double _dt;
 
 
   static ClockObject *_global_clock;
   static ClockObject *_global_clock;

+ 4 - 4
panda/src/framework/framework.cxx

@@ -391,7 +391,7 @@ void event_esc(CPT_Event) {
   }
   }
 #endif
 #endif
 
 
-  double now = ClockObject::get_global_clock()->get_time();
+  double now = ClockObject::get_global_clock()->get_frame_time();
   double delta = now - start_time;
   double delta = now - start_time;
 
 
   int frame_count = ClockObject::get_global_clock()->get_frame_count();
   int frame_count = ClockObject::get_global_clock()->get_frame_count();
@@ -420,7 +420,7 @@ void event_esc(CPT_Event) {
 }
 }
 
 
 void event_f(CPT_Event) {
 void event_f(CPT_Event) {
-  double now = ClockObject::get_global_clock()->get_time();
+  double now = ClockObject::get_global_clock()->get_frame_time();
   double delta = now - start_time;
   double delta = now - start_time;
 
 
   int frame_count = ClockObject::get_global_clock()->get_frame_count();
   int frame_count = ClockObject::get_global_clock()->get_frame_count();
@@ -533,7 +533,7 @@ void handle_framerate(void) {
     return;
     return;
   }
   }
 
 
-  double now = ClockObject::get_global_clock()->get_time();
+  double now = ClockObject::get_global_clock()->get_frame_time();
 
 
   if (first_time) {
   if (first_time) {
     if (prev_times == (double*)0L) {
     if (prev_times == (double*)0L) {
@@ -1163,7 +1163,7 @@ int framework_main(int argc, char *argv[]) {
   // Tick the clock once so we won't count the time spent loading up
   // Tick the clock once so we won't count the time spent loading up
   // files, above, in our frame rate average.
   // files, above, in our frame rate average.
   ClockObject::get_global_clock()->tick();
   ClockObject::get_global_clock()->tick();
-  start_time = ClockObject::get_global_clock()->get_time();
+  start_time = ClockObject::get_global_clock()->get_frame_time();
   start_frame_count = ClockObject::get_global_clock()->get_frame_count();
   start_frame_count = ClockObject::get_global_clock()->get_frame_count();
 
 
   if (framework.Defined("clear-value")) {
   if (framework.Defined("clear-value")) {

+ 38 - 0
panda/src/gobj/perspectiveProjection.cxx

@@ -166,3 +166,41 @@ extrude(const LPoint2f &point2d, LPoint3f &origin, LVector3f &direction,
   direction = far_vector - near_vector;
   direction = far_vector - near_vector;
   return true;
   return true;
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: PerspectiveProjection::project
+//       Access: Public, Virtual
+//  Description: Given a 3-d point in space, determine the 2-d point
+//               this maps to, in the range (-1,1) in both dimensions,
+//               where (0,0) is the center of the projection and
+//               (-1,-1) is the lower-left corner.  Returns true if
+//               the 3-d point is in front of the projection and
+//               within the viewing frustum (in which case point2d is
+//               filled in), or false otherwise.
+////////////////////////////////////////////////////////////////////
+bool PerspectiveProjection::
+project(const LPoint3f &point3d, LPoint2f &point2d,
+	CoordinateSystem cs) const {
+  float f = point3d.dot(LVector3f::forward(cs));
+  if (f < _frustum._fnear || f > _frustum._ffar) {
+    // The point is outside the near or far clipping planes.
+    return false;
+  }
+
+  float r = point3d.dot(LVector3f::right(cs));
+  float u = point3d.dot(LVector3f::up(cs));
+
+  LPoint2f scaled(r * _frustum._fnear / f, u * _frustum._fnear / f);
+
+  if (scaled[0] < _frustum._l || scaled[0] > _frustum._r ||
+      scaled[1] < _frustum._b || scaled[1] > _frustum._t) {
+    // The point is outside of the edge planes.
+    return false;
+  }
+
+  point2d.set((scaled[0] - _frustum._l) * 2.0 / 
+	      (_frustum._r - _frustum._l) - 1.0,
+	      (scaled[1] - _frustum._b) * 2.0 / 
+	      (_frustum._t - _frustum._b) - 1.0);
+  return true;
+}

+ 2 - 0
panda/src/gobj/perspectiveProjection.h

@@ -32,6 +32,8 @@ public:
   virtual bool extrude(const LPoint2f &point2d,
   virtual bool extrude(const LPoint2f &point2d,
 		       LPoint3f &origin, LVector3f &direction,
 		       LPoint3f &origin, LVector3f &direction,
 		       CoordinateSystem cs = CS_default) const;
 		       CoordinateSystem cs = CS_default) const;
+  virtual bool project(const LPoint3f &point3d, LPoint2f &point2d,
+		       CoordinateSystem cs) const;
 
 
   INLINE const Frustumf &get_frustum() const;
   INLINE const Frustumf &get_frustum() const;
   INLINE void set_frustum(const Frustumf &frust);
   INLINE void set_frustum(const Frustumf &frust);

+ 16 - 0
panda/src/gobj/projection.cxx

@@ -50,3 +50,19 @@ bool Projection::
 extrude(const LPoint2f &, LPoint3f &, LVector3f &, CoordinateSystem) const {
 extrude(const LPoint2f &, LPoint3f &, LVector3f &, CoordinateSystem) const {
   return false;
   return false;
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: Projection::project
+//       Access: Public, Virtual
+//  Description: Given a 3-d point in space, determine the 2-d point
+//               this maps to, in the range (-1,1) in both dimensions,
+//               where (0,0) is the center of the projection and
+//               (-1,-1) is the lower-left corner.  Returns true if
+//               the 3-d point is in front of the projection and
+//               within the viewing frustum (in which case point2d is
+//               filled in), or false otherwise.
+////////////////////////////////////////////////////////////////////
+bool Projection::
+project(const LPoint3f &, LPoint2f &, CoordinateSystem) const {
+  return false;
+}

+ 6 - 4
panda/src/gobj/projection.h

@@ -24,16 +24,18 @@ class EXPCL_PANDA Projection : public TypedReferenceCount {
 PUBLISHED:
 PUBLISHED:
   virtual Projection *make_copy() const=0;
   virtual Projection *make_copy() const=0;
 
 
+  virtual bool extrude(const LPoint2f &point2d,
+		       LPoint3f &origin, LVector3f &direction,
+		       CoordinateSystem cs = CS_default) const;
+  virtual bool project(const LPoint3f &point3d, LPoint2f &point2d,
+		       CoordinateSystem cs = CS_default) const;
+
 public:
 public:
   virtual LMatrix4f get_projection_mat(CoordinateSystem cs = CS_default) const=0;
   virtual LMatrix4f get_projection_mat(CoordinateSystem cs = CS_default) const=0;
   virtual Geom* make_geometry(const Colorf &color = Colorf(0.0, 1.0, 0.0, 1.0),
   virtual Geom* make_geometry(const Colorf &color = Colorf(0.0, 1.0, 0.0, 1.0),
 			      CoordinateSystem cs = CS_default) const;
 			      CoordinateSystem cs = CS_default) const;
 
 
   virtual BoundingVolume *make_bounds(CoordinateSystem cs = CS_default) const;
   virtual BoundingVolume *make_bounds(CoordinateSystem cs = CS_default) const;
-
-  virtual bool extrude(const LPoint2f &point2d,
-		       LPoint3f &origin, LVector3f &direction,
-		       CoordinateSystem cs = CS_default) const;
   
   
 public:
 public:
   virtual TypeHandle get_type() const {
   virtual TypeHandle get_type() const {

+ 0 - 183
panda/src/sgraph/camera.cxx

@@ -9,11 +9,6 @@
 #include <pandabase.h>
 #include <pandabase.h>
 #include "camera.h"
 #include "camera.h"
 #include <projection.h>
 #include <projection.h>
-#include <perspectiveProjection.h>
-#include <frustum.h>
-#include <geometricBoundingVolume.h>
-
-#include <algorithm>
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -138,184 +133,6 @@ get_dr(int index) const {
   return _display_regions[index];
   return _display_regions[index];
 }
 }
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: Camera::is_in_view
-//       Access: Public
-//  Description: Returns true if the given point is within the bounds
-//		 of the projection of the camera (i.e. if the camera
-//		 can see the point).
-////////////////////////////////////////////////////////////////////
-bool Camera::
-is_in_view(const LPoint3f &pos) {
-  BoundingVolume *bv = _projection->make_bounds();
-  if (bv == NULL)
-    return false;
-  GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, bv);
-  int ret = gbv->contains(pos);
-  delete bv;
-  return (ret != 0);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: Camera::get_fov_near_far
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-void Camera::
-get_perspective_params(float &yfov, float &aspect, float &cnear, 
-		       float &cfar) const {
-  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
-    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
-    proj->get_frustum().get_perspective_params(yfov, aspect, cnear, cfar);
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: Camera::get_fov_near_far
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-void Camera::
-get_perspective_params(float &xfov, float &yfov, float &aspect, float &cnear, 
-		       float &cfar) const {
-  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
-    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
-    proj->get_frustum().get_perspective_params(xfov, yfov, aspect, cnear,
-					       cfar);
-  }
-}
-
-float Camera::
-get_hfov(void) const {
-  float xfov=0.0, yfov=0.0, aspect, cnear, cfar;
-  get_perspective_params(xfov, yfov, aspect, cnear, cfar);
-  return xfov;
-}
-
-float Camera::
-get_vfov(void) const {
-  float xfov=0.0, yfov=0.0, aspect, cnear, cfar;
-  get_perspective_params(xfov, yfov, aspect, cnear, cfar);
-  return yfov;
-}
-
-float Camera::
-get_aspect(void) const {
-  float yfov, aspect=0.0, cnear, cfar;
-  get_perspective_params(yfov, aspect, cnear, cfar);
-  return aspect;
-}
-
-void Camera::
-get_near_far(float &cnear, float &cfar) const {
-  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
-    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
-    cnear = proj->get_frustum()._fnear;
-    cfar = proj->get_frustum()._ffar;
-  }
-}
-
-float Camera::
-get_near(void) const {
-  float cnear, cfar;
-  get_near_far(cnear, cfar);
-  return cnear;
-}
-
-float Camera::
-get_far(void) const {
-  float cnear, cfar;
-  get_near_far(cnear, cfar);
-  return cfar;
-}
-
-void Camera::
-set_fov(float hfov) {
-  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
-    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
-    float tfov, ufov, aspect, cnear, cfar;
-    Frustumf frust = proj->get_frustum();
-    frust.get_perspective_params(tfov, ufov, aspect, cnear, cfar);
-    frust.make_perspective_hfov(hfov, aspect, cnear, cfar);
-    proj->set_frustum(frust);
-  }
-}
-
-void Camera::
-set_fov(float hfov, float vfov) {
-  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
-    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
-    float tfov, ufov, aspect, cnear, cfar;
-    Frustumf frust = proj->get_frustum();
-    frust.get_perspective_params(tfov, ufov, aspect, cnear, cfar);
-    frust.make_perspective(hfov, vfov, cnear, cfar);
-    proj->set_frustum(frust);
-  }
-}
-
-void Camera::
-set_hfov(float hfov) {
-  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
-    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
-    float tfov, ufov, aspect, cnear, cfar;
-    Frustumf frust = proj->get_frustum();
-    frust.get_perspective_params(tfov, ufov, aspect, cnear, cfar);
-    frust.make_perspective(hfov, ufov, cnear, cfar);
-    proj->set_frustum(frust);
-  }
-}
-
-void Camera::
-set_vfov(float vfov) {
-  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
-    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
-    float tfov, ufov, aspect, cnear, cfar;
-    Frustumf frust = proj->get_frustum();
-    frust.get_perspective_params(tfov, ufov, aspect, cnear, cfar);
-    frust.make_perspective(tfov, vfov, cnear, cfar);
-    proj->set_frustum(frust);
-  }
-}
-
-void Camera::
-set_aspect(float aspect) {
-  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
-    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
-    float xfov, yfov, taspect, cnear, cfar;
-    Frustumf frust = proj->get_frustum();
-    frust.get_perspective_params(xfov, yfov, taspect, cnear, cfar);
-    // I don't know what to do when the aspect changes.  I have arbitrarilly
-    // decided to preserved the horizontal FoV.  The vertical will be
-    // recomputed based on the new aspect and the horizontal.
-    frust.make_perspective_hfov(xfov, aspect, cnear, cfar);
-    proj->set_frustum(frust);
-  }
-}
-
-void Camera::
-set_near_far(float cnear, float cfar) {
-  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
-    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
-    float xfov, yfov, aspect, tnear, tfar;
-    Frustumf frust = proj->get_frustum();
-    frust.get_perspective_params(xfov, yfov, aspect, tnear, tfar);
-    frust.make_perspective(xfov, yfov, cnear, cfar);
-    proj->set_frustum(frust);
-  }
-}
-
-void Camera::
-set_near(float cnear) {
-  float cfar = get_far();
-  set_near_far(cnear, cfar);
-}
-
-void Camera::
-set_far(float cfar) {
-  float cnear = get_near();
-  set_near_far(cnear, cfar);
-}
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Camera::add_display_region
 //     Function: Camera::add_display_region
 //       Access: Private
 //       Access: Private

+ 0 - 21
panda/src/sgraph/camera.h

@@ -52,27 +52,6 @@ PUBLISHED:
   int get_num_drs() const;
   int get_num_drs() const;
   DisplayRegion *get_dr(int index) const;
   DisplayRegion *get_dr(int index) const;
 
 
-  bool is_in_view(const LPoint3f &pos);
-
-  void get_perspective_params(float &yfov, float &aspect, float &cnear, 
-			      float &cfar) const;
-  void get_perspective_params(float &xfov, float &yfov, float &aspect,
-			      float &cnear, float &cfar) const;
-  float get_hfov(void) const;
-  float get_vfov(void) const;
-  void set_fov(float hfov);
-  void set_fov(float hfov, float vfov);
-  void set_hfov(float hfov);
-  void set_vfov(float vfov);
-  float get_aspect(void) const;
-  void set_aspect(float aspect);
-  void get_near_far(float &cnear, float &cfar) const;
-  void set_near_far(float cnear, float cfar);
-  float get_near(void) const;
-  void set_near(float cnear);
-  float get_far(void) const;
-  void set_far(float cfar);
-
 private:
 private:
   void add_display_region(DisplayRegion *display_region);
   void add_display_region(DisplayRegion *display_region);
   void remove_display_region(DisplayRegion *display_region);
   void remove_display_region(DisplayRegion *display_region);

+ 270 - 0
panda/src/sgraph/projectionNode.cxx

@@ -9,6 +9,9 @@
 #include "projectionNode.h"
 #include "projectionNode.h"
 #include <frustum.h>
 #include <frustum.h>
 #include <perspectiveProjection.h>
 #include <perspectiveProjection.h>
+#include <geometricBoundingVolume.h>
+
+#include <algorithm>
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 // Static variables
 // Static variables
@@ -70,3 +73,270 @@ get_projection() {
 
 
   return _projection;
   return _projection;
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::is_in_view
+//       Access: Public
+//  Description: Returns true if the given point is within the bounds
+//		 of the projection of the ProjectionNode (i.e. if the
+//		 camera can see the point).
+////////////////////////////////////////////////////////////////////
+bool ProjectionNode::
+is_in_view(const LPoint3f &pos) {
+  BoundingVolume *bv = _projection->make_bounds();
+  if (bv == NULL)
+    return false;
+  GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, bv);
+  int ret = gbv->contains(pos);
+  delete bv;
+  return (ret != 0);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::get_perspective_params
+//       Access: Public
+//  Description: Gets the viewing parameters of the ProjectionNode,
+//               assuming it represents a perspective frustum.
+////////////////////////////////////////////////////////////////////
+void ProjectionNode::
+get_perspective_params(float &yfov, float &aspect, float &cnear, 
+		       float &cfar) const {
+  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
+    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
+    proj->get_frustum().get_perspective_params(yfov, aspect, cnear, cfar);
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::get_perspective_params
+//       Access: Public
+//  Description: Gets the viewing parameters of the ProjectionNode,
+//               assuming it represents a perspective frustum.
+////////////////////////////////////////////////////////////////////
+void ProjectionNode::
+get_perspective_params(float &xfov, float &yfov, float &aspect, float &cnear, 
+		       float &cfar) const {
+  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
+    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
+    proj->get_frustum().get_perspective_params(xfov, yfov, aspect, cnear,
+					       cfar);
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::get_hfov
+//       Access: Public
+//  Description: Gets the horizontal field of view of the
+//               ProjectionNode, assuming it represents a perspective
+//               frustum.
+////////////////////////////////////////////////////////////////////
+float ProjectionNode::
+get_hfov(void) const {
+  float xfov=0.0, yfov=0.0, aspect, cnear, cfar;
+  get_perspective_params(xfov, yfov, aspect, cnear, cfar);
+  return xfov;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::get_vfov
+//       Access: Public
+//  Description: Gets the vertical field of view of the
+//               ProjectionNode, assuming it represents a perspective
+//               frustum.
+////////////////////////////////////////////////////////////////////
+float ProjectionNode::
+get_vfov(void) const {
+  float xfov=0.0, yfov=0.0, aspect, cnear, cfar;
+  get_perspective_params(xfov, yfov, aspect, cnear, cfar);
+  return yfov;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::get_aspect
+//       Access: Public
+//  Description: Gets the aspect ratio of the horizontal field of view
+//               to the vertical field of view, assuming we have a
+//               perspective frustum.
+////////////////////////////////////////////////////////////////////
+float ProjectionNode::
+get_aspect(void) const {
+  float yfov, aspect=0.0, cnear, cfar;
+  get_perspective_params(yfov, aspect, cnear, cfar);
+  return aspect;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::get_near_far
+//       Access: Public
+//  Description: Gets the near and far clipping planes, assuming we
+//               have a perspective frustum.
+////////////////////////////////////////////////////////////////////
+void ProjectionNode::
+get_near_far(float &cnear, float &cfar) const {
+  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
+    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
+    cnear = proj->get_frustum()._fnear;
+    cfar = proj->get_frustum()._ffar;
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::get_near
+//       Access: Public
+//  Description: Gets the near clipping plane, assuming we have a
+//               perspective frustum.
+////////////////////////////////////////////////////////////////////
+float ProjectionNode::
+get_near(void) const {
+  float cnear, cfar;
+  get_near_far(cnear, cfar);
+  return cnear;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::get_far
+//       Access: Public
+//  Description: Gets the far clipping plane, assuming we have a
+//               perspective frustum.
+////////////////////////////////////////////////////////////////////
+float ProjectionNode::
+get_far(void) const {
+  float cnear, cfar;
+  get_near_far(cnear, cfar);
+  return cfar;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::set_fov
+//       Access: Public
+//  Description: Sets the field-of-view of the ProjectionNode,
+//               assuming it represents a perspective frustum.
+////////////////////////////////////////////////////////////////////
+void ProjectionNode::
+set_fov(float hfov) {
+  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
+    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
+    float tfov, ufov, aspect, cnear, cfar;
+    Frustumf frust = proj->get_frustum();
+    frust.get_perspective_params(tfov, ufov, aspect, cnear, cfar);
+    frust.make_perspective_hfov(hfov, aspect, cnear, cfar);
+    proj->set_frustum(frust);
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::set_fov
+//       Access: Public
+//  Description: Sets the field-of-view of the ProjectionNode,
+//               assuming it represents a perspective frustum.
+////////////////////////////////////////////////////////////////////
+void ProjectionNode::
+set_fov(float hfov, float vfov) {
+  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
+    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
+    float tfov, ufov, aspect, cnear, cfar;
+    Frustumf frust = proj->get_frustum();
+    frust.get_perspective_params(tfov, ufov, aspect, cnear, cfar);
+    frust.make_perspective(hfov, vfov, cnear, cfar);
+    proj->set_frustum(frust);
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::set_hfov
+//       Access: Public
+//  Description: Sets the horizontal field-of-view of the ProjectionNode,
+//               assuming it represents a perspective frustum.
+////////////////////////////////////////////////////////////////////
+void ProjectionNode::
+set_hfov(float hfov) {
+  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
+    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
+    float tfov, ufov, aspect, cnear, cfar;
+    Frustumf frust = proj->get_frustum();
+    frust.get_perspective_params(tfov, ufov, aspect, cnear, cfar);
+    frust.make_perspective(hfov, ufov, cnear, cfar);
+    proj->set_frustum(frust);
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::set_vfov
+//       Access: Public
+//  Description: Sets the vertical field-of-view of the ProjectionNode,
+//               assuming it represents a perspective frustum.
+////////////////////////////////////////////////////////////////////
+void ProjectionNode::
+set_vfov(float vfov) {
+  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
+    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
+    float tfov, ufov, aspect, cnear, cfar;
+    Frustumf frust = proj->get_frustum();
+    frust.get_perspective_params(tfov, ufov, aspect, cnear, cfar);
+    frust.make_perspective(tfov, vfov, cnear, cfar);
+    proj->set_frustum(frust);
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::set_aspect
+//       Access: Public
+//  Description: Sets the aspect ratio of the ProjectionNode,
+//               assuming it represents a perspective frustum.
+////////////////////////////////////////////////////////////////////
+void ProjectionNode::
+set_aspect(float aspect) {
+  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
+    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
+    float xfov, yfov, taspect, cnear, cfar;
+    Frustumf frust = proj->get_frustum();
+    frust.get_perspective_params(xfov, yfov, taspect, cnear, cfar);
+    // I don't know what to do when the aspect changes.  I have arbitrarilly
+    // decided to preserved the horizontal FoV.  The vertical will be
+    // recomputed based on the new aspect and the horizontal.
+    frust.make_perspective_hfov(xfov, aspect, cnear, cfar);
+    proj->set_frustum(frust);
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::set_near_far
+//       Access: Public
+//  Description: Sets the near and far planes of the ProjectionNode,
+//               assuming it represents a perspective frustum.
+////////////////////////////////////////////////////////////////////
+void ProjectionNode::
+set_near_far(float cnear, float cfar) {
+  if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
+    PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
+    float xfov, yfov, aspect, tnear, tfar;
+    Frustumf frust = proj->get_frustum();
+    frust.get_perspective_params(xfov, yfov, aspect, tnear, tfar);
+    frust.make_perspective(xfov, yfov, cnear, cfar);
+    proj->set_frustum(frust);
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::set_near
+//       Access: Public
+//  Description: Sets the near clipping plane of the ProjectionNode,
+//               assuming it represents a perspective frustum.
+////////////////////////////////////////////////////////////////////
+void ProjectionNode::
+set_near(float cnear) {
+  float cfar = get_far();
+  set_near_far(cnear, cfar);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ProjectionNode::set_far
+//       Access: Public
+//  Description: Sets the far clipping plane of the ProjectionNode,
+//               assuming it represents a perspective frustum.
+////////////////////////////////////////////////////////////////////
+void ProjectionNode::
+set_far(float cfar) {
+  float cnear = get_near();
+  set_near_far(cnear, cfar);
+}

+ 21 - 0
panda/src/sgraph/projectionNode.h

@@ -36,6 +36,27 @@ PUBLISHED:
   void set_projection(const Projection &projection);
   void set_projection(const Projection &projection);
   void share_projection(Projection *projection);
   void share_projection(Projection *projection);
   Projection *get_projection();
   Projection *get_projection();
+
+  bool is_in_view(const LPoint3f &pos);
+
+  void get_perspective_params(float &yfov, float &aspect, float &cnear, 
+			      float &cfar) const;
+  void get_perspective_params(float &xfov, float &yfov, float &aspect,
+			      float &cnear, float &cfar) const;
+  float get_hfov(void) const;
+  float get_vfov(void) const;
+  void set_fov(float hfov);
+  void set_fov(float hfov, float vfov);
+  void set_hfov(float hfov);
+  void set_vfov(float vfov);
+  float get_aspect(void) const;
+  void set_aspect(float aspect);
+  void get_near_far(float &cnear, float &cfar) const;
+  void set_near_far(float cnear, float cfar);
+  float get_near(void) const;
+  void set_near(float cnear);
+  float get_far(void) const;
+  void set_far(float cfar);
   
   
 protected:
 protected:
   PT(Projection) _projection;
   PT(Projection) _projection;

+ 2 - 2
panda/src/testbed/deadrec_rec.cxx

@@ -141,7 +141,7 @@ static void* internal_monitor(void*) {
 	      float x;
 	      float x;
 	      buff = get_float64(buff, x);
 	      buff = get_float64(buff, x);
 	      if (doing_sync) {
 	      if (doing_sync) {
-		clock_skew = ClockObject::get_global_clock()->get_time() - x;
+		clock_skew = ClockObject::get_global_clock()->get_frame_time() - x;
 		doing_sync = false;
 		doing_sync = false;
 		cerr << "setting clock skew to: " << clock_skew << endl;
 		cerr << "setting clock skew to: " << clock_skew << endl;
 	      } else
 	      } else
@@ -454,7 +454,7 @@ inline static void predict_linear(void) {
       }
       }
     }
     }
     if (time <= 0.) {
     if (time <= 0.) {
-      float rtime = ClockObject::get_global_clock()->get_time() - A_time;
+      float rtime = ClockObject::get_global_clock()->get_frame_time() - A_time;
       target_pos = (rtime * V) + A;
       target_pos = (rtime * V) + A;
       target_vel = V;
       target_vel = V;
       time = 0.5;
       time = 0.5;

+ 1 - 1
panda/src/testbed/deadrec_send.cxx

@@ -39,7 +39,7 @@ enum TelemetryToken { T_End = 1, T_Pos, T_Vel, T_Num, T_Time, T_Sync };
 
 
 static inline NetDatagram& add_time(NetDatagram& d) {
 static inline NetDatagram& add_time(NetDatagram& d) {
   d.add_uint8(T_Time);
   d.add_uint8(T_Time);
-  d.add_float64(ClockObject::get_global_clock()->get_time());
+  d.add_float64(ClockObject::get_global_clock()->get_frame_time());
   return d;
   return d;
 }
 }
 
 

+ 2 - 2
panda/src/tform/driveInterface.cxx

@@ -40,7 +40,7 @@ KeyHeld() {
 
 
 float DriveInterface::KeyHeld::
 float DriveInterface::KeyHeld::
 get_effect(float ramp_up_time, float ramp_down_time) {
 get_effect(float ramp_up_time, float ramp_down_time) {
-  double elapsed = ClockObject::get_global_clock()->get_time() - _changed_time;
+  double elapsed = ClockObject::get_global_clock()->get_frame_time() - _changed_time;
 
 
   if (_down) {
   if (_down) {
     // We are currently holding down the key.  That means we base our
     // We are currently holding down the key.  That means we base our
@@ -71,7 +71,7 @@ get_effect(float ramp_up_time, float ramp_down_time) {
 void DriveInterface::KeyHeld::
 void DriveInterface::KeyHeld::
 set_key(bool down) {
 set_key(bool down) {
   _down = down;
   _down = down;
-  _changed_time = ClockObject::get_global_clock()->get_time();
+  _changed_time = ClockObject::get_global_clock()->get_frame_time();
   _effect_at_change = _effect;
   _effect_at_change = _effect;
 }
 }