ソースを参照

polar uv scrolling

Zachary Pavlov 16 年 前
コミット
8db00b4f74

+ 12 - 1
panda/src/egg/eggGroup.I

@@ -1062,6 +1062,11 @@ set_scroll_v(const double v_speed) {
   _v_speed = v_speed;
 }
 
+INLINE void EggGroup::
+set_scroll_r(const double r_speed) {
+  _r_speed = r_speed;
+}
+
 INLINE double EggGroup::
 get_scroll_u() const {
   return _u_speed;
@@ -1072,7 +1077,13 @@ get_scroll_v() const {
   return _v_speed;
 }
 
+INLINE double EggGroup::
+get_scroll_r() const {
+  return _r_speed;
+}
+
+
 INLINE bool EggGroup::
 has_scrolling_uvs() {
-  return (_u_speed != 0) || (_v_speed != 0);
+  return (_u_speed != 0) || (_v_speed != 0) || (_r_speed != 0);
 }

+ 3 - 0
panda/src/egg/eggGroup.h

@@ -272,8 +272,10 @@ PUBLISHED:
 
   INLINE void set_scroll_u(const double u_speed);
   INLINE void set_scroll_v(const double v_speed);
+  INLINE void set_scroll_r(const double r_speed);
   INLINE double get_scroll_u() const;
   INLINE double get_scroll_v() const;
+  INLINE double get_scroll_r() const;
 
   INLINE bool has_scrolling_uvs();
 
@@ -378,6 +380,7 @@ private:
 
   double _u_speed;
   double _v_speed;
+  double _r_speed;
 
   // This is the <DefaultPose> entry for a <Joint>.  It is not the
   // <Transform> entry (that is stored via inheritance, in the

+ 3 - 0
panda/src/egg/parser.yxx

@@ -1298,6 +1298,9 @@ group_body:
   } else if (cmp_nocase_uh(name, "scroll_v") == 0) {
     group->set_scroll_v(value);
 
+  } else if (cmp_nocase_uh(name, "scroll_r") == 0) {
+    group->set_scroll_r(value);
+
   } else if (cmp_nocase_uh(name, "blend") == 0) {
     EggGroup::BlendMode blend_mode =
       EggGroup::string_blend_mode(strval);

+ 1 - 1
panda/src/egg2pg/eggLoader.cxx

@@ -1880,7 +1880,7 @@ make_node(EggGroup *egg_group, PandaNode *parent) {
       make_node(*ci, node);
     }
   } else if (egg_group->has_scrolling_uvs()) {
-    node = new UvScrollNode(egg_group->get_name(), egg_group->get_scroll_u(), egg_group->get_scroll_v());
+    node = new UvScrollNode(egg_group->get_name(), egg_group->get_scroll_u(), egg_group->get_scroll_v(), egg_group->get_scroll_r());
     
     EggGroup::const_iterator ci;
     for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) {

+ 39 - 2
panda/src/pgraph/uvScrollNode.I

@@ -19,15 +19,33 @@
 //  Description:
 ////////////////////////////////////////////////////////////////////
 INLINE UvScrollNode::
-UvScrollNode(const string &name, float u_speed, float v_speed) :
+UvScrollNode(const string &name, float u_speed, float v_speed, float r_speed) :
   PandaNode(name),
   _start_time(ClockObject::get_global_clock()->get_frame_time()),
   _u_speed(u_speed),
-  _v_speed(v_speed)
+  _v_speed(v_speed),
+  _r_speed(r_speed)
 {  
   set_cull_callback();
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: UvScrollNode::Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE UvScrollNode::
+UvScrollNode(const string &name) :
+  PandaNode(name),
+  _start_time(ClockObject::get_global_clock()->get_frame_time()),
+  _u_speed(0),
+  _v_speed(0),
+  _r_speed(0)
+{  
+  set_cull_callback();
+}
+
+
 ////////////////////////////////////////////////////////////////////
 //     Function: UvSctrollNode::set_u_speed
 //       Access: Published
@@ -48,6 +66,15 @@ set_v_speed(float v_speed) {
   _v_speed = v_speed;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: UvSctrollNode::set_r_speed
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void UvScrollNode::
+set_r_speed(float r_speed) {
+  _r_speed = r_speed;
+}
 
 ////////////////////////////////////////////////////////////////////
 //     Function: UvSctrollNode::get_u_speed
@@ -69,6 +96,16 @@ get_v_speed() const {
   return _v_speed;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: UvSctrollNode::get_r_speed
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE float UvScrollNode::
+get_r_speed() const {
+  return _r_speed;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: UvScrollNode::Copy Constructor
 //       Access: Protected

+ 10 - 2
panda/src/pgraph/uvScrollNode.cxx

@@ -61,6 +61,7 @@ write_datagram(BamWriter *manager, Datagram &dg) {
   PandaNode::write_datagram(manager, dg);
   dg.add_float32(_u_speed);
   dg.add_float32(_v_speed);
+  dg.add_float32(_r_speed);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -73,7 +74,7 @@ write_datagram(BamWriter *manager, Datagram &dg) {
 ////////////////////////////////////////////////////////////////////
 TypedWritable *UvScrollNode::
 make_from_bam(const FactoryParams &params) {
-  UvScrollNode *node = new UvScrollNode("",0,0);
+  UvScrollNode *node = new UvScrollNode("");
   DatagramIterator scan;
   BamReader *manager;
 
@@ -96,6 +97,10 @@ fillin(DatagramIterator &scan, BamReader *manager) {
 
   _u_speed = scan.get_float32();
   _v_speed = scan.get_float32();
+  if(manager->get_file_minor_ver() >=22) {
+    _r_speed = scan.get_float32();
+  }
+
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -126,7 +131,10 @@ fillin(DatagramIterator &scan, BamReader *manager) {
 bool UvScrollNode::
 cull_callback(CullTraverser * trav, CullTraverserData &data) {
   double elapsed = ClockObject::get_global_clock()->get_frame_time() - _start_time; 
-  CPT(TransformState) ts = TransformState::make_pos2d(LVecBase2f(cmod(elapsed*_u_speed,1.0)/1.0, cmod(elapsed*_v_speed,1.0)/1.0));
+  CPT(TransformState) ts = TransformState::make_pos_hpr(
+    LVecBase3f(cmod(elapsed*_u_speed,1.0)/1.0, cmod(elapsed*_v_speed,1.0)/1.0,0), 
+    LVecBase3f((cmod(elapsed*_r_speed,1.0)/1.0)*360,0,0));
+  
   CPT(RenderAttrib) tm = TexMatrixAttrib::make(TextureStage::get_default(), ts);
   CPT(RenderState) rs = RenderState::make_empty()->set_attrib(tm);
   data._state = data._state->compose(rs);

+ 5 - 1
panda/src/pgraph/uvScrollNode.h

@@ -28,7 +28,8 @@
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDA_PGRAPH UvScrollNode : public PandaNode {
 PUBLISHED:
-  INLINE UvScrollNode(const string &name, float u_speed, float v_speed);
+  INLINE UvScrollNode(const string &name, float u_speed, float v_speed, float r_speed);
+  INLINE UvScrollNode(const string &name);
 
 protected:
   INLINE UvScrollNode(const UvScrollNode &copy);
@@ -42,12 +43,15 @@ public:
 PUBLISHED:
   INLINE void set_u_speed(float u_speed);
   INLINE void set_v_speed(float v_speed);
+  INLINE void set_r_speed(float r_speed);
   INLINE float get_u_speed() const;
   INLINE float get_v_speed() const;
+  INLINE float get_r_speed() const;
   
 private:
   float _u_speed;
   float _v_speed;
+  float _r_speed;
 
   double _start_time;
 

+ 2 - 1
panda/src/putil/bam.h

@@ -33,7 +33,7 @@ static const unsigned short _bam_major_ver = 6;
 // Bumped to major version 6 on 2/11/06 to factor out PandaNode::CData.
 
 static const unsigned short _bam_first_minor_ver = 14;
-static const unsigned short _bam_minor_ver = 21;
+static const unsigned short _bam_minor_ver = 22;
 // Bumped to minor version 14 on 12/19/07 to change default ColorAttrib.
 // Bumped to minor version 15 on 4/9/08 to add TextureAttrib::_implicit_sort.
 // Bumped to minor version 16 on 5/13/08 to add Texture::_quality_level.
@@ -42,6 +42,7 @@ static const unsigned short _bam_minor_ver = 21;
 // Bumped to minor version 19 on 8/14/08 to add PandaNode::_bounds_type.
 // Bumped to minor version 20 on 4/21/09 to add MovingPartBase::_forced_channel.
 // Bumped to minor version 21 on 2/26/08 to add BamEnums::BamObjectCode.
+// Bumped to minor version 22 on 7/31/09 to add UvScrollNode R speed.
 
 
 #endif