Planeshift
pscal3dcallback.h
Go to the documentation of this file.
1 /*
2  * Author: Andrew Robberts
3  *
4  * Copyright (C) 2005 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef PS_CAL3D_CALLBACK_HEADER
21 #define PS_CAL3D_CALLBACK_HEADER
22 //=============================================================================
23 // Crystal Space Includes
24 //=============================================================================
25 #include <csutil/csstring.h>
26 #include <csutil/ref.h>
27 #include <imap/reader.h>
28 
29 #include <cal3d/animcallback.h>
30 
31 //=============================================================================
32 // Project Includes
33 //=============================================================================
34 
35 //=============================================================================
36 // Local Includes
37 //=============================================================================
38 
39 class psCal3DCallbackLoader : public scfImplementation1<psCal3DCallbackLoader,iLoaderPlugin>
40 {
41 public:
42  psCal3DCallbackLoader(iObjectRegistry * objreg);
43  virtual ~psCal3DCallbackLoader();
44 
45  // used to handle and parse the <addon> tags.
46  csPtr<iBase> Parse(iDocumentNode * node, iStreamSource*, iLoaderContext * ldr_context,
47  iBase * context);
48 
49  bool IsThreadSafe() { return true; }
50 };
51 
56 {
57 public:
58  psCal3DCallbackEffect(iDocumentNode * node);
59  virtual ~psCal3DCallbackEffect();
60 
61  void AnimationUpdate(float anim_time, CalModel * model, void * userData);
62  void AnimationComplete(CalModel * model, void * userData);
63 
64 protected:
65 
67  csString effectName;
68 
70  float triggerTime;
71 
74 
77 
80 
83 
85  unsigned int effectID;
86 };
87 
90 {
91  csRef<iSpriteCal3DFactoryState> callbacksprite;
92  csRef<iSpriteCal3DState> callbackspstate;
94  unsigned int callbackcount;
95 
96  // Not using this for now.
97  void AnimationUpdate(float /*anim_time*/, CalModel* /*model*/, void* /*userData*/)
98  {
99  //printf("Anim Update at time %.2f.\n",anim_time);
100  }
101 
102  // This is used to keep animations repeating.
103  void AnimationComplete(CalModel* /*model*/, void* /*userData*/)
104  {
105  //printf("Anim Completed (%d)!\n",callbackcount);
106  if (callbackcount > 0)
107  {
108  callbackcount--;
109  callbackspstate->SetAnimAction(callbackanimation.GetDataSafe(),0.0,0.0);
110  }
111  else // remove callback when repeat count is completed
112  {
113  callbacksprite->RemoveAnimCallback(callbackanimation,this);
114  }
115  }
116 };
117 
118 #endif
119 
csRef< iSpriteCal3DState > callbackspstate
csString callbackanimation
Callback to repeat animation.
csRef< iSpriteCal3DFactoryState > callbacksprite
bool resetPerCycle
if true, effect will be rerendered every cycle, otherwise it will be rendered every animation ...
virtual ~psCal3DCallbackLoader()
bool killWithAnimEnd
true if the effect should die when the animation dies
A stripped version of the cal3d callback loader used only for eedit.
unsigned int callbackcount
float triggerTime
time to trigger the effect
bool hasTriggered
keep track if the effect has triggered this cycle
psCal3DCallbackLoader(iObjectRegistry *objreg)
unsigned int effectID
keep track of the effect ID
void AnimationComplete(CalModel *, void *)
csString effectName
name of the effect to call
float lastUpdateTime
keep track of the animation time of last update
void AnimationUpdate(float, CalModel *, void *)
csPtr< iBase > Parse(iDocumentNode *node, iStreamSource *, iLoaderContext *ldr_context, iBase *context)
A cal3d callback to handle displaying an effect.