mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
the real uv scroll node. Not sure what happened with the commit
This commit is contained in:
parent
f53400cd04
commit
8950ddbf15
@ -1,5 +1,5 @@
|
||||
// Filename: modelNode.I
|
||||
// Created by: drose (16Mar02)
|
||||
// Filename: uvScrollNode.I
|
||||
// Created by: zpavlov (30june09)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -14,20 +14,22 @@
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ModelNode::Constructor
|
||||
// Function: UvScrollNode::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE UvScrollNode::
|
||||
UvScrollNode(const string &name, float u_speed, float v_speed) :
|
||||
ModelNode(name)
|
||||
PandaNode(name),
|
||||
_u_speed(u_speed),
|
||||
_v_speed(v_speed)
|
||||
{
|
||||
_u_speed = u_speed;
|
||||
_v_speed = v_speed;
|
||||
set_cull_callback();
|
||||
_start_time = ClockObject::get_global_clock()->get_frame_time();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: set_u_speed
|
||||
// Function: UvSctrollNode::set_u_speed
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -37,7 +39,7 @@ set_u_speed(float u_speed) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: set_v_speed
|
||||
// Function: UvSctrollNode::set_v_speed
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -48,13 +50,33 @@ set_v_speed(float v_speed) {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ModelNode::Copy Constructor
|
||||
// Function: UvSctrollNode::get_u_speed
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE float UvScrollNode::
|
||||
get_u_speed() const {
|
||||
return _u_speed;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: UvSctrollNode::get_v_speed
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE float UvScrollNode::
|
||||
get_v_speed() const {
|
||||
return _v_speed;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: UvScrollNode::Copy Constructor
|
||||
// Access: Protected
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE UvScrollNode::
|
||||
UvScrollNode(const UvScrollNode ©) :
|
||||
ModelNode(copy),
|
||||
PandaNode(copy),
|
||||
_u_speed(copy._u_speed),
|
||||
_v_speed(copy._v_speed)
|
||||
{
|
||||
|
@ -17,6 +17,11 @@
|
||||
#include "bamReader.h"
|
||||
#include "datagram.h"
|
||||
#include "datagramIterator.h"
|
||||
#include "luse.h"
|
||||
#include "renderState.h"
|
||||
#include "texMatrixAttrib.h"
|
||||
#include "textureStage.h"
|
||||
#include "transformState.h"
|
||||
|
||||
TypeHandle UvScrollNode::_type_handle;
|
||||
|
||||
@ -35,10 +40,10 @@ make_copy() const {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ModelNode::register_with_read_factory
|
||||
// Function: UvSctrollNode::register_with_read_factory
|
||||
// Access: Public, Static
|
||||
// Description: Tells the BamReader how to create objects of type
|
||||
// ModelNode.
|
||||
// UvScrollNode.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void UvScrollNode::
|
||||
register_with_read_factory() {
|
||||
@ -46,16 +51,16 @@ register_with_read_factory() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ModelNode::write_datagram
|
||||
// Function: UvSctrollNode::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_float64(_u_speed);
|
||||
dg.add_float64(_v_speed);
|
||||
PandaNode::write_datagram(manager, dg);
|
||||
dg.add_float32(_u_speed);
|
||||
dg.add_float32(_v_speed);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -68,7 +73,7 @@ write_datagram(BamWriter *manager, Datagram &dg) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
TypedWritable *UvScrollNode::
|
||||
make_from_bam(const FactoryParams ¶ms) {
|
||||
UvScrollNode *node = new UvScrollNode("", 0.0, 0.0);
|
||||
UvScrollNode *node = new UvScrollNode("",0,0);
|
||||
DatagramIterator scan;
|
||||
BamReader *manager;
|
||||
|
||||
@ -89,6 +94,57 @@ void UvScrollNode::
|
||||
fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
PandaNode::fillin(scan, manager);
|
||||
|
||||
_u_speed = scan.get_float64();
|
||||
_v_speed = scan.get_float64();
|
||||
_u_speed = scan.get_float32();
|
||||
_v_speed = scan.get_float32();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SequenceNode::cull_callback
|
||||
// Access: Public, Virtual
|
||||
// Description: This function will be called during the cull
|
||||
// traversal to perform any additional operations that
|
||||
// should be performed at cull time. This may include
|
||||
// additional manipulation of render state or additional
|
||||
// visible/invisible decisions, or any other arbitrary
|
||||
// operation.
|
||||
//
|
||||
// Note that this function will *not* be called unless
|
||||
// set_cull_callback() is called in the constructor of
|
||||
// the derived class. It is necessary to call
|
||||
// set_cull_callback() to indicated that we require
|
||||
// cull_callback() to be called.
|
||||
//
|
||||
// By the time this function is called, the node has
|
||||
// already passed the bounding-volume test for the
|
||||
// viewing frustum, and the node's transform and state
|
||||
// have already been applied to the indicated
|
||||
// CullTraverserData object.
|
||||
//
|
||||
// The return value is \true if this node should be
|
||||
// visible, or false if it should be culled.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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(RenderAttrib) tm = TexMatrixAttrib::make(TextureStage::get_default(), ts);
|
||||
CPT(RenderState) rs = RenderState::make_empty()->set_attrib(tm);
|
||||
data._state = data._state->compose(rs);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: UvScrollNode::safe_to_flatten
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns true if it is generally safe to flatten out
|
||||
// this particular kind of PandaNode by duplicating
|
||||
// instances (by calling dupe_for_flatten()), false
|
||||
// otherwise (for instance, a Camera cannot be safely
|
||||
// flattened, because the Camera pointer itself is
|
||||
// meaningful).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool UvScrollNode::
|
||||
safe_to_flatten() const {
|
||||
return false;
|
||||
}
|
||||
|
@ -17,14 +17,16 @@
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "modelNode.h"
|
||||
#include "animInterface.h"
|
||||
#include "pandaNode.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 {
|
||||
class EXPCL_PANDA_PGRAPH UvScrollNode : public PandaNode {
|
||||
PUBLISHED:
|
||||
INLINE UvScrollNode(const string &name, float u_speed, float v_speed);
|
||||
|
||||
@ -33,15 +35,21 @@ protected:
|
||||
|
||||
public:
|
||||
virtual PandaNode *make_copy() const;
|
||||
virtual bool safe_to_flatten() const;
|
||||
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
|
||||
|
||||
PUBLISHED:
|
||||
INLINE void set_u_speed(float u_speed);
|
||||
INLINE void set_v_speed(float v_speed);
|
||||
|
||||
INLINE float get_u_speed() const;
|
||||
INLINE float get_v_speed() const;
|
||||
|
||||
private:
|
||||
float _u_speed;
|
||||
float _v_speed;
|
||||
|
||||
double _start_time;
|
||||
|
||||
public:
|
||||
static void register_with_read_factory();
|
||||
virtual void write_datagram(BamWriter *manager, Datagram &dg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user