no message

This commit is contained in:
Chris Danford
2001-12-11 11:44:26 +00:00
parent ffd50d9087
commit 7879b119a4
3 changed files with 220 additions and 1 deletions
+126
View File
@@ -0,0 +1,126 @@
#include "stdafx.h" // testing updates
/*
-----------------------------------------------------------------------------
File: ActorFrame.h
Desc: Base class for all objects that appear on the screen.
Copyright (c) 2001 Chris Danford. All rights reserved.
-----------------------------------------------------------------------------
*/
#include "ActorFrame.h"
#include <math.h>
#include "RageScreen.h"
ActorFrame::ActorFrame()
{
m_pos = m_start_pos = m_end_pos = D3DXVECTOR2( 0, 0 );
m_rotation = m_start_rotation = m_end_rotation = D3DXVECTOR3( 0, 0, 0 );
m_scale = m_start_scale = m_end_scale = D3DXVECTOR2( 1, 1 );
m_TweenType = no_tween;
m_fTweenTime = 0.0f;
m_fTimeIntoTween = 0.0f;
}
void ActorFrame::Draw()
{
D3DXVECTOR2 pos = m_pos;
D3DXVECTOR3 rotation = m_rotation;
D3DXVECTOR2 scale = m_scale;
LPDIRECT3DDEVICE8 pd3dDevice = SCREEN->GetDevice();
// calculate and apply world transform
D3DXMATRIX matOriginalWorld, matNewWorld, matTemp;
pd3dDevice->GetTransform( D3DTS_WORLD, &matOriginalWorld ); // save the original world matrix
matNewWorld = matOriginalWorld; // initialize the matrix we're about to build to transform into this Frame's coord space
D3DXMatrixTranslation( &matTemp, pos.x, pos.y, 0 ); // add in the translation
matNewWorld = matTemp * matNewWorld;
D3DXMatrixScaling( &matTemp, scale.x, scale.y, 1 ); // add in the zoom
matNewWorld = matTemp * matNewWorld;
D3DXMatrixRotationYawPitchRoll( &matTemp, rotation.y, rotation.x, rotation.z ); // add in the rotation
matNewWorld = matTemp * matNewWorld;
pd3dDevice->SetTransform( D3DTS_WORLD, &matNewWorld ); // apply the translation so we're in this ActorFrame's local coords
// draw all sub-actors while we're in the frame's local coordinate space
for( int i=0; i<m_SubActors.GetSize(); i++ ) {
// pd3dDevice->SetTransform( D3DTS_WORLD, &matNewWorld ); // apply the translation so we're in this ActorFrame's local coords
m_SubActors[i]->Draw();
}
pd3dDevice->SetTransform( D3DTS_WORLD, &matOriginalWorld ); // restore the original world matrix
}
void ActorFrame::Update( float fDeltaTime )
{
// RageLog( "ActorFrame::Update( %f )", fDeltaTime )
// update tweening
if( m_TweenType != no_tween ) // we are performing some type of tweening
{
m_fTimeIntoTween += fDeltaTime;
if( m_fTimeIntoTween > m_fTweenTime ) // The tweening is over. Stop the tweening
{
m_pos = m_end_pos;
m_scale = m_end_scale;
m_rotation = m_end_rotation;
m_TweenType = no_tween;
}
else // Tweening. Recalcute the curent position.
{
float fPercentThroughTween = m_fTimeIntoTween / m_fTweenTime;
// distort the percentage if appropriate
if( m_TweenType == tween_bias_begin )
fPercentThroughTween = (float) sqrt( fPercentThroughTween );
else if( m_TweenType == tweening_bias_end )
fPercentThroughTween = fPercentThroughTween * fPercentThroughTween;
m_pos = m_start_pos + (m_end_pos - m_start_pos )*fPercentThroughTween;
m_scale = m_start_scale + (m_end_scale - m_start_scale )*fPercentThroughTween;
m_rotation = m_start_rotation+ (m_end_rotation - m_start_rotation)*fPercentThroughTween;
}
} // end if m_TweenType != no_tween
// update all sub-actors
for( int i=0; i<m_SubActors.GetSize(); i++ )
m_SubActors[i]->Update(fDeltaTime);
}
void ActorFrame::BeginTweening( float time, TweenType tt )
{
// set our tweeen starting and ending values to the current position
m_start_pos = m_end_pos = m_pos;
m_start_scale = m_end_scale = m_scale;
m_start_rotation = m_end_rotation = m_rotation;
m_TweenType = tt;
m_fTweenTime = time;
m_fTimeIntoTween = 0;
}
void ActorFrame::SetTweenX( float x ) { m_end_pos.x = x; }
void ActorFrame::SetTweenY( float y ) { m_end_pos.y = y; }
void ActorFrame::SetTweenXY( float x, float y ) { SetTweenX(x); SetTweenY(y); }
void ActorFrame::SetTweenZoom( float zoom ) { m_end_scale.x = zoom; m_end_scale.y = zoom; }
void ActorFrame::SetTweenRotationX( float r ) { m_end_rotation.x = r; }
void ActorFrame::SetTweenRotationY( float r ) { m_end_rotation.y = r; }
void ActorFrame::SetTweenRotationZ( float r ) { m_end_rotation.z = r; }
+93
View File
@@ -0,0 +1,93 @@
/*
-----------------------------------------------------------------------------
File: ActorFrame.h
Desc: Base class for all objects that appear on the screen.
Copyright (c) 2001 Chris Danford. All rights reserved.
-----------------------------------------------------------------------------
*/
#ifndef _ActorFrame_H_
#define _ActorFrame_H_
#include "RageUtil.h"
#include <d3dx8math.h>
#include "Actor.h"
class ActorFrame
{
protected:
CArray<Actor*,Actor*> m_SubActors;
public:
ActorFrame();
void AddActor( Actor* pActor ) { m_SubActors.Add(pActor); };
enum TweenType { no_tween, tween_linear, tween_bias_begin, tweening_bias_end };
// let subclasses override
void Restore() { for(int i=0; i<m_SubActors.GetSize(); i++) m_SubActors[i]->Restore(); };
void Invalidate() { for(int i=0; i<m_SubActors.GetSize(); i++) m_SubActors[i]->Invalidate(); };
void Draw();
void Update( float fDeltaTime );
float GetX() { return m_pos.x; };
float GetY() { return m_pos.y; };
void SetX( float x ) { m_pos.x = x; m_TweenType = no_tween; };
void SetY( float y ) { m_pos.y = y; m_TweenType = no_tween; };
void SetXY( float x, float y ) { m_pos.x = x; m_pos.y = y; m_TweenType = no_tween; };
float GetZoom() { return m_scale.x; }
void SetZoom( float zoom ) { m_scale.x = zoom; m_scale.y = zoom; }
float GetRotation() { return m_rotation.z; }
void SetRotation( float rot ) { m_rotation.z = rot; }
float GetRotationX() { return m_rotation.x; }
void SetRotationX( float rot ) { m_rotation.x = rot; }
float GetRotationY() { return m_rotation.y; }
void SetRotationY( float rot ) { m_rotation.y = rot; }
void SetDiffuseColor( D3DXCOLOR colorDiffuse ) { for(int i=0; i<m_SubActors.GetSize(); i++) m_SubActors[i]->SetDiffuseColor(colorDiffuse); };
void SetAddColor( D3DXCOLOR colorAdd ) { for(int i=0; i<m_SubActors.GetSize(); i++) m_SubActors[i]->SetAddColor(colorAdd); };
void BeginTweening( float time, TweenType tt = tween_linear );
void SetTweenX( float x );
void SetTweenY( float y );
void SetTweenXY( float x, float y );
void SetTweenZoom( float zoom );
void SetTweenRotationX( float r );
void SetTweenRotationY( float r );
void SetTweenRotationZ( float r );
void SetTweenDiffuseColor( D3DXCOLOR c );
void SetTweenAddColor( D3DXCOLOR c );
protected:
D3DXVECTOR2 m_pos; // X-Y coordinate of where the center point will appear on screen
D3DXVECTOR3 m_rotation; // X, Y, and Z m_rotation
D3DXVECTOR2 m_scale; // X and Y zooming
// start and end position for tweening
D3DXVECTOR2 m_start_pos, m_end_pos;
D3DXVECTOR3 m_start_rotation, m_end_rotation;
D3DXVECTOR2 m_start_scale, m_end_scale;
// counters for tweening
TweenType m_TweenType;
float m_fTweenTime; // seconds between Start and End positions/zooms
float m_fTimeIntoTween; // how long we have been tweening for
};
#endif
+1 -1
View File
@@ -35,7 +35,7 @@ void Background::LoadFromSong( Song& song )
}
}
void Background::Update( const FLOAT& fDeltaTime)
void Background::Update( float fDeltaTime)
{
Sprite::Update( fDeltaTime );
m_sprVis.Update( fDeltaTime );