From dd84f35bbed16e8c12bb2ed7b5bfc072d7689a06 Mon Sep 17 00:00:00 2001 From: Zachary Pavlov Date: Thu, 2 Jul 2009 00:42:31 +0000 Subject: [PATCH] *** empty log message *** --- panda/src/pgraph/uvScrollNode.cxx | 94 +++++++++++++++++++++++++++++++ panda/src/pgraph/uvScrollNode.h | 75 ++++++++++++++++++++++++ panda/src/pgraph/uvScrollNode.i | 61 ++++++++++++++++++++ 3 files changed, 230 insertions(+) create mode 100755 panda/src/pgraph/uvScrollNode.cxx create mode 100755 panda/src/pgraph/uvScrollNode.h create mode 100755 panda/src/pgraph/uvScrollNode.i diff --git a/panda/src/pgraph/uvScrollNode.cxx b/panda/src/pgraph/uvScrollNode.cxx new file mode 100755 index 0000000000..87d73f0ed9 --- /dev/null +++ b/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 ¶ms) { + 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(); +} diff --git a/panda/src/pgraph/uvScrollNode.h b/panda/src/pgraph/uvScrollNode.h new file mode 100755 index 0000000000..ad12c65dfe --- /dev/null +++ b/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 ©); + +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 ¶ms); + 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 + + diff --git a/panda/src/pgraph/uvScrollNode.i b/panda/src/pgraph/uvScrollNode.i new file mode 100755 index 0000000000..894f360451 --- /dev/null +++ b/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 ©) : + ModelNode(copy), + _u_speed(copy._u_speed), + _v_speed(copy._v_speed) +{ +}