Panda3D
 All Classes Functions Variables Enumerations
movingPartBase.h
1 // Filename: movingPartBase.h
2 // Created by: drose (22Feb99)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef MOVINGPARTBASE_H
16 #define MOVINGPARTBASE_H
17 
18 #include "pandabase.h"
19 
20 #include "partGroup.h"
21 #include "partBundle.h"
22 #include "animChannelBase.h"
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : MovingPartBase
26 // Description : This is the base class for a single animatable piece
27 // that may be bound to one channel (or more, if
28 // blending is in effect). It corresponds to, for
29 // instance, a single joint or slider of a character.
30 //
31 // MovingPartBase does not have a particular value type.
32 // See the derived template class, MovingPart, for this.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_PANDA_CHAN MovingPartBase : public PartGroup {
35 protected:
36  INLINE MovingPartBase(const MovingPartBase &copy);
37 
38 public:
39  MovingPartBase(PartGroup *parent, const string &name);
40 
41 PUBLISHED:
42  INLINE int get_max_bound() const;
43  INLINE AnimChannelBase *get_bound(int n) const;
44 
45 public:
46  virtual TypeHandle get_value_type() const=0;
47  virtual AnimChannelBase *make_default_channel() const=0;
48 
49 PUBLISHED:
50  virtual bool clear_forced_channel();
51  virtual AnimChannelBase *get_forced_channel() const;
52 
53  virtual void write(ostream &out, int indent_level) const;
54  virtual void write_with_value(ostream &out, int indent_level) const;
55  virtual void output_value(ostream &out) const=0;
56 
57 public:
58  virtual bool do_update(PartBundle *root, const CycleData *root_cdata,
59  PartGroup *parent, bool parent_changed,
60  bool anim_changed, Thread *current_thread);
61 
62  virtual void get_blend_value(const PartBundle *root)=0;
63  virtual bool update_internals(PartBundle *root, PartGroup *parent,
64  bool self_changed, bool parent_changed,
65  Thread *current_thread);
66 
67 protected:
68  MovingPartBase();
69 
70  virtual void pick_channel_index(plist<int> &holes, int &next) const;
71  virtual void bind_hierarchy(AnimGroup *anim, int channel_index,
72  int &joint_index, bool is_included,
73  BitArray &bound_joints,
74  const PartSubset &subset);
75  virtual void find_bound_joints(int &joint_index, bool is_included,
76  BitArray &bound_joints,
77  const PartSubset &subset);
78  virtual void determine_effective_channels(const CycleData *root_cdata);
79 
80  // This is the vector of all channels bound to this part.
82  Channels _channels;
83 
84  // This is the number of channels in the above _channels vector that
85  // actually have an effect on this part.
86  int _num_effective_channels;
87 
88  // This is the single channel that has an effect on this part, as
89  // determined by determine_effective_channels(). It is only set if
90  // there is exactly one channel that affects this part
91  // (i.e. _num_effective_channels is 1). If there are multiple
92  // channels, or no channels at all, it is NULL.
93  AnimControl *_effective_control;
94  PT(AnimChannelBase) _effective_channel;
95 
96  // This is the particular channel that's been forced to this part,
97  // via set_forced_channel(). It overrides all of the above if set.
98  PT(AnimChannelBase) _forced_channel;
99 
100 public:
101  virtual void write_datagram(BamWriter *manager, Datagram &dg);
102  virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
103 
104 protected:
105  void fillin(DatagramIterator &scan, BamReader *manager);
106 
107 public:
108  virtual TypeHandle get_type() const {
109  return get_class_type();
110  }
111  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
112 PUBLISHED:
113  static TypeHandle get_class_type() {
114  return _type_handle;
115  }
116 public:
117  static void init_type() {
118  PartGroup::init_type();
119  register_type(_type_handle, "MovingPartBase",
120  PartGroup::get_class_type());
121  }
122 
123 private:
124  static TypeHandle _type_handle;
125 };
126 
127 #include "movingPartBase.I"
128 
129 #endif
130 
131 
132 
133 
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
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:532
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:50
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
virtual TypeHandle get_value_type() const
Returns the TypeHandle associated with the ValueType we are concerned with.
Definition: partGroup.cxx:334
virtual void write_with_value(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:318
This is the base class for a single animatable piece that may be bound to one channel (or more...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
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:292
virtual void write(ostream &out, int indent_level) const
Writes a brief description of the group and all of its descendants.
Definition: partGroup.cxx:304
A dynamic array with an unlimited number of bits.
Definition: bitArray.h:42
Parent class for all animation channels.
This is the base class for AnimChannel and AnimBundle.
Definition: animGroup.h:36
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:571
This class is used to define a subset of part names to apply to the PartBundle::bind_anim() operation...
Definition: partSubset.h:28
A thread; that is, a lightweight process.
Definition: thread.h:51
This is the root of a MovingPart hierarchy.
Definition: partBundle.h:49
virtual bool clear_forced_channel()
Undoes the effect of a previous call to apply_freeze() or apply_control().
Definition: partGroup.cxx:279
Controls the timing of a character animation.
Definition: animControl.h:41
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:85
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
Definition: partGroup.cxx:714
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
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:757
This is the base class for PartRoot and MovingPart.
Definition: partGroup.h:45