Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

Actor.h

Go to the documentation of this file.
00001 /* Actor - Base class for all objects that appear on the screen. */ 00002 00003 #ifndef ACTOR_H 00004 #define ACTOR_H 00005 00006 #include "RageTypes.h" 00007 #include "ActorCommands.h" 00008 #include <deque> 00009 #include <map> 00010 struct XNode; 00011 struct lua_State; 00012 00013 #define DRAW_ORDER_BEFORE_EVERYTHING -100 00014 #define DRAW_ORDER_TRANSITIONS 100 00015 #define DRAW_ORDER_AFTER_EVERYTHING 200 00016 00017 00018 #define LUA_Actor_METHODS( T ) \ 00019 static int sleep( T* p, lua_State *L ) { p->Sleep(FArg(1)); return 0; } \ 00020 static int linear( T* p, lua_State *L ) { p->BeginTweening(FArg(1),Actor::TWEEN_LINEAR); return 0; } \ 00021 static int accelerate( T* p, lua_State *L ) { p->BeginTweening(FArg(1),Actor::TWEEN_ACCELERATE); return 0; } \ 00022 static int decelerate( T* p, lua_State *L ) { p->BeginTweening(FArg(1),Actor::TWEEN_DECELERATE); return 0; } \ 00023 static int bouncebegin( T* p, lua_State *L ) { p->BeginTweening(FArg(1),Actor::TWEEN_BOUNCE_BEGIN); return 0; } \ 00024 static int bounceend( T* p, lua_State *L ) { p->BeginTweening(FArg(1),Actor::TWEEN_BOUNCE_END); return 0; } \ 00025 static int spring( T* p, lua_State *L ) { p->BeginTweening(FArg(1),Actor::TWEEN_SPRING); return 0; } \ 00026 static int stoptweening( T* p, lua_State *L ) { p->StopTweening(); p->BeginTweening( 0.0001f, Actor::TWEEN_LINEAR ); return 0; } \ 00027 static int finishtweening( T* p, lua_State *L ) { p->FinishTweening(); return 0; } \ 00028 static int hurrytweening( T* p, lua_State *L ) { p->HurryTweening(FArg(1)); return 0; } \ 00029 static int x( T* p, lua_State *L ) { p->SetX(FArg(1)); return 0; } \ 00030 static int y( T* p, lua_State *L ) { p->SetY(FArg(1)); return 0; } \ 00031 static int z( T* p, lua_State *L ) { p->SetZ(FArg(1)); return 0; } \ 00032 static int addx( T* p, lua_State *L ) { p->AddX(FArg(1)); return 0; } \ 00033 static int addy( T* p, lua_State *L ) { p->AddY(FArg(1)); return 0; } \ 00034 static int addz( T* p, lua_State *L ) { p->AddZ(FArg(1)); return 0; } \ 00035 static int zoom( T* p, lua_State *L ) { p->SetZoom(FArg(1)); return 0; } \ 00036 static int zoomx( T* p, lua_State *L ) { p->SetZoomX(FArg(1)); return 0; } \ 00037 static int zoomy( T* p, lua_State *L ) { p->SetZoomY(FArg(1)); return 0; } \ 00038 static int zoomz( T* p, lua_State *L ) { p->SetZoomZ(FArg(1)); return 0; } \ 00039 static int zoomtowidth( T* p, lua_State *L ) { p->ZoomToWidth(FArg(1)); return 0; } \ 00040 static int zoomtoheight( T* p, lua_State *L ) { p->ZoomToHeight(FArg(1)); return 0; } \ 00041 static int stretchto( T* p, lua_State *L ) { p->StretchTo( RectF(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \ 00042 static int cropleft( T* p, lua_State *L ) { p->SetCropLeft(FArg(1)); return 0; } \ 00043 static int croptop( T* p, lua_State *L ) { p->SetCropTop(FArg(1)); return 0; } \ 00044 static int cropright( T* p, lua_State *L ) { p->SetCropRight(FArg(1)); return 0; } \ 00045 static int cropbottom( T* p, lua_State *L ) { p->SetCropBottom(FArg(1)); return 0; } \ 00046 static int fadeleft( T* p, lua_State *L ) { p->SetFadeLeft(FArg(1)); return 0; } \ 00047 static int fadetop( T* p, lua_State *L ) { p->SetFadeTop(FArg(1)); return 0; } \ 00048 static int faderight( T* p, lua_State *L ) { p->SetFadeRight(FArg(1)); return 0; } \ 00049 static int fadebottom( T* p, lua_State *L ) { p->SetFadeBottom(FArg(1)); return 0; } \ 00050 static int diffuse( T* p, lua_State *L ) { p->SetDiffuse( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \ 00051 static int diffuseleftedge( T* p, lua_State *L ) { p->SetDiffuseLeftEdge( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \ 00052 static int diffuserightedge( T* p, lua_State *L ) { p->SetDiffuseRightEdge( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \ 00053 static int diffusetopedge( T* p, lua_State *L ) { p->SetDiffuseTopEdge( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \ 00054 static int diffusebottomedge( T* p, lua_State *L ) { p->SetDiffuseBottomEdge( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \ 00055 static int diffusealpha( T* p, lua_State *L ) { p->SetDiffuseAlpha(FArg(1)); return 0; } \ 00056 static int diffusecolor( T* p, lua_State *L ) { p->SetDiffuseColor( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \ 00057 static int glow( T* p, lua_State *L ) { p->SetGlow( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \ 00058 static int rotationx( T* p, lua_State *L ) { p->SetRotationX(FArg(1)); return 0; } \ 00059 static int rotationy( T* p, lua_State *L ) { p->SetRotationY(FArg(1)); return 0; } \ 00060 static int rotationz( T* p, lua_State *L ) { p->SetRotationZ(FArg(1)); return 0; } \ 00061 static int heading( T* p, lua_State *L ) { p->AddRotationH(FArg(1)); return 0; } \ 00062 static int pitch( T* p, lua_State *L ) { p->AddRotationP(FArg(1)); return 0; } \ 00063 static int roll( T* p, lua_State *L ) { p->AddRotationR(FArg(1)); return 0; } \ 00064 static int shadowlength( T* p, lua_State *L ) { p->SetShadowLength(FArg(1)); return 0; } \ 00065 static int horizalign( T* p, lua_State *L ) { p->SetHorizAlignString(SArg(1)); return 0; } \ 00066 static int vertalign( T* p, lua_State *L ) { p->SetVertAlignString(SArg(1)); return 0; } \ 00067 static int diffuseblink( T* p, lua_State *L ) { p->SetEffectDiffuseBlink(); return 0; } \ 00068 static int diffuseshift( T* p, lua_State *L ) { p->SetEffectDiffuseShift(); return 0; } \ 00069 static int glowblink( T* p, lua_State *L ) { p->SetEffectGlowBlink(); return 0; } \ 00070 static int glowshift( T* p, lua_State *L ) { p->SetEffectGlowShift(); return 0; } \ 00071 static int rainbow( T* p, lua_State *L ) { p->SetEffectRainbow(); return 0; } \ 00072 static int wag( T* p, lua_State *L ) { p->SetEffectWag(); return 0; } \ 00073 static int bounce( T* p, lua_State *L ) { p->SetEffectBounce(); return 0; } \ 00074 static int bob( T* p, lua_State *L ) { p->SetEffectBob(); return 0; } \ 00075 static int pulse( T* p, lua_State *L ) { p->SetEffectPulse(); return 0; } \ 00076 static int spin( T* p, lua_State *L ) { p->SetEffectSpin(); return 0; } \ 00077 static int vibrate( T* p, lua_State *L ) { p->SetEffectVibrate(); return 0; } \ 00078 static int stopeffect( T* p, lua_State *L ) { p->SetEffectNone(); return 0; } \ 00079 static int effectcolor1( T* p, lua_State *L ) { p->SetEffectColor1( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \ 00080 static int effectcolor2( T* p, lua_State *L ) { p->SetEffectColor2( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \ 00081 static int effectperiod( T* p, lua_State *L ) { p->SetEffectPeriod(FArg(1)); return 0; } \ 00082 static int effectoffset( T* p, lua_State *L ) { p->SetEffectOffset(FArg(1)); return 0; } \ 00083 static int effectdelay( T* p, lua_State *L ) { p->SetEffectDelay(FArg(1)); return 0; } \ 00084 static int effectclock( T* p, lua_State *L ) { p->SetEffectClockString(SArg(1)); return 0; } \ 00085 static int effectmagnitude( T* p, lua_State *L ) { p->SetEffectMagnitude( RageVector3(FArg(1),FArg(2),FArg(3)) ); return 0; } \ 00086 static int scaletocover( T* p, lua_State *L ) { p->ScaleToCover( RectF(FArg(1), FArg(2), FArg(3), FArg(4)) ); return 0; } \ 00087 static int scaletofit( T* p, lua_State *L ) { p->ScaleToFitInside( RectF(FArg(1), FArg(2), FArg(3), FArg(4)) ); return 0; } \ 00088 static int animate( T* p, lua_State *L ) { p->EnableAnimation(BArg(1)); return 0; } \ 00089 static int play( T* p, lua_State *L ) { p->EnableAnimation(true); return 0; } \ 00090 static int pause( T* p, lua_State *L ) { p->EnableAnimation(false); return 0; } \ 00091 static int setstate( T* p, lua_State *L ) { p->SetState(IArg(1)); return 0; } \ 00092 static int texturewrapping( T* p, lua_State *L ) { p->SetTextureWrapping(BArg(1)); return 0; } \ 00093 static int additiveblend( T* p, lua_State *L ) { p->SetBlendMode(BArg(1) ? BLEND_ADD : BLEND_NORMAL); return 0; } \ 00094 static int blend( T* p, lua_State *L ) { p->SetBlendModeString(SArg(1)); return 0; } \ 00095 static int zbuffer( T* p, lua_State *L ) { p->SetUseZBuffer(BArg(1)); return 0; } \ 00096 static int ztest( T* p, lua_State *L ) { p->SetZTestMode(BArg(1)?ZTEST_WRITE_ON_PASS:ZTEST_OFF); return 0; } \ 00097 static int ztestmode( T* p, lua_State *L ) { p->SetZTestModeString(SArg(1)); return 0; } \ 00098 static int zwrite( T* p, lua_State *L ) { p->SetZWrite(BArg(1)); return 0; } \ 00099 static int clearzbuffer( T* p, lua_State *L ) { p->SetClearZBuffer(BArg(1)); return 0; } \ 00100 static int backfacecull( T* p, lua_State *L ) { p->SetCullMode(BArg(1) ? CULL_BACK : CULL_NONE); return 0; } \ 00101 static int cullmode( T* p, lua_State *L ) { p->SetCullModeString(SArg(1)); return 0; } \ 00102 static int hidden( T* p, lua_State *L ) { p->SetHidden(BArg(1)); return 0; } \ 00103 static int hibernate( T* p, lua_State *L ) { p->SetHibernate(FArg(1)); return 0; } \ 00104 static int draworder( T* p, lua_State *L ) { p->SetDrawOrder(IArg(1)); return 0; } \ 00105 static int playcommand( T* p, lua_State *L ) { p->PlayCommand(SArg(1)); return 0; } \ 00106 static int queuecommand( T* p, lua_State *L ) { p->QueueCommand(SArg(1)); return 0; } \ 00107 00108 #define LUA_Actor_METHODS_MAP( T ) \ 00109 LUA_METHOD_MAP( T, sleep ) \ 00110 LUA_METHOD_MAP( T, linear ) \ 00111 LUA_METHOD_MAP( T, accelerate ) \ 00112 LUA_METHOD_MAP( T, decelerate ) \ 00113 LUA_METHOD_MAP( T, bouncebegin ) \ 00114 LUA_METHOD_MAP( T, bounceend ) \ 00115 LUA_METHOD_MAP( T, spring ) \ 00116 LUA_METHOD_MAP( T, stoptweening ) \ 00117 LUA_METHOD_MAP( T, finishtweening ) \ 00118 LUA_METHOD_MAP( T, hurrytweening ) \ 00119 LUA_METHOD_MAP( T, x ) \ 00120 LUA_METHOD_MAP( T, y ) \ 00121 LUA_METHOD_MAP( T, z ) \ 00122 LUA_METHOD_MAP( T, addx ) \ 00123 LUA_METHOD_MAP( T, addy ) \ 00124 LUA_METHOD_MAP( T, addz ) \ 00125 LUA_METHOD_MAP( T, zoom ) \ 00126 LUA_METHOD_MAP( T, zoomx ) \ 00127 LUA_METHOD_MAP( T, zoomy ) \ 00128 LUA_METHOD_MAP( T, zoomz ) \ 00129 LUA_METHOD_MAP( T, zoomtowidth ) \ 00130 LUA_METHOD_MAP( T, zoomtoheight ) \ 00131 LUA_METHOD_MAP( T, stretchto ) \ 00132 LUA_METHOD_MAP( T, cropleft ) \ 00133 LUA_METHOD_MAP( T, croptop ) \ 00134 LUA_METHOD_MAP( T, cropright ) \ 00135 LUA_METHOD_MAP( T, cropbottom ) \ 00136 LUA_METHOD_MAP( T, fadeleft ) \ 00137 LUA_METHOD_MAP( T, fadetop ) \ 00138 LUA_METHOD_MAP( T, faderight ) \ 00139 LUA_METHOD_MAP( T, fadebottom ) \ 00140 LUA_METHOD_MAP( T, diffuse ) \ 00141 LUA_METHOD_MAP( T, diffuseleftedge ) \ 00142 LUA_METHOD_MAP( T, diffuserightedge ) \ 00143 LUA_METHOD_MAP( T, diffusetopedge ) \ 00144 LUA_METHOD_MAP( T, diffusebottomedge ) \ 00145 LUA_METHOD_MAP( T, diffusealpha ) \ 00146 LUA_METHOD_MAP( T, diffusecolor ) \ 00147 LUA_METHOD_MAP( T, glow ) \ 00148 LUA_METHOD_MAP( T, rotationx ) \ 00149 LUA_METHOD_MAP( T, rotationy ) \ 00150 LUA_METHOD_MAP( T, rotationz ) \ 00151 LUA_METHOD_MAP( T, heading ) \ 00152 LUA_METHOD_MAP( T, pitch ) \ 00153 LUA_METHOD_MAP( T, roll ) \ 00154 LUA_METHOD_MAP( T, shadowlength ) \ 00155 LUA_METHOD_MAP( T, horizalign ) \ 00156 LUA_METHOD_MAP( T, vertalign ) \ 00157 LUA_METHOD_MAP( T, diffuseblink ) \ 00158 LUA_METHOD_MAP( T, diffuseshift ) \ 00159 LUA_METHOD_MAP( T, glowblink ) \ 00160 LUA_METHOD_MAP( T, glowshift ) \ 00161 LUA_METHOD_MAP( T, rainbow ) \ 00162 LUA_METHOD_MAP( T, wag ) \ 00163 LUA_METHOD_MAP( T, bounce ) \ 00164 LUA_METHOD_MAP( T, bob ) \ 00165 LUA_METHOD_MAP( T, pulse ) \ 00166 LUA_METHOD_MAP( T, spin ) \ 00167 LUA_METHOD_MAP( T, vibrate ) \ 00168 LUA_METHOD_MAP( T, stopeffect ) \ 00169 LUA_METHOD_MAP( T, effectcolor1 ) \ 00170 LUA_METHOD_MAP( T, effectcolor2 ) \ 00171 LUA_METHOD_MAP( T, effectperiod ) \ 00172 LUA_METHOD_MAP( T, effectoffset ) \ 00173 LUA_METHOD_MAP( T, effectdelay ) \ 00174 LUA_METHOD_MAP( T, effectclock ) \ 00175 LUA_METHOD_MAP( T, effectmagnitude ) \ 00176 LUA_METHOD_MAP( T, scaletocover ) \ 00177 LUA_METHOD_MAP( T, scaletofit ) \ 00178 LUA_METHOD_MAP( T, animate ) \ 00179 LUA_METHOD_MAP( T, play ) \ 00180 LUA_METHOD_MAP( T, pause ) \ 00181 LUA_METHOD_MAP( T, setstate ) \ 00182 LUA_METHOD_MAP( T, texturewrapping ) \ 00183 LUA_METHOD_MAP( T, additiveblend ) \ 00184 LUA_METHOD_MAP( T, blend ) \ 00185 LUA_METHOD_MAP( T, zbuffer ) \ 00186 LUA_METHOD_MAP( T, ztest ) \ 00187 LUA_METHOD_MAP( T, ztestmode ) \ 00188 LUA_METHOD_MAP( T, zwrite ) \ 00189 LUA_METHOD_MAP( T, clearzbuffer ) \ 00190 LUA_METHOD_MAP( T, backfacecull ) \ 00191 LUA_METHOD_MAP( T, cullmode ) \ 00192 LUA_METHOD_MAP( T, hidden ) \ 00193 LUA_METHOD_MAP( T, hibernate ) \ 00194 LUA_METHOD_MAP( T, draworder ) \ 00195 LUA_METHOD_MAP( T, playcommand ) \ 00196 LUA_METHOD_MAP( T, queuecommand ) \ 00197 00198 00199 class Actor 00200 { 00201 public: 00202 Actor(); 00203 virtual ~Actor() {} 00204 virtual void Reset(); 00205 void LoadFromNode( const CString& sDir, const XNode* pNode ); 00206 00207 static void SetBGMTime( float fTime, float fBeat ) { g_fCurrentBGMTime = fTime; g_fCurrentBGMBeat = fBeat; } 00208 00209 enum TweenType { 00210 TWEEN_LINEAR, 00211 TWEEN_ACCELERATE, 00212 TWEEN_DECELERATE, 00213 TWEEN_BOUNCE_BEGIN, 00214 TWEEN_BOUNCE_END, 00215 TWEEN_SPRING, 00216 }; 00217 enum Effect { no_effect, 00218 diffuse_blink, diffuse_shift, 00219 glow_blink, glow_shift, 00220 rainbow, 00221 wag, bounce, bob, pulse, 00222 spin, vibrate 00223 }; 00224 00225 struct TweenState 00226 { 00227 // start and end position for tweening 00228 RageVector3 pos; 00229 RageVector3 rotation; 00230 RageVector4 quat; 00231 RageVector3 scale; 00232 RectF crop; // 0 = no cropping, 1 = fully cropped 00233 RectF fade; // 0 = no fade 00234 RageColor diffuse[4]; 00235 RageColor glow; 00236 CString sCommandName; // command to execute when this TweenState goes into effect 00237 00238 void Init(); 00239 static void MakeWeightedAverage( TweenState& average_out, const TweenState& ts1, const TweenState& ts2, float fPercentBetween ); 00240 }; 00241 00242 enum EffectClock { CLOCK_TIMER, CLOCK_BGM_TIME, CLOCK_BGM_BEAT, NUM_CLOCKS }; 00243 00244 void Draw(); // calls, NeedsDraw, BeginDraw, DrawPrimitives, EndDraw 00245 virtual bool EarlyAbortDraw() { return false; } // return true to early abort drawing of this Actor 00246 virtual void BeginDraw(); // pushes transform onto world matrix stack 00247 virtual void SetRenderStates(); // Actor should call at beginning of their DrawPrimitives() after setting textures 00248 virtual void DrawPrimitives() {}; // Derivitives should override 00249 virtual void EndDraw(); // pops transform from world matrix stack 00250 00251 bool IsFirstUpdate() const; 00252 virtual void Update( float fDeltaTime ); 00253 void UpdateTweening( float fDeltaTime ); 00254 void CopyTweening( const Actor &from ); 00255 00256 00257 CString m_sName, m_sID; 00258 00259 /* m_sName is the name actors use to look up internal metrics for themselves, and for 00260 * filenames. m_sID is the name parents use to look up their own metrics for an actor 00261 * (usually via ActorUtil). (This is experimental; see DifficultyMeter.cpp for more 00262 * information.) */ 00263 const CString &GetName() const { return m_sName; } 00264 const CString &GetID() const { return m_sID.empty() ? m_sName : m_sID; } 00265 void SetName( const CString &sName, const CString &sID = "" ) { m_sName = sName; m_sID = sID; } 00266 00267 00268 00269 /* Do subclasses really need to override tweening? Tween data should 00270 * probably be private ... - glenn */ 00271 /* Things like a "FocusingSprite" might, but probably not. -Chris */ 00272 00273 /* Return the current coordinates, not the destination coordinates; 00274 * that's what the old behavior was, at least, and it's what ScreenMusicScroll 00275 * expects. I could see uses for knowing the destination coords, though, 00276 * especially now that setting parameters when tweening and when not tweening 00277 * is somewhat abstracted. Hmmm. -glenn */ 00278 /* Things like the cursor on ScreenSelectDifficutly need to know the dest coordinates. 00279 * -Chris */ 00280 float GetX() const { return m_current.pos.x; }; 00281 float GetY() const { return m_current.pos.y; }; 00282 float GetZ() const { return m_current.pos.z; }; 00283 float GetDestX() { return DestTweenState().pos.x; }; 00284 float GetDestY() { return DestTweenState().pos.y; }; 00285 float GetDestZ() { return DestTweenState().pos.z; }; 00286 void SetX( float x ) { DestTweenState().pos.x = x; }; 00287 void SetY( float y ) { DestTweenState().pos.y = y; }; 00288 void SetZ( float z ) { DestTweenState().pos.z = z; }; 00289 void SetXY( float x, float y ) { DestTweenState().pos.x = x; DestTweenState().pos.y = y; }; 00290 void AddX( float x ) { SetX( GetDestX()+x ); } 00291 void AddY( float y ) { SetY( GetDestY()+y ); } 00292 void AddZ( float z ) { SetZ( GetDestZ()+z ); } 00293 00294 // height and width vary depending on zoom 00295 float GetUnzoomedWidth() { return m_size.x; } 00296 float GetUnzoomedHeight() { return m_size.y; } 00297 float GetZoomedWidth() { return m_size.x * m_baseScale.x * DestTweenState().scale.x; } 00298 float GetZoomedHeight() { return m_size.y * m_baseScale.y * DestTweenState().scale.y; } 00299 void SetWidth( float width ) { m_size.x = width; } 00300 void SetHeight( float height ) { m_size.y = height; } 00301 00302 void SetBaseZoomX( float zoom ) { m_baseScale.x = zoom; } 00303 void SetBaseZoomY( float zoom ) { m_baseScale.y = zoom; } 00304 void SetBaseZoomZ( float zoom ) { m_baseScale.z = zoom; } 00305 void SetBaseZoom( const RageVector3 &zoom ) { m_baseScale = zoom; } 00306 void SetBaseRotationX( float rot ) { m_baseRotation.x = rot; } 00307 void SetBaseRotationY( float rot ) { m_baseRotation.y = rot; } 00308 void SetBaseRotationZ( float rot ) { m_baseRotation.z = rot; } 00309 void SetBaseRotation( const RageVector3 &rot ) { m_baseRotation = rot; } 00310 00311 float GetZoom() { return DestTweenState().scale.x; } // not accurate in some cases 00312 float GetZoomX() { return DestTweenState().scale.x; } 00313 float GetZoomY() { return DestTweenState().scale.y; } 00314 float GetZoomZ() { return DestTweenState().scale.z; } 00315 void SetZoom( float zoom ) { DestTweenState().scale.x = zoom; DestTweenState().scale.y = zoom; } 00316 void SetZoomX( float zoom ) { DestTweenState().scale.x = zoom; } 00317 void SetZoomY( float zoom ) { DestTweenState().scale.y = zoom; } 00318 void SetZoomZ( float zoom ) { DestTweenState().scale.z = zoom; } 00319 void ZoomToWidth( float zoom ) { SetZoomX( zoom / GetUnzoomedWidth() ); } 00320 void ZoomToHeight( float zoom ){ SetZoomY( zoom / GetUnzoomedHeight() ); } 00321 00322 float GetRotationX() { return DestTweenState().rotation.x; } 00323 float GetRotationY() { return DestTweenState().rotation.y; } 00324 float GetRotationZ() { return DestTweenState().rotation.z; } 00325 void SetRotationX( float rot ) { DestTweenState().rotation.x = rot; } 00326 void SetRotationY( float rot ) { DestTweenState().rotation.y = rot; } 00327 void SetRotationZ( float rot ) { DestTweenState().rotation.z = rot; } 00328 void AddRotationH( float rot ); 00329 void AddRotationP( float rot ); 00330 void AddRotationR( float rot ); 00331 00332 float GetCropLeft() { return DestTweenState().crop.left; } 00333 float GetCropTop() { return DestTweenState().crop.top; } 00334 float GetCropRight() { return DestTweenState().crop.right;} 00335 float GetCropBottom() { return DestTweenState().crop.bottom;} 00336 void SetCropLeft( float percent ) { DestTweenState().crop.left = percent; } 00337 void SetCropTop( float percent ) { DestTweenState().crop.top = percent; } 00338 void SetCropRight( float percent ) { DestTweenState().crop.right = percent;} 00339 void SetCropBottom( float percent ){ DestTweenState().crop.bottom = percent;} 00340 00341 void SetFadeLeft( float percent ) { DestTweenState().fade.left = percent; } 00342 void SetFadeTop( float percent ) { DestTweenState().fade.top = percent; } 00343 void SetFadeRight( float percent ) { DestTweenState().fade.right = percent;} 00344 void SetFadeBottom( float percent ){ DestTweenState().fade.bottom = percent;} 00345 00346 void SetGlobalDiffuseColor( RageColor c ); 00347 void SetGlobalX( float x ); 00348 00349 virtual void SetDiffuse( RageColor c ) { for(int i=0; i<4; i++) DestTweenState().diffuse[i] = c; }; 00350 virtual void SetDiffuseAlpha( float f ) { for(int i = 0; i < 4; ++i) { RageColor c = GetDiffuses( i ); c.a = f; SetDiffuses( i, c ); } } 00351 void SetDiffuseColor( RageColor c ); 00352 void SetDiffuses( int i, RageColor c ) { DestTweenState().diffuse[i] = c; }; 00353 void SetDiffuseUpperLeft( RageColor c ) { DestTweenState().diffuse[0] = c; }; 00354 void SetDiffuseUpperRight( RageColor c ) { DestTweenState().diffuse[1] = c; }; 00355 void SetDiffuseLowerLeft( RageColor c ) { DestTweenState().diffuse[2] = c; }; 00356 void SetDiffuseLowerRight( RageColor c ) { DestTweenState().diffuse[3] = c; }; 00357 void SetDiffuseTopEdge( RageColor c ) { DestTweenState().diffuse[0] = DestTweenState().diffuse[1] = c; }; 00358 void SetDiffuseRightEdge( RageColor c ) { DestTweenState().diffuse[1] = DestTweenState().diffuse[3] = c; }; 00359 void SetDiffuseBottomEdge( RageColor c ) { DestTweenState().diffuse[2] = DestTweenState().diffuse[3] = c; }; 00360 void SetDiffuseLeftEdge( RageColor c ) { DestTweenState().diffuse[0] = DestTweenState().diffuse[2] = c; }; 00361 RageColor GetDiffuse() { return DestTweenState().diffuse[0]; }; 00362 RageColor GetDiffuses( int i ) { return DestTweenState().diffuse[i]; }; 00363 void SetGlow( RageColor c ) { DestTweenState().glow = c; }; 00364 RageColor GetGlow() { return DestTweenState().glow; }; 00365 00366 00367 void BeginTweening( float time, TweenType tt = TWEEN_LINEAR ); 00368 void StopTweening(); 00369 void Sleep( float time ); 00370 void QueueCommand( const CString& sCommandName ); 00371 virtual void FinishTweening(); 00372 virtual void HurryTweening( float factor ); 00373 // Let ActorFrame and BGAnimation override 00374 virtual float GetTweenTimeLeft() const; // Amount of time until all tweens have stopped 00375 TweenState& DestTweenState() // where Actor will end when its tween finish 00376 { 00377 if( m_Tweens.empty() ) // not tweening 00378 return m_current; 00379 else 00380 return LatestTween(); 00381 } 00382 void SetLatestTween( TweenState ts ) { LatestTween() = ts; } 00383 00384 00385 enum StretchType { fit_inside, cover }; 00386 00387 void ScaleToCover( const RectF &rect ) { ScaleTo( rect, cover ); } 00388 void ScaleToFitInside( const RectF &rect ) { ScaleTo( rect, fit_inside); }; 00389 void ScaleTo( const RectF &rect, StretchType st ); 00390 00391 void StretchTo( const RectF &rect ); 00392 00393 00394 // 00395 // Alignment settings. These need to be virtual for BitmapText 00396 // 00397 enum HorizAlign { align_left, align_center, align_right }; 00398 virtual void SetHorizAlign( HorizAlign ha ) { m_HorizAlign = ha; } 00399 virtual void SetHorizAlignString( const CString &s ); // convenience 00400 00401 enum VertAlign { align_top, align_middle, align_bottom }; 00402 virtual void SetVertAlign( VertAlign va ) { m_VertAlign = va; } 00403 virtual void SetVertAlignString( const CString &s ); // convenience 00404 00405 00406 // 00407 // effects 00408 // 00409 void SetEffectNone() { m_Effect = no_effect; } 00410 Effect GetEffect() { return m_Effect; } 00411 void SetEffectColor1( RageColor c ) { m_effectColor1 = c; } 00412 void SetEffectColor2( RageColor c ) { m_effectColor2 = c; } 00413 void SetEffectPeriod( float fSecs ) { m_fEffectPeriodSeconds = fSecs; } 00414 void SetEffectDelay( float fTime ) { m_fEffectDelay = fTime; } 00415 void SetEffectOffset( float fPercent ) { m_fEffectOffset = fPercent; } 00416 void SetEffectClock( EffectClock c ) { m_EffectClock = c; } 00417 void SetEffectClockString( const CString &s ); // convenience 00418 00419 void SetEffectMagnitude( RageVector3 vec ) { m_vEffectMagnitude = vec; } 00420 00421 void SetEffectDiffuseBlink( 00422 float fEffectPeriodSeconds = 1.0f, 00423 RageColor c1 = RageColor(0.5f,0.5f,0.5f,1), 00424 RageColor c2 = RageColor(1,1,1,1) ); 00425 void SetEffectDiffuseShift( float fEffectPeriodSeconds = 1.f, 00426 RageColor c1 = RageColor(0,0,0,1), 00427 RageColor c2 = RageColor(1,1,1,1) ); 00428 void SetEffectGlowBlink( float fEffectPeriodSeconds = 1.f, 00429 RageColor c1 = RageColor(1,1,1,0.2f), 00430 RageColor c2 = RageColor(1,1,1,0.8f) ); 00431 void SetEffectGlowShift( 00432 float fEffectPeriodSeconds = 1.0f, 00433 RageColor c1 = RageColor(1,1,1,0.2f), 00434 RageColor c2 = RageColor(1,1,1,0.8f) ); 00435 void SetEffectRainbow( 00436 float fEffectPeriodSeconds = 2.0f ); 00437 void SetEffectWag( 00438 float fPeriod = 2.f, 00439 RageVector3 vect = RageVector3(0,0,20) ); 00440 void SetEffectBounce( 00441 float fPeriod = 2.f, 00442 RageVector3 vect = RageVector3(0,0,20) ); 00443 void SetEffectBob( 00444 float fPeriod = 2.f, 00445 RageVector3 vect = RageVector3(0,0,20) ); 00446 void SetEffectPulse( 00447 float fPeriod = 2.f, 00448 float fMinZoom = 0.5f, 00449 float fMaxZoom = 1.f ); 00450 void SetEffectSpin( 00451 RageVector3 vect = RageVector3(0,0,180) ); 00452 void SetEffectVibrate( 00453 RageVector3 vect = RageVector3(10,10,10) ); 00454 00455 00456 // 00457 // other properties 00458 // 00459 bool GetHidden() const { return m_bHidden; } 00460 void SetHidden( bool b ) { m_bHidden = b; } 00461 void SetShadowLength( float fLength ); 00462 // TODO: Implement hibernate as a tween type? 00463 void SetHibernate( float fSecs ) { m_fHibernateSecondsLeft = fSecs; } 00464 void SetDrawOrder( int iOrder ) { m_iDrawOrder = iOrder; } 00465 int GetDrawOrder() const { return m_iDrawOrder; } 00466 00467 virtual void EnableAnimation( bool b ) { m_bIsAnimating = b; } // Sprite needs to overload this 00468 void StartAnimating() { this->EnableAnimation(true); }; 00469 void StopAnimating() { this->EnableAnimation(false); }; 00470 00471 00472 // 00473 // render states 00474 // 00475 void SetBlendMode( BlendMode mode ) { m_BlendMode = mode; } 00476 void SetBlendModeString( const CString &s ); // convenience 00477 void SetTextureWrapping( bool b ) { m_bTextureWrapping = b; } 00478 void SetClearZBuffer( bool b ) { m_bClearZBuffer = b; } 00479 void SetUseZBuffer( bool b ) { SetZTestMode(b?ZTEST_WRITE_ON_PASS:ZTEST_OFF); SetZWrite(b); } 00480 virtual void SetZTestMode( ZTestMode mode ) { m_ZTestMode = mode; } 00481 void SetZTestModeString( const CString &s ); // convenience 00482 virtual void SetZWrite( bool b ) { m_bZWrite = b; } 00483 virtual void SetCullMode( CullMode mode ) { m_CullMode = mode; } 00484 void SetCullModeString( const CString &s ); // convenience 00485 00486 // 00487 // Commands 00488 // 00489 virtual void PushSelf( lua_State *L ); 00490 virtual void PlayCommand( const CString &sCommandName ); 00491 virtual void RunCommands( const ActorCommands& cmds ); 00492 void RunCommands( const apActorCommands& cmds ) { this->RunCommands( *cmds ); } // convenience 00493 00494 static float GetCommandsLengthSeconds( const ActorCommands& cmds ); 00495 static float GetCommandsLengthSeconds( const apActorCommands& cmds ) { return GetCommandsLengthSeconds( *cmds ); } // convenience 00496 00497 // 00498 // Animation 00499 // 00500 virtual int GetNumStates() const { return 1; } 00501 virtual void SetState( int iNewState ) {} 00502 virtual float GetAnimationLengthSeconds() const { return 0; } 00503 virtual void SetSecondsIntoAnimation( float fSeconds ) {} 00504 00505 // 00506 // BGAnimation stuff 00507 // 00508 virtual void GainFocus( float fRate, bool bRewindMovie, bool bLoop ) {} 00509 virtual void LoseFocus() {} 00510 00511 protected: 00512 00513 struct TweenInfo 00514 { 00515 // counters for tweening 00516 TweenType m_TweenType; 00517 float m_fTimeLeftInTween; // how far into the tween are we? 00518 float m_fTweenTime; // seconds between Start and End positions/zooms 00519 }; 00520 00521 00522 RageVector3 m_baseRotation; 00523 RageVector3 m_baseScale; 00524 00525 00526 RageVector2 m_size; 00527 TweenState m_current; 00528 TweenState m_start; 00529 struct TweenStateAndInfo 00530 { 00531 TweenState state; 00532 TweenInfo info; 00533 }; 00534 deque<TweenStateAndInfo> m_Tweens; // use deque for contant time delete of the head 00535 00536 TweenState& LatestTween() { ASSERT(m_Tweens.size()>0); return m_Tweens.back().state; }; 00537 00538 // 00539 // Temporary variables that are filled just before drawing 00540 // 00541 TweenState m_tempState; 00542 TweenState *m_pTempState; 00543 00544 bool m_bFirstUpdate; 00545 00546 // 00547 // Stuff for alignment 00548 // 00549 HorizAlign m_HorizAlign; 00550 VertAlign m_VertAlign; 00551 00552 00553 // 00554 // Stuff for effects 00555 // 00556 Effect m_Effect; 00557 float m_fSecsIntoEffect, m_fEffectDelta; 00558 float m_fEffectPeriodSeconds; 00559 float m_fEffectDelay; 00560 float m_fEffectOffset; 00561 EffectClock m_EffectClock; 00562 00563 /* This can be used in lieu of the fDeltaTime parameter to Update() to 00564 * follow the effect clock. Actor::Update must be called first. */ 00565 float GetEffectDeltaTime() const { return m_fEffectDelta; } 00566 00567 RageColor m_effectColor1; 00568 RageColor m_effectColor2; 00569 RageVector3 m_vEffectMagnitude; 00570 00571 00572 // 00573 // other properties 00574 // 00575 bool m_bHidden; 00576 float m_fHibernateSecondsLeft; 00577 float m_fShadowLength; // 0 == no shadow 00578 bool m_bIsAnimating; 00579 int m_iDrawOrder; 00580 00581 // 00582 // render states 00583 // 00584 bool m_bTextureWrapping; 00585 BlendMode m_BlendMode; 00586 bool m_bClearZBuffer; 00587 ZTestMode m_ZTestMode; 00588 bool m_bZWrite; 00589 CullMode m_CullMode; 00590 00591 // 00592 // global state 00593 // 00594 static float g_fCurrentBGMTime, g_fCurrentBGMBeat; 00595 00596 // 00597 // commands 00598 // 00599 map<CString, apActorCommands> m_mapNameToCommands; 00600 }; 00601 00602 #endif 00603 00604 /* 00605 * (c) 2001-2004 Chris Danford 00606 * All rights reserved. 00607 * 00608 * Permission is hereby granted, free of charge, to any person obtaining a 00609 * copy of this software and associated documentation files (the 00610 * "Software"), to deal in the Software without restriction, including 00611 * without limitation the rights to use, copy, modify, merge, publish, 00612 * distribute, and/or sell copies of the Software, and to permit persons to 00613 * whom the Software is furnished to do so, provided that the above 00614 * copyright notice(s) and this permission notice appear in all copies of 00615 * the Software and that both the above copyright notice(s) and this 00616 * permission notice appear in supporting documentation. 00617 * 00618 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00619 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00620 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00621 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00622 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00623 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00624 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00625 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00626 * PERFORMANCE OF THIS SOFTWARE. 00627 */

Generated on Thu Jan 27 20:57:17 2005 for StepMania by doxygen 1.3.7