Răsfoiți Sursa

Bam 6.41: lenses and light changes, add max_distance

rdb 9 ani în urmă
părinte
comite
2971915618

+ 58 - 2
panda/src/gobj/lens.cxx

@@ -139,7 +139,7 @@ get_min_fov() const {
 
 /**
  * Returns the default near plane distance that will be assigned to each
- * newly-created lens.  This is read from the Configrc file.
+ * newly-created lens.  This is read from the Config.prc file.
  */
 PN_stdfloat Lens::
 get_default_near() {
@@ -148,7 +148,7 @@ get_default_near() {
 
 /**
  * Returns the default far plane distance that will be assigned to each newly-
- * created lens.  This is read from the Configrc file.
+ * created lens.  This is read from the Config.prc file.
  */
 PN_stdfloat Lens::
 get_default_far() {
@@ -1930,6 +1930,35 @@ write_datagram(BamWriter *manager, Datagram &dg) const {
   dg.add_stdfloat(_near_distance);
   dg.add_stdfloat(_far_distance);
   dg.add_uint16(_user_flags);
+
+  if (manager->get_file_minor_ver() < 41) {
+    return;
+  }
+
+  dg.add_stdfloat(_min_fov);
+  dg.add_stdfloat(_interocular_distance);
+  dg.add_stdfloat(_convergence_distance);
+
+  if (_user_flags & UF_view_hpr) {
+    _view_hpr.write_datagram(dg);
+  }
+
+  if (_user_flags & UF_view_vector) {
+    _view_vector.write_datagram(dg);
+    _up_vector.write_datagram(dg);
+  }
+
+  if (_user_flags & UF_view_mat) {
+    _lens_mat.write_datagram(dg);
+  }
+
+  if (_user_flags & UF_keystone) {
+    _keystone.write_datagram(dg);
+  }
+
+  if (_user_flags & UF_custom_film_mat) {
+    _custom_film_mat.write_datagram(dg);
+  }
 }
 
 /**
@@ -1949,6 +1978,33 @@ fillin(DatagramIterator &scan, BamReader *manager) {
   _far_distance = scan.get_stdfloat();
   _user_flags = scan.get_uint16();
 
+  if (manager->get_file_minor_ver() >= 41) {
+    _min_fov = scan.get_stdfloat();
+    _interocular_distance = scan.get_stdfloat();
+    _convergence_distance = scan.get_stdfloat();
+
+    if (_user_flags & UF_view_hpr) {
+      _view_hpr.read_datagram(scan);
+    }
+
+    if (_user_flags & UF_view_vector) {
+      _view_vector.read_datagram(scan);
+      _up_vector.read_datagram(scan);
+    }
+
+    if (_user_flags & UF_view_mat) {
+      _lens_mat.read_datagram(scan);
+    }
+
+    if (_user_flags & UF_keystone) {
+      _keystone.read_datagram(scan);
+    }
+
+    if (_user_flags & UF_custom_film_mat) {
+      _custom_film_mat.read_datagram(scan);
+    }
+  }
+
   _comp_flags = 0;
 }
 

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

@@ -77,6 +77,23 @@ register_with_read_factory() {
   BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
 }
 
+/**
+ * Writes the contents of this object to the datagram for shipping out to a
+ * Bam file.
+ */
+void MatrixLens::
+write_datagram(BamWriter *manager, Datagram &dg) {
+  dg.add_uint8(_ml_flags);
+  _user_mat.write_datagram(dg);
+
+  if (_ml_flags & MF_has_left_eye) {
+    _left_eye_mat.write_datagram(dg);
+  }
+  if (_ml_flags & MF_has_right_eye) {
+    _left_eye_mat.write_datagram(dg);
+  }
+}
+
 /**
  * This function is called by the BamReader's factory when a new object of
  * type Lens is encountered in the Bam file.  It should create the Lens and
@@ -93,3 +110,24 @@ make_from_bam(const FactoryParams &params) {
 
   return lens;
 }
+
+/**
+ * This internal function is called by make_from_bam to read in all of the
+ * relevant data from the BamFile for the new MatrixLens.
+ */
+void MatrixLens::
+fillin(DatagramIterator &scan, BamReader *manager) {
+  Lens::fillin(scan, manager);
+
+  if (manager->get_file_minor_ver() >= 41) {
+    _ml_flags = scan.get_uint8();
+
+    _user_mat.read_datagram(scan);
+    if (_ml_flags & MF_has_left_eye) {
+      _left_eye_mat.read_datagram(scan);
+    }
+    if (_ml_flags & MF_has_right_eye) {
+      _right_eye_mat.read_datagram(scan);
+    }
+  }
+}

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

@@ -70,9 +70,11 @@ private:
 
 public:
   static void register_with_read_factory();
+  virtual void write_datagram(BamWriter *manager, Datagram &dg);
 
 protected:
   static TypedWritable *make_from_bam(const FactoryParams &params);
+  void fillin(DatagramIterator &scan, BamReader *manager);
 
 public:
   virtual TypeHandle get_type() const {

+ 24 - 2
panda/src/pgraph/camera.cxx

@@ -26,9 +26,9 @@ Camera(const string &name, Lens *lens) :
   LensNode(name, lens),
   _active(true),
   _camera_mask(~PandaNode::get_overall_bit()),
-  _initial_state(RenderState::make_empty())
+  _initial_state(RenderState::make_empty()),
+  _lod_scale(1)
 {
-  set_lod_scale(1.0);
 }
 
 /**
@@ -271,6 +271,23 @@ write_datagram(BamWriter *manager, Datagram &dg) {
 
   dg.add_bool(_active);
   dg.add_uint32(_camera_mask.get_word());
+
+  manager->write_pointer(dg, _initial_state);
+  dg.add_stdfloat(_lod_scale);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: Camera::complete_pointers
+//       Access: Public, Virtual
+//  Description: Receives an array of pointers, one for each time
+//               manager->read_pointer() was called in fillin().
+//               Returns the number of pointers processed.
+////////////////////////////////////////////////////////////////////
+int Camera::
+complete_pointers(TypedWritable **p_list, BamReader *manager) {
+  int pi = LensNode::complete_pointers(p_list, manager);
+  _initial_state = DCAST(RenderState, p_list[pi++]);
+  return pi;
 }
 
 /**
@@ -300,4 +317,9 @@ fillin(DatagramIterator &scan, BamReader *manager) {
 
   _active = scan.get_bool();
   _camera_mask.set_word(scan.get_uint32());
+
+  if (manager->get_file_minor_ver() >= 41) {
+    manager->read_pointer(scan);
+    _lod_scale = scan.get_stdfloat();
+  }
 }

+ 2 - 0
panda/src/pgraph/camera.h

@@ -124,6 +124,8 @@ private:
 public:
   static void register_with_read_factory();
   virtual void write_datagram(BamWriter *manager, Datagram &dg);
+  virtual int complete_pointers(TypedWritable **plist,
+                                BamReader *manager);
 
 protected:
   static TypedWritable *make_from_bam(const FactoryParams &params);

+ 35 - 5
panda/src/pgraph/lensNode.cxx

@@ -218,9 +218,18 @@ void LensNode::
 write_datagram(BamWriter *manager, Datagram &dg) {
   PandaNode::write_datagram(manager, dg);
 
-  // For now, we only write out lens 0, simply because that's what we always
-  // have done.  Should probably write out all lenses for the future.
-  manager->write_pointer(dg, get_lens(0));
+  if (manager->get_file_minor_ver() < 41) {
+    // Prior to bam 6.41, we stored only one lens.
+    manager->write_pointer(dg, get_lens(0));
+  } else {
+    dg.add_uint16(_lenses.size());
+
+    Lenses::const_iterator li;
+    for (li = _lenses.begin(); li != _lenses.end(); ++li) {
+      manager->write_pointer(dg, (*li)._lens);
+      dg.add_bool((*li)._is_active);
+    }
+  }
 }
 
 /**
@@ -230,7 +239,16 @@ write_datagram(BamWriter *manager, Datagram &dg) {
 int LensNode::
 complete_pointers(TypedWritable **p_list, BamReader *manager) {
   int pi = PandaNode::complete_pointers(p_list, manager);
-  set_lens(0, DCAST(Lens, p_list[pi++]));
+
+  Lenses::iterator li;
+  for (li = _lenses.begin(); li != _lenses.end(); ++li) {
+    (*li)._lens = DCAST(Lens, p_list[pi++]);
+  }
+
+  if (_shown_frustum != (PandaNode *)NULL) {
+    show_frustum();
+  }
+
   return pi;
 }
 
@@ -259,5 +277,17 @@ void LensNode::
 fillin(DatagramIterator &scan, BamReader *manager) {
   PandaNode::fillin(scan, manager);
 
-  manager->read_pointer(scan);
+  if (manager->get_file_minor_ver() < 41) {
+    // Prior to bam 6.41, we stored only one lens.
+    _lenses.resize(1);
+    manager->read_pointer(scan);
+
+  } else {
+    _lenses.resize(scan.get_uint16());
+    Lenses::iterator li;
+    for (li = _lenses.begin(); li != _lenses.end(); ++li) {
+      manager->read_pointer(scan);
+      (*li)._is_active = scan.get_bool();
+    }
+  }
 }

+ 2 - 0
panda/src/pgraph/pandaNode.cxx

@@ -3750,6 +3750,8 @@ void PandaNode::
 fillin(DatagramIterator &scan, BamReader *manager) {
   TypedWritable::fillin(scan, manager);
 
+  remove_all_children();
+
   string name = scan.get_string();
   set_name(name);
 

+ 24 - 2
panda/src/pgraphnodes/pointLight.I

@@ -18,6 +18,7 @@ INLINE PointLight::CData::
 CData() :
   _specular_color(1.0f, 1.0f, 1.0f, 1.0f),
   _attenuation(1.0f, 0.0f, 0.0f),
+  _max_distance(make_inf((PN_stdfloat)0)),
   _point(0.0f, 0.0f, 0.0f)
 {
 }
@@ -29,6 +30,7 @@ INLINE PointLight::CData::
 CData(const PointLight::CData &copy) :
   _specular_color(copy._specular_color),
   _attenuation(copy._attenuation),
+  _max_distance(copy._max_distance),
   _point(copy._point)
 {
 }
@@ -88,9 +90,29 @@ set_attenuation(const LVecBase3 &attenuation) {
   cdata->_attenuation = attenuation;
 }
 
+/**
+ * Returns the maximum distance at which the light has any effect, as previously
+ * specified by set_max_distance.
+ */
+INLINE PN_stdfloat PointLight::
+get_max_distance() const {
+  CDReader cdata(_cycler);
+  return cdata->_max_distance;
+}
+
+/**
+ * Sets the radius of the light's sphere of influence.  Beyond this distance, the
+ * light may be attenuated to zero, if this is supported by the shader.
+ */
+INLINE void PointLight::
+set_max_distance(PN_stdfloat max_distance) {
+  CDWriter cdata(_cycler);
+  cdata->_max_distance = max_distance;
+}
+
 /**
  * Returns the point in space at which the light is located.  This is local to
- * the coordinate space in which the light is assigned.
+ * the coordinate space in which the light is assigned, and is usually 0.
  */
 INLINE const LPoint3 &PointLight::
 get_point() const {
@@ -99,7 +121,7 @@ get_point() const {
 }
 
 /**
- * Sets the point in space at which the light is located.
+ * Sets the point in space at which the light is located.  Usually 0.
  */
 INLINE void PointLight::
 set_point(const LPoint3 &point) {

+ 13 - 2
panda/src/pgraphnodes/pointLight.cxx

@@ -33,9 +33,12 @@ make_copy() const {
  * Bam file.
  */
 void PointLight::CData::
-write_datagram(BamWriter *, Datagram &dg) const {
+write_datagram(BamWriter *manager, Datagram &dg) const {
   _specular_color.write_datagram(dg);
   _attenuation.write_datagram(dg);
+  if (manager->get_file_minor_ver() >= 41) {
+    dg.add_stdfloat(_max_distance);
+  }
   _point.write_datagram(dg);
 }
 
@@ -44,9 +47,12 @@ write_datagram(BamWriter *, Datagram &dg) const {
  * relevant data from the BamFile for the new Light.
  */
 void PointLight::CData::
-fillin(DatagramIterator &scan, BamReader *) {
+fillin(DatagramIterator &scan, BamReader *manager) {
   _specular_color.read_datagram(scan);
   _attenuation.read_datagram(scan);
+  if (manager->get_file_minor_ver() >= 41) {
+    _max_distance = scan.get_stdfloat();
+  }
   _point.read_datagram(scan);
 }
 
@@ -127,6 +133,11 @@ write(ostream &out, int indent_level) const {
   }
   indent(out, indent_level + 2)
     << "attenuation " << get_attenuation() << "\n";
+
+  if (!cinf(get_max_distance())) {
+    indent(out, indent_level + 2)
+      << "max distance " << get_max_distance() << "\n";
+  }
 }
 
 /**

+ 5 - 0
panda/src/pgraphnodes/pointLight.h

@@ -48,6 +48,10 @@ PUBLISHED:
   INLINE void set_attenuation(const LVecBase3 &attenuation);
   MAKE_PROPERTY(attenuation, get_attenuation, set_attenuation);
 
+  INLINE PN_stdfloat get_max_distance() const;
+  INLINE void set_max_distance(PN_stdfloat max_distance);
+  MAKE_PROPERTY(max_distance, get_max_distance, set_max_distance);
+
   INLINE const LPoint3 &get_point() const;
   INLINE void set_point(const LPoint3 &point);
   MAKE_PROPERTY(point, get_point, set_point);
@@ -75,6 +79,7 @@ private:
 
     LColor _specular_color;
     LVecBase3 _attenuation;
+    PN_stdfloat _max_distance;
     LPoint3 _point;
   };
 

+ 24 - 2
panda/src/pgraphnodes/spotlight.I

@@ -18,7 +18,8 @@ INLINE Spotlight::CData::
 CData() :
   _exponent(50.0f),
   _specular_color(1.0f, 1.0f, 1.0f, 1.0f),
-  _attenuation(1.0f, 0.0f, 0.0f)
+  _attenuation(1.0f, 0.0f, 0.0f),
+  _max_distance(make_inf((PN_stdfloat)0))
 {
 }
 
@@ -29,7 +30,8 @@ INLINE Spotlight::CData::
 CData(const Spotlight::CData &copy) :
   _exponent(copy._exponent),
   _specular_color(copy._specular_color),
-  _attenuation(copy._attenuation)
+  _attenuation(copy._attenuation),
+  _max_distance(copy._max_distance)
 {
 }
 
@@ -111,3 +113,23 @@ set_attenuation(const LVecBase3 &attenuation) {
   CDWriter cdata(_cycler);
   cdata->_attenuation = attenuation;
 }
+
+/**
+ * Returns the maximum distance at which the light has any effect, as previously
+ * specified by set_max_distance.
+ */
+INLINE PN_stdfloat Spotlight::
+get_max_distance() const {
+  CDReader cdata(_cycler);
+  return cdata->_max_distance;
+}
+
+/**
+ * Sets the radius of the light's sphere of influence.  Beyond this distance, the
+ * light may be attenuated to zero, if this is supported by the shader.
+ */
+INLINE void Spotlight::
+set_max_distance(PN_stdfloat max_distance) {
+  CDWriter cdata(_cycler);
+  cdata->_max_distance = max_distance;
+}

+ 13 - 2
panda/src/pgraphnodes/spotlight.cxx

@@ -37,10 +37,13 @@ make_copy() const {
  * Bam file.
  */
 void Spotlight::CData::
-write_datagram(BamWriter *, Datagram &dg) const {
+write_datagram(BamWriter *manager, Datagram &dg) const {
   dg.add_stdfloat(_exponent);
   _specular_color.write_datagram(dg);
   _attenuation.write_datagram(dg);
+  if (manager->get_file_minor_ver() >= 41) {
+    dg.add_stdfloat(_max_distance);
+  }
 }
 
 /**
@@ -48,10 +51,13 @@ write_datagram(BamWriter *, Datagram &dg) const {
  * relevant data from the BamFile for the new Light.
  */
 void Spotlight::CData::
-fillin(DatagramIterator &scan, BamReader *) {
+fillin(DatagramIterator &scan, BamReader *manager) {
   _exponent = scan.get_stdfloat();
   _specular_color.read_datagram(scan);
   _attenuation.read_datagram(scan);
+  if (manager->get_file_minor_ver() >= 41) {
+    _max_distance = scan.get_stdfloat();
+  }
 }
 
 /**
@@ -113,6 +119,11 @@ write(ostream &out, int indent_level) const {
   indent(out, indent_level + 2)
     << "exponent " << get_exponent() << "\n";
 
+  if (!cinf(get_max_distance())) {
+    indent(out, indent_level + 2)
+      << "max distance " << get_max_distance() << "\n";
+  }
+
   Lens *lens = get_lens();
   if (lens != (Lens *)NULL) {
     lens->write(out, indent_level + 2);

+ 5 - 0
panda/src/pgraphnodes/spotlight.h

@@ -59,6 +59,10 @@ PUBLISHED:
   INLINE void set_attenuation(const LVecBase3 &attenuation);
   MAKE_PROPERTY(attenuation, get_attenuation, set_attenuation);
 
+  INLINE PN_stdfloat get_max_distance() const;
+  INLINE void set_max_distance(PN_stdfloat max_distance);
+  MAKE_PROPERTY(max_distance, get_max_distance, set_max_distance);
+
   virtual int get_class_priority() const;
 
   static PT(Texture) make_spot(int pixel_width, PN_stdfloat full_radius,
@@ -92,6 +96,7 @@ private:
     PN_stdfloat _exponent;
     LColor _specular_color;
     LVecBase3 _attenuation;
+    PN_stdfloat _max_distance;
   };
 
   PipelineCycler<CData> _cycler;

+ 34 - 35
panda/src/putil/bam.h

@@ -25,42 +25,41 @@
 static const string _bam_header = string("pbj\0\n\r", 6);
 
 static const unsigned short _bam_major_ver = 6;
-// Bumped to major version 2 on 7600 due to major changes in Character.
-// Bumped to major version 3 on 12800 to change float64's to float32's.
-// Bumped to major version 4 on 41002 to store new scene graph.  Bumped to
-// major version 5 on 5605 for new Geom implementation.  Bumped to major
-// version 6 on 21106 to factor out PandaNode::CData.
+// Bumped to major version 2 on 2000-07-06 due to major changes in Character.
+// Bumped to major version 3 on 2000-12-08 to change float64's to float32's.
+// Bumped to major version 4 on 2002-04-10 to store new scene graph.
+// Bumped to major version 5 on 2005-05-06 for new Geom implementation.
+// Bumped to major version 6 on 2006-02-11 to factor out PandaNode::CData.
 
 static const unsigned short _bam_first_minor_ver = 14;
-static const unsigned short _bam_minor_ver = 40;
-/*
- * Bumped to minor version 14 on 121907 to change default ColorAttrib.  Bumped
- * to minor version 15 on 4908 to add TextureAttrib::_implicit_sort.  Bumped
- * to minor version 16 on 51308 to add Texture::_quality_level.  Bumped to
- * minor version 17 on 8608 to add PartBundle::_anim_preload.  Bumped to minor
- * version 18 on 81408 to add Texture::_simple_ram_image.  Bumped to minor
- * version 19 on 81408 to add PandaNode::_bounds_type.  Bumped to minor
- * version 20 on 42109 to add MovingPartBase::_forced_channel.  Bumped to
- * minor version 21 on 22608 to add BamEnums::BamObjectCode.  Bumped to minor
- * version 22 on 73109 to add UvScrollNode R speed.  Bumped to minor version
- * 23 on 5410 to add internal TextureAttrib overrides.  Bumped to minor
- * version 24 on 5410 to add internal TexMatrixAttrib overrides.  Bumped to
- * minor version 25 on 62211 to add support for caching movie files.  Bumped
- * to minor version 26 on 8511 to add multiview (stereo) Textures.  Bumped to
- * minor version 27 on 10911 to add stdfloat_double.  Bumped to minor version
- * 28 on 112811 to add Texture::_auto_texture_scale.  Bumped to minor version
- * 29 on 121711 to add GeomVertexColumn::_column_alignment.  Bumped to minor
- * version 30 on 12212 to add Texture::_pad_*_size.  Bumped to minor version
- * 31 on 21612 to add DepthOffsetAttrib::_min_value, _max_value.  Bumped to
- * minor version 32 on 61112 to add Texture::_has_read_mipmaps.  Bumped to
- * minor version 33 on 81713 to add UvScrollNode::_w_speed.  Bumped to minor
- * version 34 on 91614 to add ScissorAttrib::_off.  Bumped to minor version 35
- * on 12314 to change StencilAttrib.  Bumped to minor version 36 on 12914 to
- * add samplers and lod settings.  Bumped to minor version 37 on 12215 to add
- * GeomVertexArrayFormat::_divisor.  Bumped to minor version 38 on 41515 to
- * add various Bullet classes.  Bumped to minor version 39 on 1916 to change
- * lights and materials.  Bumped to minor version 40 on 11116 to make
- * NodePaths writable.
- */
+static const unsigned short _bam_minor_ver = 41;
+// Bumped to minor version 14 on 2007-12-19 to change default ColorAttrib.
+// Bumped to minor version 15 on 2008-04-09 to add TextureAttrib::_implicit_sort.
+// Bumped to minor version 16 on 2008-05-13 to add Texture::_quality_level.
+// Bumped to minor version 17 on 2008-08-06 to add PartBundle::_anim_preload.
+// Bumped to minor version 18 on 2008-08-14 to add Texture::_simple_ram_image.
+// Bumped to minor version 19 on 2008-08-14 to add PandaNode::_bounds_type.
+// Bumped to minor version 20 on 2009-04-21 to add MovingPartBase::_forced_channel.
+// Bumped to minor version 21 on 2008-02-26 to add BamEnums::BamObjectCode.
+// Bumped to minor version 22 on 2009-07-31 to add UvScrollNode R speed.
+// Bumped to minor version 23 on 2010-05-04 to add internal TextureAttrib overrides.
+// Bumped to minor version 24 on 2010-05-04 to add internal TexMatrixAttrib overrides.
+// Bumped to minor version 25 on 2011-06-22 to add support for caching movie files.
+// Bumped to minor version 26 on 2011-08-05 to add multiview (stereo) Textures.
+// Bumped to minor version 27 on 2011-10-09 to add stdfloat_double.
+// Bumped to minor version 28 on 2011-11-28 to add Texture::_auto_texture_scale.
+// Bumped to minor version 29 on 2011-12-17 to add GeomVertexColumn::_column_alignment.
+// Bumped to minor version 30 on 2012-01-22 to add Texture::_pad_*_size.
+// Bumped to minor version 31 on 2012-02-16 to add DepthOffsetAttrib::_min_value, _max_value.
+// Bumped to minor version 32 on 2012-06-11 to add Texture::_has_read_mipmaps.
+// Bumped to minor version 33 on 2013-08-17 to add UvScrollNode::_w_speed.
+// Bumped to minor version 34 on 2014-09-16 to add ScissorAttrib::_off.
+// Bumped to minor version 35 on 2014-12-03 to change StencilAttrib.
+// Bumped to minor version 36 on 2014-12-09 to add samplers and lod settings.
+// Bumped to minor version 37 on 2015-01-22 to add GeomVertexArrayFormat::_divisor.
+// Bumped to minor version 38 on 2015-04-15 to add various Bullet classes.
+// Bumped to minor version 39 on 2016-01-09 to change lights and materials.
+// Bumped to minor version 40 on 2016-01-11 to make NodePaths writable.
+// Bumped to minor version 41 on 2016-03-02 to change LensNode, Lens, and Camera.
 
 #endif

+ 2 - 1
panda/src/putil/bamReader.cxx

@@ -236,7 +236,8 @@ read_object() {
  * This flavor of read_object() returns both a TypedWritable and a
  * ReferenceCount pointer to the same object, so the reference count may be
  * tracked reliably, without having to know precisely what type of object we
- * have.  It returns true on success, or false on failure.
+ * have.
+ * @return true on success, or false on failure.
  */
 bool BamReader::
 read_object(TypedWritable *&ptr, ReferenceCount *&ref_ptr) {

+ 16 - 0
panda/src/putil/bamWriter.I

@@ -34,6 +34,22 @@ get_filename() const {
   return empty_filename;
 }
 
+/**
+ * Returns the major version number of the Bam file currently being written.
+ */
+INLINE int BamWriter::
+get_file_major_ver() const {
+  return _file_major;
+}
+
+/**
+ * Returns the minor version number of the Bam file currently being written.
+ */
+INLINE int BamWriter::
+get_file_minor_ver() const {
+  return _file_minor;
+}
+
 /**
  * Returns the endian preference indicated by the Bam file currently being
  * written.  This does not imply that every number is stored using the

+ 4 - 0
panda/src/putil/bamWriter.cxx

@@ -41,6 +41,8 @@ BamWriter(DatagramSink *target) :
   _next_pta_id = 1;
   _long_pta_id = false;
 
+  _file_major = _bam_major_ver;
+  _file_minor = _bam_minor_ver;
   _file_endian = bam_endian;
   _file_stdfloat_double = bam_stdfloat_double;
   _file_texture_mode = bam_texture_mode;
@@ -96,6 +98,8 @@ init() {
   _next_pta_id = 1;
   _long_pta_id = false;
 
+  _file_major = _bam_major_ver;
+  _file_minor = _bam_minor_ver;
   _file_endian = bam_endian;
   _file_texture_mode = bam_texture_mode;
 

+ 4 - 0
panda/src/putil/bamWriter.h

@@ -74,6 +74,9 @@ PUBLISHED:
   bool has_object(const TypedWritable *obj) const;
   void flush();
 
+  INLINE int get_file_major_ver() const;
+  INLINE int get_file_minor_ver() const;
+
   INLINE BamEndian get_file_endian() const;
   INLINE bool get_file_stdfloat_double() const;
 
@@ -115,6 +118,7 @@ private:
   int enqueue_object(const TypedWritable *object);
   bool flush_queue();
 
+  int _file_major, _file_minor;
   BamEndian _file_endian;
   bool _file_stdfloat_double;
   BamTextureMode _file_texture_mode;