- Cal3D 0.11 API Reference -

mixer.h
1 //****************************************************************************//
2 // mixer.h //
3 // Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger //
4 // Copyright (C) 2004 Mekensleep <licensing@mekensleep.com> //
5 //****************************************************************************//
6 // This library is free software; you can redistribute it and/or modify it //
7 // under the terms of the GNU Lesser General Public License as published by //
8 // the Free Software Foundation; either version 2.1 of the License, or (at //
9 // your option) any later version. //
10 //****************************************************************************//
11 
12 #ifndef CAL_MIXER_H
13 #define CAL_MIXER_H
14 
15 //****************************************************************************//
16 // Includes //
17 //****************************************************************************//
18 
19 #include "cal3d/global.h"
20 #include "cal3d/animation.h"
21 #include "cal3d/quaternion.h"
22 
23 //****************************************************************************//
24 // Forward declarations //
25 //****************************************************************************//
26 
27 class CalModel;
28 class CalAnimation;
29 class CalAnimationAction;
30 class CalAnimationCycle;
31 
33  bool on_;
34  float time_;
35  float weight_;
36  float scale_;
37  float rampValue_;
38  CalAnimation::CompositionFunction compositionFunction_;
39 };
40 
41 enum CalMixerBoneAdjustmentFlag {
42  CalMixerBoneAdjustmentFlagPosRot = 1,
43  CalMixerBoneAdjustmentFlagMeshScale = 2
44 };
45 
46 
48 
49  // What parts of the adjustment are to be applied?
50  unsigned int flags_;
51 
52  // Relative to the parent frame of reference.
53  CalVector localPos_;
54  CalQuaternion localOri_;
55 
56  // Scales X, Y, and Z of mesh by these parameters. The scale parameters are with
57  // respect to the absolute coordinate space, e.g., Z is up in 3dMax, as opposed
58  // to the local coordinate space of the bone.
59  CalVector meshScaleAbsolute_;
60 
61  // The adjustment is a highest priority "replace" animation for the bone. Lower priority
62  // animations for the bone, including other replace animations, will be attenuated by 1 - rampValue.
63  float rampValue_;
64 };
65 
66 
68  CalMixerBoneAdjustment boneAdjustment_;
69  int boneId_;
70 };
71 
72 // Total number of bone adjustments per mixer.
73 #define CalMixerBoneAdjustmentsMax ( 20 ) // Arbitrary.
74 
75 
76 /*****************************************************************************/
140 class CAL3D_API CalAbstractMixer
141 {
142 public:
143  CalAbstractMixer() {}
144  virtual ~CalAbstractMixer() {}
145 
146  /*****************************************************************************/
154  virtual bool isDefaultMixer() const { return false; }
155 
156  /*****************************************************************************/
173  virtual void updateAnimation(float deltaTime) = 0;
174 
175  /*****************************************************************************/
191  virtual void updateSkeleton() = 0;
192 };
193 
194 
195 class CAL3D_API CalMixer : public CalAbstractMixer
196 {
197 public:
198  CalMixer(CalModel* pModel);
199  virtual ~CalMixer();
200 
201  virtual bool isDefaultMixer() const { return true; }
202  bool blendCycle(int id, float weight, float delay);
203  bool clearCycle(int id, float delay);
204  bool executeAction(int id, float delayIn, float delayOut, float weightTarget = 1.0f, bool autoLock=false);
205  bool removeAction(int id);
206  virtual void updateAnimation(float deltaTime);
207  virtual void updateSkeleton();
208  float getAnimationTime() const;
209  float getAnimationDuration() const;
210  void setAnimationTime(float animationTime);
211  void setTimeFactor(float timeFactor);
212  float getTimeFactor() const;
213  CalModel *getCalModel();
214  const CalModel *getCalModel() const;
215  std::vector<CalAnimation *> &getAnimationVector();
216  const std::vector<CalAnimation *> &getAnimationVector() const;
217  std::list<CalAnimationAction *> &getAnimationActionList();
218  const std::list<CalAnimationAction *> &getAnimationActionList() const;
219  std::list<CalAnimationCycle *> &getAnimationCycle();
220  const std::list<CalAnimationCycle *> &getAnimationCycle() const;
221  bool actionOn( int coreAnimationId );
222  bool stopAction( int coreAnimationId );
223  bool addManualAnimation( int coreAnimationId );
224  bool removeManualAnimation( int coreAnimationId );
225  bool setManualAnimationOn( int coreAnimationId, bool );
226  bool setManualAnimationTime( int coreAnimationId, float seconds );
227  bool setManualAnimationWeight( int coreAnimationId, float );
228  bool setManualAnimationScale( int coreAnimationId, float p );
229  bool setManualAnimationRampValue( int coreAnimationId, float p );
230  bool setManualAnimationCompositionFunction( int coreAnimationId, CalAnimation::CompositionFunction p );
231  bool setManualAnimationAttributes( int coreAnimationId, CalMixerManualAnimationAttributes const & p );
232  bool animationDuration( int coreAnimationId, float * result );
233  bool addBoneAdjustment( int boneId, CalMixerBoneAdjustment const & );
234  bool removeBoneAdjustment( int boneId );
235  void removeAllBoneAdjustments();
236  unsigned int numActiveOneShotAnimations();
237 protected:
238  CalModel *m_pModel;
239  std::vector<CalAnimation *> m_vectorAnimation;
240  std::list<CalAnimationAction *> m_listAnimationAction;
241  std::list<CalAnimationCycle *> m_listAnimationCycle;
242  float m_animationTime;
243  float m_animationDuration;
244  float m_timeFactor;
245  unsigned int m_numBoneAdjustments;
246  CalMixerBoneAdjustmentAndBoneId m_boneAdjustmentAndBoneIdArray[ CalMixerBoneAdjustmentsMax ];
247 
248 public: // private:
249 
250  CalAnimationAction * animationActionFromCoreAnimationId( int coreAnimationId );
251  CalAnimationAction * newAnimationAction( int coreAnimationId );
252  bool setManualAnimationCompositionFunction( CalAnimationAction *, CalAnimation::CompositionFunction p );
253  bool setManualAnimationRampValue( CalAnimationAction *, float p );
254  bool setManualAnimationScale( CalAnimationAction *, float p );
255  bool setManualAnimationWeight( CalAnimationAction *, float p );
256  bool setManualAnimationTime( CalAnimationAction *, float p );
257  bool setManualAnimationOn( CalAnimationAction *, bool p );
258  void applyBoneAdjustments();
259 };
260 
261 
262 #endif
263 
264 //****************************************************************************//
Definition: mixer.h:195
Definition: animation_cycle.h:22
Definition: mixer.h:32
virtual void updateAnimation(float deltaTime)=0
Notifies the instance that updateAnimation was last called deltaTime seconds ago. ...
virtual void updateSkeleton()=0
Updates the skeleton of the corresponding CalModel (as provided to the create method) to match the cu...
Definition: mixer.h:47
Definition: mixer.h:67
virtual bool isDefaultMixer() const
Is the object an instance of the default mixer (i.e.
Definition: mixer.h:154
CalAbstractMixer defines the API that CalModel relies on for blending and scheduling animations...
Definition: mixer.h:140
virtual bool isDefaultMixer() const
Is the object an instance of the default mixer (i.e.
Definition: mixer.h:201
Definition: animation_action.h:22
The vector class.
Definition: vector.h:36
Definition: animation.h:21
Definition: model.h:30
The quaternion class.
Definition: quaternion.h:35

Generated by The Cal3D Team with Doxygen 1.8.14