Browse Source

*** empty log message ***

Zachary Pavlov 16 years ago
parent
commit
dd84f35bbe
3 changed files with 230 additions and 0 deletions
  1. 94 0
      panda/src/pgraph/uvScrollNode.cxx
  2. 75 0
      panda/src/pgraph/uvScrollNode.h
  3. 61 0
      panda/src/pgraph/uvScrollNode.i

+ 94 - 0
panda/src/pgraph/uvScrollNode.cxx

@@ -0,0 +1,94 @@
+// Filename: modelNode.cxx
+// Created by:  drose (16Mar02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#include "uvScrollNode.h"
+
+#include "bamReader.h"
+#include "datagram.h"
+#include "datagramIterator.h"
+
+TypeHandle UvScrollNode::_type_handle;
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: UvScrollNode::make_copy
+//       Access: Public, Virtual
+//  Description: Returns a newly-allocated Node that is a shallow copy
+//               of this one.  It will be a different Node pointer,
+//               but its internal data may or may not be shared with
+//               that of the original Node.
+////////////////////////////////////////////////////////////////////
+PandaNode *UvScrollNode::
+make_copy() const {
+  return new UvScrollNode(*this);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ModelNode::register_with_read_factory
+//       Access: Public, Static
+//  Description: Tells the BamReader how to create objects of type
+//               ModelNode.
+////////////////////////////////////////////////////////////////////
+void UvScrollNode::
+register_with_read_factory() {
+  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ModelNode::write_datagram
+//       Access: Public, Virtual
+//  Description: Writes the contents of this object to the datagram
+//               for shipping out to a Bam file.
+////////////////////////////////////////////////////////////////////
+void UvScrollNode::
+write_datagram(BamWriter *manager, Datagram &dg) {
+  ModelNode::write_datagram(manager, dg);
+  dg.add_float(_u_speed);
+  dg.add_float(_v_speed);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ModelNode::make_from_bam
+//       Access: Protected, Static
+//  Description: This function is called by the BamReader's factory
+//               when a new object of type ModelNode is encountered
+//               in the Bam file.  It should create the ModelNode
+//               and extract its information from the file.
+////////////////////////////////////////////////////////////////////
+TypedWritable *UvScrollNode::
+make_from_bam(const FactoryParams &params) {
+  UvScrollNode *node = new ModelNode("");
+  DatagramIterator scan;
+  BamReader *manager;
+
+  parse_params(params, scan, manager);
+  node->fillin(scan, manager);
+
+  return node;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ModelNode::fillin
+//       Access: Protected
+//  Description: This internal function is called by make_from_bam to
+//               read in all of the relevant data from the BamFile for
+//               the new ModelNode.
+////////////////////////////////////////////////////////////////////
+void UvScrollNode::
+fillin(DatagramIterator &scan, BamReader *manager) {
+  PandaNode::fillin(scan, manager);
+
+  _u_speed = scan.get_float();
+  _v_speed = scan.get_float();
+}

+ 75 - 0
panda/src/pgraph/uvScrollNode.h

@@ -0,0 +1,75 @@
+// Filename: modelNode.h
+// Created by:  drose (16Mar02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef UVSCROLLNODE_H
+#define UVSCROLLNODE_H
+
+#include "pandabase.h"
+
+#include "modelNode.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : UvScrollNode
+// Description : This node is placed at key points within the scene
+//               graph to animate uvs. 
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDA_PGRAPH UvScrollNode : public ModelNode {
+PUBLISHED:
+  INLINE UvScrollNode(const string &name, float u_speed, float v_speed);
+
+protected:
+  INLINE UvScrollNode(const ModelNode &copy);
+
+public:
+  virtual PandaNode *make_copy() const;
+
+PUBLISHED:
+  INLINE void set_scroll_u(float u_speed);
+  INLINE void set_scroll_v(float v_speed);
+
+private:
+  float _u_speed;
+  float _v_speed;
+
+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:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    PandaNode::init_type();
+    register_type(_type_handle, "UvScrollNode",
+                  PandaNode::get_class_type());
+  }
+  virtual TypeHandle get_type() const {
+    return get_class_type();
+  }
+  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
+
+private:
+  static TypeHandle _type_handle;
+};
+
+#include "uvScrollNode.I"
+
+#endif
+
+

+ 61 - 0
panda/src/pgraph/uvScrollNode.i

@@ -0,0 +1,61 @@
+// Filename: modelNode.I
+// Created by:  drose (16Mar02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: ModelNode::Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE UvScrollNode::
+UvScrollNode(const string &name, float u_speed, float v_speed) :
+  ModelNode(name)
+{
+  _u_speed = u_speed;
+  _v_speed = v_speed;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: set_u_speed
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE UvScrollNode::
+set_u_speed(float u_speed) {
+  _u_speed = u_speed;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: set_v_speed
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE UvScrollNode::
+set_v_speed(float v_speed) {
+  _v_speed = v_speed;
+}
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: ModelNode::Copy Constructor
+//       Access: Protected
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE UvScrollNode::
+UvScrollNode(const UvScrollNode &copy) :
+  ModelNode(copy),
+  _u_speed(copy._u_speed),
+  _v_speed(copy._v_speed)
+{
+}