From 1afba99e1f981c8e2ab5061af14a9d6d115d5a2e Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 18 Oct 2002 00:06:00 +0000 Subject: [PATCH] set_visible_child --- panda/src/pgraph/sequenceNode.I | 17 +++++++++++++++++ panda/src/pgraph/sequenceNode.h | 1 + 2 files changed, 18 insertions(+) diff --git a/panda/src/pgraph/sequenceNode.I b/panda/src/pgraph/sequenceNode.I index a361610354..5d08c297e7 100644 --- a/panda/src/pgraph/sequenceNode.I +++ b/panda/src/pgraph/sequenceNode.I @@ -88,6 +88,23 @@ get_cycle_rate() const { return cdata->_cycle_rate; } +//////////////////////////////////////////////////////////////////// +// Function: SequenceNode::set_visible_child +// Access: Published +// Description: Sets the particular child that this SequenceNode will +// display this frame. Future frames will proceed from +// here. +//////////////////////////////////////////////////////////////////// +INLINE void SequenceNode:: +set_visible_child(int index) { + int num_children = get_num_children(); + if (num_children != 0) { + CDWriter cdata(_cycler); + float now = ClockObject::get_global_clock()->get_frame_time(); + cdata->_frame_offset = (index - (now - cdata->_start_time) * cdata->_cycle_rate); + } +} + //////////////////////////////////////////////////////////////////// // Function: SequenceNode::get_visible_child // Access: Published diff --git a/panda/src/pgraph/sequenceNode.h b/panda/src/pgraph/sequenceNode.h index e81baa9b41..7ffbf48a4a 100644 --- a/panda/src/pgraph/sequenceNode.h +++ b/panda/src/pgraph/sequenceNode.h @@ -46,6 +46,7 @@ PUBLISHED: INLINE void set_cycle_rate(float cycle_rate); INLINE float get_cycle_rate() const; + INLINE void set_visible_child(int index); INLINE int get_visible_child() const; private: