Panda3D
animChannelScalarDynamic.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file animChannelScalarDynamic.h
10  * @author drose
11  * @date 2003-10-20
12  */
13 
14 #ifndef ANIMCHANNELSCALARDYNAMIC_H
15 #define ANIMCHANNELSCALARDYNAMIC_H
16 
17 #include "pandabase.h"
18 
19 #include "animChannel.h"
20 
21 class PandaNode;
22 class TransformState;
23 
24 /**
25  * An animation channel that accepts a scalar each frame from some dynamic
26  * input provided by code.
27  *
28  * This object operates in two modes: in explicit mode, the programmer should
29  * call set_value() each frame to indicate the new value; in implicit mode,
30  * the programmer should call set_value_node() to indicate the node whose X
31  * component will be copied to the scalar each frame.
32  */
33 class EXPCL_PANDA_CHAN AnimChannelScalarDynamic : public AnimChannelScalar {
34 protected:
37 
38 public:
39  AnimChannelScalarDynamic(const std::string &name);
40 
41  virtual bool has_changed(int last_frame, double last_frac,
42  int this_frame, double this_frac);
43  virtual void get_value(int frame, PN_stdfloat &value);
44  INLINE PN_stdfloat get_value() const;
45  INLINE PandaNode *get_value_node() const;
46 
47 PUBLISHED:
48  void set_value(PN_stdfloat value);
49  void set_value_node(PandaNode *node);
50 
51  MAKE_PROPERTY(value, get_value, set_value);
52  MAKE_PROPERTY(value_node, get_value_node, set_value_node);
53 
54 protected:
55  virtual AnimGroup *make_copy(AnimGroup *parent) const;
56 
57 private:
58  // This is filled in only if we are using the set_value_node() interface to
59  // get an implicit value from the transform on the indicated node each
60  // frame.
61  PT(PandaNode) _value_node;
62  CPT(TransformState) _value;
63  CPT(TransformState) _last_value;
64 
65  // This is used only if we are using the explicit set_value() interface.
66  bool _value_changed;
67  PN_stdfloat _float_value;
68 
69 public:
70  static void register_with_read_factory();
71  virtual void write_datagram(BamWriter *manager, Datagram &dg);
72  virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
73  void fillin(DatagramIterator &scan, BamReader *manager);
74 
75  static TypedWritable *make_AnimChannelScalarDynamic(const FactoryParams &params);
76 
77 public:
78  virtual TypeHandle get_type() const {
79  return get_class_type();
80  }
81  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
82  static TypeHandle get_class_type() {
83  return _type_handle;
84  }
85  static void init_type() {
86  AnimChannelScalar::init_type();
87  register_type(_type_handle, "AnimChannelScalarDynamic",
88  AnimChannelScalar::get_class_type());
89  }
90 
91 private:
92  static TypeHandle _type_handle;
93 };
94 
96 
97 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
Indicates a coordinate-system transform on vertices.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Takes in a vector of pointes to TypedWritable objects that correspond to all the requests for pointer...
Definition: animGroup.cxx:277
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
static void register_with_read_factory()
Factory method to generate a AnimGroup object.
Definition: animGroup.cxx:308
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
This is our own Panda specialization on the default STL list.
Definition: plist.h:35
This template class is the parent class for all kinds of AnimChannels that return different values.
Definition: animChannel.h:28
virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac)
Returns true if the value has changed since the last call to has_changed().
This is the base class for AnimChannel and AnimBundle.
Definition: animGroup.h:33
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
An animation channel that accepts a scalar each frame from some dynamic input provided by code.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38