Planeshift
|
00001 /* 00002 * Author: Andrew Robberts 00003 * 00004 * Copyright (C) 2005 Atomic Blue ([email protected], http://www.atomicblue.org) 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation (version 2 of the License) 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 */ 00019 00020 #ifndef PS_CAL3D_CALLBACK_HEADER 00021 #define PS_CAL3D_CALLBACK_HEADER 00022 //============================================================================= 00023 // Crystal Space Includes 00024 //============================================================================= 00025 #include <csutil/csstring.h> 00026 #include <csutil/ref.h> 00027 #include <imap/reader.h> 00028 00029 #include <cal3d/animcallback.h> 00030 00031 //============================================================================= 00032 // Project Includes 00033 //============================================================================= 00034 00035 //============================================================================= 00036 // Local Includes 00037 //============================================================================= 00038 00039 class psCal3DCallbackLoader : public scfImplementation1<psCal3DCallbackLoader,iLoaderPlugin> 00040 { 00041 public: 00042 psCal3DCallbackLoader(iObjectRegistry * objreg); 00043 virtual ~psCal3DCallbackLoader(); 00044 00045 // used to handle and parse the <addon> tags. 00046 csPtr<iBase> Parse(iDocumentNode * node, iStreamSource*, iLoaderContext * ldr_context, 00047 iBase * context); 00048 00049 bool IsThreadSafe() { return true; } 00050 }; 00051 00055 class psCal3DCallbackEffect : public CalAnimationCallback 00056 { 00057 public: 00058 psCal3DCallbackEffect(iDocumentNode * node); 00059 virtual ~psCal3DCallbackEffect(); 00060 00061 void AnimationUpdate(float anim_time, CalModel * model, void * userData); 00062 void AnimationComplete(CalModel * model, void * userData); 00063 00064 protected: 00065 00067 csString effectName; 00068 00070 float triggerTime; 00071 00073 float lastUpdateTime; 00074 00076 bool hasTriggered; 00077 00079 bool resetPerCycle; 00080 00082 bool killWithAnimEnd; 00083 00085 unsigned int effectID; 00086 }; 00087 00089 struct vmAnimCallback : public CalAnimationCallback 00090 { 00091 csRef<iSpriteCal3DFactoryState> callbacksprite; 00092 csRef<iSpriteCal3DState> callbackspstate; 00093 csString callbackanimation; 00094 unsigned int callbackcount; 00095 00096 // Not using this for now. 00097 void AnimationUpdate(float /*anim_time*/, CalModel* /*model*/, void* /*userData*/) 00098 { 00099 //printf("Anim Update at time %.2f.\n",anim_time); 00100 } 00101 00102 // This is used to keep animations repeating. 00103 void AnimationComplete(CalModel* /*model*/, void* /*userData*/) 00104 { 00105 //printf("Anim Completed (%d)!\n",callbackcount); 00106 if (callbackcount > 0) 00107 { 00108 callbackcount--; 00109 callbackspstate->SetAnimAction(callbackanimation.GetDataSafe(),0.0,0.0); 00110 } 00111 else // remove callback when repeat count is completed 00112 { 00113 callbacksprite->RemoveAnimCallback(callbackanimation,this); 00114 } 00115 } 00116 }; 00117 00118 #endif 00119