2001-11-03 10:52:42 +00:00
|
|
|
#include "stdafx.h" // testing updates
|
2001-11-04 19:34:28 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
2002-05-19 01:59:48 +00:00
|
|
|
Class: Actor
|
2001-11-04 19:34:28 +00:00
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
Desc: See header.
|
2001-11-04 19:34:28 +00:00
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
2001-11-04 19:34:28 +00:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
2001-11-03 10:52:42 +00:00
|
|
|
|
|
|
|
|
#include "Actor.h"
|
|
|
|
|
#include <math.h>
|
2002-05-19 01:59:48 +00:00
|
|
|
#include "RageDisplay.h"
|
2002-03-30 20:00:13 +00:00
|
|
|
#include "PrefsManager.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
2001-11-03 10:52:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Actor::Actor()
|
|
|
|
|
{
|
2003-01-10 02:22:07 +00:00
|
|
|
m_bFirstUpdate = true;
|
|
|
|
|
|
2002-05-28 20:01:22 +00:00
|
|
|
m_iNumTweenStates = 0;
|
|
|
|
|
|
2003-02-06 07:32:57 +00:00
|
|
|
m_baseRotation = RageVector3( 0, 0, 0 );
|
|
|
|
|
m_baseScale = RageVector3( 1, 1, 1 );
|
2002-10-28 05:30:45 +00:00
|
|
|
m_size = RageVector2( 1, 1 );
|
2002-09-02 21:59:58 +00:00
|
|
|
|
|
|
|
|
m_start.Init();
|
|
|
|
|
m_current.Init();
|
2002-03-30 20:00:13 +00:00
|
|
|
|
|
|
|
|
m_HorizAlign = align_center;
|
|
|
|
|
m_VertAlign = align_middle;
|
|
|
|
|
|
|
|
|
|
m_Effect = no_effect ;
|
|
|
|
|
m_fPercentBetweenColors = 0.0f;
|
|
|
|
|
m_bTweeningTowardEndColor = true;
|
|
|
|
|
m_fDeltaPercentPerSecond = 1.0f;
|
|
|
|
|
m_fWagRadians = 0.2f;
|
|
|
|
|
m_fWagPeriod = 2.0f;
|
|
|
|
|
m_fWagTimer = 0.0f;
|
2002-10-28 05:30:45 +00:00
|
|
|
m_vSpinVelocity = RageVector3(0,0,0);
|
2002-03-30 20:00:13 +00:00
|
|
|
m_fVibrationDistance = 5.0f;
|
2002-12-17 21:15:47 +00:00
|
|
|
m_bVisibleThisFrame = false;
|
2002-03-30 20:00:13 +00:00
|
|
|
|
2002-05-01 19:14:55 +00:00
|
|
|
m_bShadow = false;
|
2002-04-16 17:31:00 +00:00
|
|
|
m_fShadowLength = 4;
|
2002-03-30 20:00:13 +00:00
|
|
|
|
|
|
|
|
m_bBlendAdd = false;
|
2002-05-28 20:01:22 +00:00
|
|
|
|
2001-11-03 10:52:42 +00:00
|
|
|
}
|
|
|
|
|
|
2002-08-19 20:02:30 +00:00
|
|
|
void Actor::Draw()
|
|
|
|
|
{
|
|
|
|
|
// call the most-derived versions
|
|
|
|
|
this->BeginDraw();
|
|
|
|
|
this->DrawPrimitives(); // call the most-derived version of DrawPrimitives();
|
|
|
|
|
this->EndDraw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Actor::BeginDraw() // set the world matrix and calculate actor properties
|
2001-11-28 20:26:45 +00:00
|
|
|
{
|
2002-05-19 01:59:48 +00:00
|
|
|
DISPLAY->PushMatrix(); // we're actually going to do some drawing in this function
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2002-03-30 20:00:13 +00:00
|
|
|
int i;
|
2002-09-02 21:59:58 +00:00
|
|
|
|
|
|
|
|
m_temp = m_current;
|
2002-03-30 20:00:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// set temporary drawing properties based on Effects
|
|
|
|
|
//
|
2001-11-28 20:26:45 +00:00
|
|
|
switch( m_Effect )
|
|
|
|
|
{
|
|
|
|
|
case no_effect:
|
|
|
|
|
break;
|
|
|
|
|
case blinking:
|
2002-03-30 20:00:13 +00:00
|
|
|
for(i=0; i<4; i++)
|
2002-09-02 21:59:58 +00:00
|
|
|
m_temp.diffuse[i] = m_bTweeningTowardEndColor ? m_effect_colorDiffuse1 : m_effect_colorDiffuse2;
|
2001-11-28 20:26:45 +00:00
|
|
|
break;
|
|
|
|
|
case camelion:
|
2002-03-30 20:00:13 +00:00
|
|
|
for(i=0; i<4; i++)
|
2002-09-02 21:59:58 +00:00
|
|
|
m_temp.diffuse[i] = m_effect_colorDiffuse1*m_fPercentBetweenColors + m_effect_colorDiffuse2*(1.0f-m_fPercentBetweenColors);
|
2001-11-28 20:26:45 +00:00
|
|
|
break;
|
|
|
|
|
case glowing:
|
2002-04-01 02:04:43 +00:00
|
|
|
float fCurvedPercent;
|
2002-10-28 05:30:45 +00:00
|
|
|
fCurvedPercent = sinf( m_fPercentBetweenColors * PI );
|
2002-09-02 21:59:58 +00:00
|
|
|
m_temp.glow = m_effect_colorGlow1*fCurvedPercent + m_effect_colorGlow2*(1.0f-fCurvedPercent);
|
2001-11-28 20:26:45 +00:00
|
|
|
break;
|
|
|
|
|
case wagging:
|
2002-09-02 21:59:58 +00:00
|
|
|
m_temp.rotation.z = m_fWagRadians * sinf(
|
2001-11-28 20:26:45 +00:00
|
|
|
(m_fWagTimer / m_fWagPeriod) // percent through wag
|
2002-10-28 05:30:45 +00:00
|
|
|
* 2.0f * PI );
|
2001-11-28 20:26:45 +00:00
|
|
|
break;
|
|
|
|
|
case spinning:
|
2002-09-02 21:59:58 +00:00
|
|
|
// nothing needs to be here
|
2001-11-28 20:26:45 +00:00
|
|
|
break;
|
|
|
|
|
case vibrating:
|
2002-09-02 21:59:58 +00:00
|
|
|
m_temp.pos.x += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom();
|
|
|
|
|
m_temp.pos.y += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom();
|
2001-11-28 20:26:45 +00:00
|
|
|
break;
|
|
|
|
|
case flickering:
|
2002-03-30 20:00:13 +00:00
|
|
|
m_bVisibleThisFrame = !m_bVisibleThisFrame;
|
|
|
|
|
if( !m_bVisibleThisFrame )
|
|
|
|
|
for(int i=0; i<4; i++)
|
2002-10-28 05:30:45 +00:00
|
|
|
m_temp.diffuse[i] = RageColor(0,0,0,0); // don't draw the frame
|
2001-11-28 20:26:45 +00:00
|
|
|
break;
|
2002-01-16 10:01:32 +00:00
|
|
|
case bouncing:
|
2002-03-30 20:00:13 +00:00
|
|
|
{
|
2002-01-16 10:01:32 +00:00
|
|
|
float fPercentThroughBounce = m_fTimeIntoBounce / m_fBouncePeriod;
|
2002-10-28 05:30:45 +00:00
|
|
|
float fPercentOffset = sinf( fPercentThroughBounce*PI );
|
2002-09-02 21:59:58 +00:00
|
|
|
m_temp.pos += m_vectBounce * fPercentOffset;
|
2002-03-30 20:00:13 +00:00
|
|
|
}
|
2002-01-16 10:01:32 +00:00
|
|
|
break;
|
2002-07-27 19:29:51 +00:00
|
|
|
case bobbing:
|
|
|
|
|
{
|
|
|
|
|
float fPercentThroughBounce = m_fTimeIntoBounce / m_fBouncePeriod;
|
2002-10-28 05:30:45 +00:00
|
|
|
float fPercentOffset = sinf( fPercentThroughBounce*PI*2 );
|
2002-09-02 21:59:58 +00:00
|
|
|
m_temp.pos += m_vectBounce * fPercentOffset;
|
2002-07-27 19:29:51 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2002-03-30 20:00:13 +00:00
|
|
|
default:
|
2002-07-27 19:29:51 +00:00
|
|
|
ASSERT(0); // invalid Effect
|
2001-11-28 20:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
2002-03-30 20:00:13 +00:00
|
|
|
|
2003-02-06 07:32:57 +00:00
|
|
|
m_temp.scale.x *= m_baseScale.x;
|
|
|
|
|
m_temp.scale.y *= m_baseScale.y;
|
|
|
|
|
m_temp.scale.z *= m_baseScale.z;
|
|
|
|
|
m_temp.rotation.x += m_baseRotation.x;
|
|
|
|
|
m_temp.rotation.y += m_baseRotation.y;
|
|
|
|
|
m_temp.rotation.z += m_baseRotation.z;
|
2001-11-28 20:26:45 +00:00
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2003-02-06 07:32:57 +00:00
|
|
|
DISPLAY->Translate( m_temp.pos.x, m_temp.pos.y, m_temp.pos.z );
|
|
|
|
|
DISPLAY->Scale( m_temp.scale.x, m_temp.scale.y, m_temp.scale.z );
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2002-09-02 21:59:58 +00:00
|
|
|
if( m_temp.rotation.x != 0 ) DISPLAY->RotateX( m_temp.rotation.x );
|
|
|
|
|
if( m_temp.rotation.y != 0 ) DISPLAY->RotateY( m_temp.rotation.y );
|
|
|
|
|
if( m_temp.rotation.z != 0 ) DISPLAY->RotateZ( m_temp.rotation.z );
|
2002-08-19 20:02:30 +00:00
|
|
|
}
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2002-08-19 20:02:30 +00:00
|
|
|
void Actor::EndDraw()
|
|
|
|
|
{
|
2002-05-19 01:59:48 +00:00
|
|
|
DISPLAY->PopMatrix();
|
2001-11-28 20:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-04 21:53:43 +00:00
|
|
|
void Actor::UpdateTweening( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
// update tweening
|
2002-12-19 22:10:28 +00:00
|
|
|
if( m_iNumTweenStates == 0 )
|
2002-09-04 21:53:43 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// we are performing a tween
|
|
|
|
|
TweenState &TS = m_TweenStates[0]; // earliest tween
|
|
|
|
|
TweenInfo &TI = m_TweenInfo[0]; // earliest tween
|
|
|
|
|
|
|
|
|
|
if( TI.m_fTimeLeftInTween == TI.m_fTweenTime ) // we are just beginning this tween
|
|
|
|
|
{
|
|
|
|
|
// set the start position
|
|
|
|
|
m_start = m_current;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TI.m_fTimeLeftInTween -= fDeltaTime;
|
|
|
|
|
|
|
|
|
|
if( TI.m_fTimeLeftInTween <= 0 ) // The tweening is over. Stop the tweening
|
|
|
|
|
{
|
|
|
|
|
m_current = TS;
|
|
|
|
|
|
|
|
|
|
// delete the head tween
|
|
|
|
|
for( int i=0; i<m_iNumTweenStates-1; i++ )
|
|
|
|
|
{
|
|
|
|
|
m_TweenStates[i] = m_TweenStates[i+1];
|
|
|
|
|
m_TweenInfo[i] = m_TweenInfo[i+1];
|
|
|
|
|
}
|
|
|
|
|
m_iNumTweenStates--;
|
|
|
|
|
}
|
|
|
|
|
else // in the middle of tweening. Recalcute the current position.
|
|
|
|
|
{
|
|
|
|
|
const float fPercentThroughTween = 1-(TI.m_fTimeLeftInTween / TI.m_fTweenTime);
|
|
|
|
|
|
|
|
|
|
// distort the percentage if appropriate
|
2002-09-07 10:11:00 +00:00
|
|
|
float fPercentAlongPath = 0.f;
|
2002-09-04 21:53:43 +00:00
|
|
|
switch( TI.m_TweenType )
|
|
|
|
|
{
|
2002-10-28 05:30:45 +00:00
|
|
|
case TWEEN_LINEAR: fPercentAlongPath = fPercentThroughTween; break;
|
|
|
|
|
case TWEEN_BIAS_BEGIN: fPercentAlongPath = 1 - (1-fPercentThroughTween) * (1-fPercentThroughTween); break;
|
|
|
|
|
case TWEEN_BIAS_END: fPercentAlongPath = fPercentThroughTween * fPercentThroughTween; break;
|
|
|
|
|
case TWEEN_BOUNCE_BEGIN:fPercentAlongPath = 1 - sinf( 1.1f + fPercentThroughTween*(PI-1.1f) ) / 0.89f; break;
|
|
|
|
|
case TWEEN_BOUNCE_END: fPercentAlongPath = sinf( 1.1f + (1-fPercentThroughTween)*(PI-1.1f) ) / 0.89f; break;
|
|
|
|
|
case TWEEN_SPRING: fPercentAlongPath = 1 - cosf( fPercentThroughTween*PI*2.5f )/(1+fPercentThroughTween*3); break;
|
2002-09-04 21:53:43 +00:00
|
|
|
default: ASSERT(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_current.pos = m_start.pos + (TS.pos - m_start.pos )*fPercentAlongPath;
|
|
|
|
|
m_current.scale = m_start.scale + (TS.scale - m_start.scale )*fPercentAlongPath;
|
|
|
|
|
m_current.rotation = m_start.rotation+ (TS.rotation - m_start.rotation)*fPercentAlongPath;
|
|
|
|
|
for(int i=0; i<4; i++)
|
|
|
|
|
m_current.diffuse[i]= m_start.diffuse[i]*(1.0f-fPercentAlongPath) + TS.diffuse[i]*(fPercentAlongPath);
|
|
|
|
|
m_current.glow = m_start.glow *(1.0f-fPercentAlongPath) + TS.glow *(fPercentAlongPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-11-28 20:26:45 +00:00
|
|
|
|
2003-01-10 02:22:07 +00:00
|
|
|
bool Actor::IsFirstUpdate()
|
|
|
|
|
{
|
|
|
|
|
return m_bFirstUpdate;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
void Actor::Update( float fDeltaTime )
|
2001-11-03 10:52:42 +00:00
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
// LOG->Trace( "Actor::Update( %f )", fDeltaTime );
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2001-11-28 20:26:45 +00:00
|
|
|
// update effect
|
|
|
|
|
switch( m_Effect )
|
|
|
|
|
{
|
|
|
|
|
case no_effect:
|
|
|
|
|
break;
|
|
|
|
|
case blinking:
|
|
|
|
|
case camelion:
|
|
|
|
|
case glowing:
|
|
|
|
|
if( m_bTweeningTowardEndColor ) {
|
|
|
|
|
m_fPercentBetweenColors += m_fDeltaPercentPerSecond * fDeltaTime;
|
|
|
|
|
if( m_fPercentBetweenColors > 1.0f ) {
|
|
|
|
|
m_fPercentBetweenColors = 1.0f;
|
2001-11-29 06:49:26 +00:00
|
|
|
|
2002-12-17 21:15:47 +00:00
|
|
|
m_bTweeningTowardEndColor = false;
|
2001-11-28 20:26:45 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else { // !m_bTweeningTowardEndColor
|
|
|
|
|
m_fPercentBetweenColors -= m_fDeltaPercentPerSecond * fDeltaTime;
|
|
|
|
|
if( m_fPercentBetweenColors < 0.0f ) {
|
|
|
|
|
m_fPercentBetweenColors = 0.0f;
|
2002-12-17 21:15:47 +00:00
|
|
|
m_bTweeningTowardEndColor = true;
|
2001-11-28 20:26:45 +00:00
|
|
|
}
|
|
|
|
|
}
|
2002-07-31 19:40:40 +00:00
|
|
|
//LOG->Trace( "Actor::m_fPercentBetweenColors %f", m_fPercentBetweenColors );
|
2001-11-28 20:26:45 +00:00
|
|
|
break;
|
|
|
|
|
case wagging:
|
|
|
|
|
m_fWagTimer += fDeltaTime;
|
|
|
|
|
if( m_fWagTimer > m_fWagPeriod )
|
|
|
|
|
m_fWagTimer -= m_fWagPeriod;
|
|
|
|
|
break;
|
|
|
|
|
case spinning:
|
2002-09-02 21:59:58 +00:00
|
|
|
m_current.rotation += m_vSpinVelocity;
|
2002-10-28 05:30:45 +00:00
|
|
|
if( m_current.rotation.x > 1000*PI*2 ) m_current.rotation.x -= 1000*PI*2;
|
|
|
|
|
if( m_current.rotation.y > 1000*PI*2 ) m_current.rotation.y -= 1000*PI*2;
|
|
|
|
|
if( m_current.rotation.z > 1000*PI*2 ) m_current.rotation.z -= 1000*PI*2;
|
2001-11-28 20:26:45 +00:00
|
|
|
break;
|
|
|
|
|
case vibrating:
|
|
|
|
|
break;
|
|
|
|
|
case flickering:
|
|
|
|
|
break;
|
2002-01-16 10:01:32 +00:00
|
|
|
case bouncing:
|
2002-07-27 19:29:51 +00:00
|
|
|
case bobbing:
|
2002-01-16 10:01:32 +00:00
|
|
|
m_fTimeIntoBounce += fDeltaTime;
|
|
|
|
|
if( m_fTimeIntoBounce >= m_fBouncePeriod )
|
|
|
|
|
m_fTimeIntoBounce -= m_fBouncePeriod;
|
|
|
|
|
break;
|
2001-11-28 20:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-04 21:53:43 +00:00
|
|
|
UpdateTweening( fDeltaTime );
|
2003-01-19 04:44:22 +00:00
|
|
|
|
|
|
|
|
if( m_bFirstUpdate )
|
|
|
|
|
m_bFirstUpdate = false;
|
2001-11-03 10:52:42 +00:00
|
|
|
}
|
|
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
void Actor::BeginTweening( float time, TweenType tt )
|
2001-11-03 10:52:42 +00:00
|
|
|
{
|
2002-04-16 17:31:00 +00:00
|
|
|
ASSERT( time >= 0 );
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
// HACK to keep from out of bounds access..
|
|
|
|
|
if( m_iNumTweenStates == MAX_TWEEN_STATES )
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; i<m_iNumTweenStates-1; i++ )
|
|
|
|
|
{
|
|
|
|
|
m_TweenStates[i] = m_TweenStates[i+1];
|
|
|
|
|
m_TweenInfo[i] = m_TweenInfo[i+1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-09 06:19:40 +00:00
|
|
|
// add a new TweenState to the tail, and initialize it
|
2002-05-28 20:01:22 +00:00
|
|
|
m_iNumTweenStates++;
|
2002-09-02 21:59:58 +00:00
|
|
|
TweenState &TS = m_TweenStates[m_iNumTweenStates-1]; // latest
|
|
|
|
|
TweenInfo &TI = m_TweenInfo[m_iNumTweenStates-1]; // latest
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2002-05-28 20:01:22 +00:00
|
|
|
if( m_iNumTweenStates >= 2 ) // if there was already a TS on the stack
|
2002-03-09 06:19:40 +00:00
|
|
|
{
|
|
|
|
|
// initialize the new TS from the last TS in the list
|
2002-09-02 21:59:58 +00:00
|
|
|
TS = m_TweenStates[m_iNumTweenStates-2];
|
2002-03-09 06:19:40 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// This new TS is the only TS.
|
|
|
|
|
// Set our tween starting and ending values to the current position.
|
2002-09-02 21:59:58 +00:00
|
|
|
TS = m_current;
|
2002-03-09 06:19:40 +00:00
|
|
|
}
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2002-09-02 21:59:58 +00:00
|
|
|
TI.m_TweenType = tt;
|
|
|
|
|
TI.m_fTweenTime = time;
|
|
|
|
|
TI.m_fTimeLeftInTween = time;
|
2001-11-03 10:52:42 +00:00
|
|
|
}
|
|
|
|
|
|
2002-05-28 20:01:22 +00:00
|
|
|
void Actor::StopTweening()
|
|
|
|
|
{
|
|
|
|
|
m_iNumTweenStates = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-09-02 21:59:58 +00:00
|
|
|
void Actor::SetTweenX( float x ) { LatestTween().pos.x = x; }
|
|
|
|
|
void Actor::SetTweenY( float y ) { LatestTween().pos.y = y; }
|
|
|
|
|
void Actor::SetTweenZ( float z ) { LatestTween().pos.z = z; }
|
|
|
|
|
void Actor::SetTweenXY( float x, float y ) { LatestTween().pos.x = x; LatestTween().pos.y = y; }
|
|
|
|
|
void Actor::SetTweenZoom( float zoom ) { LatestTween().scale.x = zoom; LatestTween().scale.y = zoom; }
|
|
|
|
|
void Actor::SetTweenZoomX( float zoom ) { LatestTween().scale.x = zoom; }
|
|
|
|
|
void Actor::SetTweenZoomY( float zoom ) { LatestTween().scale.y = zoom; }
|
|
|
|
|
void Actor::SetTweenZoomToWidth( float zoom ) { SetTweenZoomX( zoom/GetUnzoomedWidth() ); }
|
|
|
|
|
void Actor::SetTweenZoomToHeight( float zoom ) { SetTweenZoomX( zoom/GetUnzoomedHeight() ); }
|
|
|
|
|
void Actor::SetTweenRotationX( float r ) { LatestTween().rotation.x = r; }
|
|
|
|
|
void Actor::SetTweenRotationY( float r ) { LatestTween().rotation.y = r; }
|
|
|
|
|
void Actor::SetTweenRotationZ( float r ) { LatestTween().rotation.z = r; }
|
2002-10-28 05:30:45 +00:00
|
|
|
void Actor::SetTweenDiffuse( RageColor c ) { for(int i=0; i<4; i++) LatestTween().diffuse[i] = c; };
|
|
|
|
|
void Actor::SetTweenDiffuseUpperLeft( RageColor c ) { LatestTween().diffuse[0] = c; };
|
|
|
|
|
void Actor::SetTweenDiffuseUpperRight( RageColor c ) { LatestTween().diffuse[1] = c; };
|
|
|
|
|
void Actor::SetTweenDiffuseLowerLeft( RageColor c ) { LatestTween().diffuse[2] = c; };
|
|
|
|
|
void Actor::SetTweenDiffuseLowerRight( RageColor c ) { LatestTween().diffuse[3] = c; };
|
|
|
|
|
void Actor::SetTweenDiffuseTopEdge( RageColor c ) { LatestTween().diffuse[0] = LatestTween().diffuse[1] = c; };
|
|
|
|
|
void Actor::SetTweenDiffuseRightEdge( RageColor c ) { LatestTween().diffuse[1] = LatestTween().diffuse[3] = c; };
|
|
|
|
|
void Actor::SetTweenDiffuseBottomEdge( RageColor c ) { LatestTween().diffuse[2] = LatestTween().diffuse[3] = c; };
|
|
|
|
|
void Actor::SetTweenDiffuseLeftEdge( RageColor c ) { LatestTween().diffuse[0] = LatestTween().diffuse[2] = c; };
|
|
|
|
|
void Actor::SetTweenGlow( RageColor c ) { LatestTween().glow = c; };
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2003-01-16 05:07:54 +00:00
|
|
|
Actor::TweenState Actor::GetDestTweenState()
|
|
|
|
|
{
|
|
|
|
|
if(!m_iNumTweenStates) return m_current;
|
|
|
|
|
return LatestTween();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Actor::SetTweenState( const Actor::TweenState &ts )
|
|
|
|
|
{
|
|
|
|
|
LatestTween() = ts;
|
|
|
|
|
}
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-11-01 20:01:59 +00:00
|
|
|
void Actor::ScaleTo( const RectI &rect, StretchType st )
|
2001-11-03 10:52:42 +00:00
|
|
|
{
|
|
|
|
|
// width and height of rectangle
|
2002-12-17 06:25:03 +00:00
|
|
|
float rect_width = (float) rect.GetWidth();
|
|
|
|
|
float rect_height = (float) rect.GetHeight();
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-10-28 05:30:45 +00:00
|
|
|
if( rect_width < 0 ) SetRotationY( PI );
|
|
|
|
|
if( rect_height < 0 ) SetRotationX( PI );
|
2001-11-25 10:49:31 +00:00
|
|
|
|
2001-11-03 10:52:42 +00:00
|
|
|
// center of the rectangle
|
2002-11-01 20:01:59 +00:00
|
|
|
float rect_cx = rect.left + rect_width/2;
|
|
|
|
|
float rect_cy = rect.top + rect_height/2;
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
// zoom fActor needed to scale the Actor to fill the rectangle
|
2002-02-24 01:43:11 +00:00
|
|
|
float fNewZoomX = fabsf(rect_width / m_size.x);
|
|
|
|
|
float fNewZoomY = fabsf(rect_height / m_size.y);
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-09-07 10:11:00 +00:00
|
|
|
float fNewZoom = 0.f;
|
2001-11-03 10:52:42 +00:00
|
|
|
switch( st )
|
|
|
|
|
{
|
|
|
|
|
case cover:
|
|
|
|
|
fNewZoom = fNewZoomX>fNewZoomY ? fNewZoomX : fNewZoomY; // use larger zoom
|
|
|
|
|
break;
|
|
|
|
|
case fit_inside:
|
|
|
|
|
fNewZoom = fNewZoomX>fNewZoomY ? fNewZoomY : fNewZoomX; // use smaller zoom
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-25 04:31:44 +00:00
|
|
|
SetXY( rect_cx, rect_cy );
|
2001-11-03 10:52:42 +00:00
|
|
|
SetZoom( fNewZoom );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-11-01 20:01:59 +00:00
|
|
|
void Actor::StretchTo( const RectI &rect )
|
2001-11-03 10:52:42 +00:00
|
|
|
{
|
|
|
|
|
// width and height of rectangle
|
2002-12-17 06:25:03 +00:00
|
|
|
int rect_width = rect.GetWidth();
|
|
|
|
|
int rect_height = rect.GetHeight();
|
2001-11-03 10:52:42 +00:00
|
|
|
|
|
|
|
|
// center of the rectangle
|
2002-11-01 20:01:59 +00:00
|
|
|
float rect_cx = rect.left + rect_width/2.0f;
|
|
|
|
|
float rect_cy = rect.top + rect_height/2.0f;
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
// zoom fActor needed to scale the Actor to fill the rectangle
|
|
|
|
|
float fNewZoomX = rect_width / m_size.x;
|
|
|
|
|
float fNewZoomY = rect_height / m_size.y;
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2001-11-28 20:26:45 +00:00
|
|
|
SetXY( (float)rect_cx, (float)rect_cy );
|
2002-01-16 10:01:32 +00:00
|
|
|
SetZoomX( fNewZoomX );
|
|
|
|
|
SetZoomY( fNewZoomY );
|
2001-11-03 10:52:42 +00:00
|
|
|
}
|
2001-11-28 20:26:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// effects
|
|
|
|
|
|
|
|
|
|
void Actor::SetEffectNone()
|
|
|
|
|
{
|
|
|
|
|
m_Effect = no_effect;
|
2002-10-28 05:30:45 +00:00
|
|
|
//m_color = RageColor( 1.0,1.0,1.0,1.0 );
|
2001-11-28 20:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
2002-10-28 05:30:45 +00:00
|
|
|
void Actor::SetEffectBlinking( float fDeltaPercentPerSecond, RageColor Color, RageColor Color2 )
|
2001-11-28 20:26:45 +00:00
|
|
|
{
|
|
|
|
|
m_Effect = blinking;
|
2002-01-16 10:01:32 +00:00
|
|
|
m_effect_colorDiffuse1 = Color;
|
|
|
|
|
m_effect_colorDiffuse2 = Color2;
|
|
|
|
|
|
2001-11-28 20:26:45 +00:00
|
|
|
m_fDeltaPercentPerSecond = fDeltaPercentPerSecond;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-28 05:30:45 +00:00
|
|
|
void Actor::SetEffectCamelion( float fDeltaPercentPerSecond, RageColor Color, RageColor Color2 )
|
2001-11-28 20:26:45 +00:00
|
|
|
{
|
|
|
|
|
m_Effect = camelion;
|
2002-01-16 10:01:32 +00:00
|
|
|
m_effect_colorDiffuse1 = Color;
|
|
|
|
|
m_effect_colorDiffuse2 = Color2;
|
|
|
|
|
|
2001-11-28 20:26:45 +00:00
|
|
|
m_fDeltaPercentPerSecond = fDeltaPercentPerSecond;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-28 05:30:45 +00:00
|
|
|
void Actor::SetEffectGlowing( float fDeltaPercentPerSecond, RageColor Color, RageColor Color2 )
|
2001-11-28 20:26:45 +00:00
|
|
|
{
|
|
|
|
|
m_Effect = glowing;
|
2002-08-18 16:19:26 +00:00
|
|
|
m_effect_colorGlow1 = Color;
|
|
|
|
|
m_effect_colorGlow2 = Color2;
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2001-11-28 20:26:45 +00:00
|
|
|
m_fDeltaPercentPerSecond = fDeltaPercentPerSecond;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Actor::SetEffectWagging( float fWagRadians, float fWagPeriod )
|
|
|
|
|
{
|
|
|
|
|
m_Effect = wagging;
|
|
|
|
|
m_fWagRadians = fWagRadians;
|
|
|
|
|
m_fWagPeriod = fWagPeriod;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-28 05:30:45 +00:00
|
|
|
void Actor::SetEffectSpinning( RageVector3 vectRotationVelocity )
|
2001-11-28 20:26:45 +00:00
|
|
|
{
|
|
|
|
|
m_Effect = spinning;
|
2002-09-02 21:59:58 +00:00
|
|
|
m_vSpinVelocity = vectRotationVelocity;
|
2001-11-28 20:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Actor::SetEffectVibrating( float fVibrationDistance )
|
|
|
|
|
{
|
|
|
|
|
m_Effect = vibrating;
|
|
|
|
|
m_fVibrationDistance = fVibrationDistance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Actor::SetEffectFlickering()
|
|
|
|
|
{
|
|
|
|
|
m_Effect = flickering;
|
2002-01-16 10:01:32 +00:00
|
|
|
}
|
|
|
|
|
|
2002-10-28 05:30:45 +00:00
|
|
|
void Actor::SetEffectBouncing( RageVector3 vectBounce, float fPeriod )
|
2002-01-16 10:01:32 +00:00
|
|
|
{
|
|
|
|
|
m_Effect = bouncing;
|
|
|
|
|
|
|
|
|
|
m_vectBounce = vectBounce;
|
|
|
|
|
m_fBouncePeriod = fPeriod;
|
|
|
|
|
m_fTimeIntoBounce = 0;
|
|
|
|
|
|
2002-07-27 19:29:51 +00:00
|
|
|
}
|
|
|
|
|
|
2002-10-28 05:30:45 +00:00
|
|
|
void Actor::SetEffectBobbing( RageVector3 vectBob, float fPeriod )
|
2002-07-27 19:29:51 +00:00
|
|
|
{
|
|
|
|
|
m_Effect = bobbing;
|
|
|
|
|
|
|
|
|
|
m_vectBounce = vectBob;
|
|
|
|
|
m_fBouncePeriod = fPeriod;
|
|
|
|
|
m_fTimeIntoBounce = 0;
|
|
|
|
|
|
2002-09-02 21:59:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GetFadeFlagsFromString( CString sFadeString,
|
|
|
|
|
bool& linear, bool& accelerate, bool& bounce, bool& spring,
|
|
|
|
|
bool& foldx, bool& foldy, bool& fade, bool& zoombig, bool& zoomsmall, bool& spinx, bool& spiny, bool& spinz, bool& ghost,
|
|
|
|
|
bool& left, bool& right, bool& top, bool& bottom )
|
|
|
|
|
{
|
|
|
|
|
sFadeString.MakeLower();
|
|
|
|
|
foldx = -1!=sFadeString.Find("foldx");
|
|
|
|
|
foldy = -1!=sFadeString.Find("foldy");
|
|
|
|
|
fade = -1!=sFadeString.Find("fade");
|
|
|
|
|
zoombig = -1!=sFadeString.Find("zoombig");
|
|
|
|
|
zoomsmall = -1!=sFadeString.Find("zoomsmall");
|
|
|
|
|
spinx = -1!=sFadeString.Find("spinx");
|
|
|
|
|
spiny = -1!=sFadeString.Find("spiny");
|
|
|
|
|
spinz = -1!=sFadeString.Find("spinz");
|
|
|
|
|
ghost = -1!=sFadeString.Find("ghost");
|
|
|
|
|
linear = -1!=sFadeString.Find("linear");
|
|
|
|
|
accelerate = -1!=sFadeString.Find("accelerate");
|
|
|
|
|
bounce = -1!=sFadeString.Find("bounce");
|
|
|
|
|
spring = -1!=sFadeString.Find("spring");
|
|
|
|
|
left = -1!=sFadeString.Find("left");
|
|
|
|
|
right = -1!=sFadeString.Find("right");
|
|
|
|
|
top = -1!=sFadeString.Find("top");
|
|
|
|
|
bottom = -1!=sFadeString.Find("bottom");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Actor::Fade( float fSleepSeconds, CString sFadeString, float fFadeSeconds, bool bOnToScreenOrOffOfScreen )
|
|
|
|
|
{
|
|
|
|
|
sFadeString.MakeLower();
|
|
|
|
|
|
|
|
|
|
TweenState original = m_current;
|
|
|
|
|
TweenState mod = m_current;
|
|
|
|
|
|
|
|
|
|
#define CONTAINS(needle) (-1!=sFadeString.Find(needle))
|
|
|
|
|
|
|
|
|
|
TweenType tt;
|
|
|
|
|
if( CONTAINS("linear") ) tt = TWEEN_LINEAR;
|
|
|
|
|
else if( CONTAINS("accelerate") ) tt = TWEEN_BIAS_BEGIN;
|
|
|
|
|
else if( CONTAINS("bounce") ) tt = TWEEN_BOUNCE_END;
|
|
|
|
|
else if( CONTAINS("spring") ) tt = TWEEN_SPRING;
|
|
|
|
|
else tt = TWEEN_LINEAR;
|
|
|
|
|
|
2003-01-26 20:49:05 +00:00
|
|
|
|
|
|
|
|
float fDeltaX = (float)(CONTAINS("left")?-SCREEN_WIDTH:0) + (CONTAINS("right")?+SCREEN_HEIGHT:0);
|
|
|
|
|
float fDeltaY = (float)(CONTAINS("top")?-SCREEN_WIDTH:0) + (CONTAINS("bottom")?+SCREEN_HEIGHT:0);
|
|
|
|
|
float fDeltaZ = (float)0;
|
|
|
|
|
if( CONTAINS("far") )
|
|
|
|
|
{
|
|
|
|
|
fDeltaX *= 2;
|
|
|
|
|
fDeltaY *= 2;
|
|
|
|
|
fDeltaZ *= 2;
|
|
|
|
|
}
|
|
|
|
|
mod.pos.x += fDeltaX;
|
|
|
|
|
mod.pos.y += fDeltaY;
|
|
|
|
|
mod.pos.z += fDeltaZ;
|
2002-10-28 05:30:45 +00:00
|
|
|
mod.rotation.x += (CONTAINS("spinx")?-PI*2:0);
|
|
|
|
|
mod.rotation.y += (CONTAINS("spiny")?-PI*2:0);
|
|
|
|
|
mod.rotation.z += (CONTAINS("spinz")?-PI*2:0);
|
2002-09-02 21:59:58 +00:00
|
|
|
mod.scale.x *= (CONTAINS("foldx")?0:1) * (CONTAINS("zoomx")?3:1);
|
|
|
|
|
mod.scale.y *= (CONTAINS("foldy")?0:1) * (CONTAINS("zoomy")?3:1);
|
|
|
|
|
for( int i=0; i<4; i++ )
|
|
|
|
|
{
|
|
|
|
|
mod.diffuse[i] = GetDiffuse();
|
|
|
|
|
mod.diffuse[i].a *= CONTAINS("fade")?0:1;
|
|
|
|
|
}
|
|
|
|
|
mod.glow = GetGlow();
|
|
|
|
|
mod.glow.a *= CONTAINS("glow")?1:0;
|
|
|
|
|
|
|
|
|
|
|
2003-01-26 20:49:05 +00:00
|
|
|
StopTweening();
|
2002-09-02 21:59:58 +00:00
|
|
|
m_current = bOnToScreenOrOffOfScreen ? original : mod;
|
|
|
|
|
BeginTweening( fSleepSeconds );
|
|
|
|
|
BeginTweening( fFadeSeconds, tt );
|
|
|
|
|
LatestTween() = bOnToScreenOrOffOfScreen ? mod : original;
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-01 09:05:21 +00:00
|
|
|
float Actor::TweenTime() const
|
|
|
|
|
{
|
|
|
|
|
float tot = 0;
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < m_iNumTweenStates; ++i)
|
|
|
|
|
tot += m_TweenInfo[i].m_fTimeLeftInTween;
|
|
|
|
|
|
|
|
|
|
return tot;
|
|
|
|
|
}
|