Panda3D
movingPartBase.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 movingPartBase.h
10  * @author drose
11  * @date 1999-02-22
12  */
13 
14 #ifndef MOVINGPARTBASE_H
15 #define MOVINGPARTBASE_H
16 
17 #include "pandabase.h"
18 
19 #include "partGroup.h"
20 #include "partBundle.h"
21 #include "animChannelBase.h"
22 
23 /**
24  * This is the base class for a single animatable piece that may be bound to
25  * one channel (or more, if blending is in effect). It corresponds to, for
26  * instance, a single joint or slider of a character.
27  *
28  * MovingPartBase does not have a particular value type. See the derived
29  * template class, MovingPart, for this.
30  */
31 class EXPCL_PANDA_CHAN MovingPartBase : public PartGroup {
32 protected:
33  INLINE MovingPartBase(const MovingPartBase &copy);
34 
35 public:
36  MovingPartBase(PartGroup *parent, const std::string &name);
37 
38 PUBLISHED:
39  INLINE int get_max_bound() const;
40  INLINE AnimChannelBase *get_bound(int n) const;
41 
42 public:
43  virtual TypeHandle get_value_type() const=0;
44  virtual AnimChannelBase *make_default_channel() const=0;
45 
46 PUBLISHED:
47  virtual bool clear_forced_channel();
48  virtual AnimChannelBase *get_forced_channel() const;
49 
50  virtual void write(std::ostream &out, int indent_level) const;
51  virtual void write_with_value(std::ostream &out, int indent_level) const;
52  virtual void output_value(std::ostream &out) const=0;
53 
54 public:
55  virtual bool do_update(PartBundle *root, const CycleData *root_cdata,
56  PartGroup *parent, bool parent_changed,
57  bool anim_changed, Thread *current_thread);
58 
59  virtual void get_blend_value(const PartBundle *root)=0;
60  virtual bool update_internals(PartBundle *root, PartGroup *parent,
61  bool self_changed, bool parent_changed,
62  Thread *current_thread);
63 
64 protected:
66 
67  virtual void pick_channel_index(plist<int> &holes, int &next) const;
68  virtual void bind_hierarchy(AnimGroup *anim, int channel_index,
69  int &joint_index, bool is_included,
70  BitArray &bound_joints,
71  const PartSubset &subset);
72  virtual void find_bound_joints(int &joint_index, bool is_included,
73  BitArray &bound_joints,
74  const PartSubset &subset);
75  virtual void determine_effective_channels(const CycleData *root_cdata);
76 
77  // This is the vector of all channels bound to this part.
78  typedef pvector< PT(AnimChannelBase) > Channels;
79  Channels _channels;
80 
81  // This is the number of channels in the above _channels vector that
82  // actually have an effect on this part.
83  int _num_effective_channels;
84 
85  // This is the single channel that has an effect on this part, as determined
86  // by determine_effective_channels(). It is only set if there is exactly
87  // one channel that affects this part (i.e. _num_effective_channels is 1).
88  // If there are multiple channels, or no channels at all, it is NULL.
89  AnimControl *_effective_control;
90  PT(AnimChannelBase) _effective_channel;
91 
92  // This is the particular channel that's been forced to this part, via
93  // set_forced_channel(). It overrides all of the above if set.
94  PT(AnimChannelBase) _forced_channel;
95 
96 public:
97  virtual void write_datagram(BamWriter *manager, Datagram &dg);
98  virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
99 
100 protected:
101  void fillin(DatagramIterator &scan, BamReader *manager);
102 
103 public:
104  virtual TypeHandle get_type() const {
105  return get_class_type();
106  }
107  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
108 PUBLISHED:
109  static TypeHandle get_class_type() {
110  return _type_handle;
111  }
112 public:
113  static void init_type() {
114  PartGroup::init_type();
115  register_type(_type_handle, "MovingPartBase",
116  PartGroup::get_class_type());
117  }
118 
119 private:
120  static TypeHandle _type_handle;
121 };
122 
123 #include "movingPartBase.I"
124 
125 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Parent class for all animation channels.
Controls the timing of a character animation.
Definition: animControl.h:38
This is the base class for AnimChannel and AnimBundle.
Definition: animGroup.h:33
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
A dynamic array with an unlimited number of bits.
Definition: bitArray.h:40
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:50
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
This is the base class for a single animatable piece that may be bound to one channel (or more,...
virtual TypeHandle get_value_type() const =0
Returns the TypeHandle associated with the ValueType we are concerned with.
This is the root of a MovingPart hierarchy.
Definition: partBundle.h:46
This is the base class for PartRoot and MovingPart.
Definition: partGroup.h:43
virtual void write(std::ostream &out, int indent_level) const
Writes a brief description of the group and all of its descendants.
Definition: partGroup.cxx:256
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
Definition: partGroup.cxx:629
virtual bool clear_forced_channel()
Undoes the effect of a previous call to apply_freeze() or apply_control().
Definition: partGroup.cxx:237
virtual AnimChannelBase * get_forced_channel() const
Returns the AnimChannelBase that has been forced to this joint by a previous call to apply_freeze() o...
Definition: partGroup.cxx:247
virtual void write_with_value(std::ostream &out, int indent_level) const
Writes a brief description of the group, showing its current value, and that of all of its descendant...
Definition: partGroup.cxx:268
virtual void determine_effective_channels(const CycleData *root_cdata)
Should be called whenever the ChannelBlend values have changed, this recursively updates the _effecti...
Definition: partGroup.cxx:503
virtual bool do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *parent, bool parent_changed, bool anim_changed, Thread *current_thread)
Recursively update this particular part and all of its descendents for the current frame.
Definition: partGroup.cxx:470
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Takes in a vector of pointers to TypedWritable objects that correspond to all the requests for pointe...
Definition: partGroup.cxx:666
This class is used to define a subset of part names to apply to the PartBundle::bind_anim() operation...
Definition: partSubset.h:25
A thread; that is, a lightweight process.
Definition: thread.h:46
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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