From 7879b119a41e7717d77565e47f79ac2552ebd8c3 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 11 Dec 2001 11:44:26 +0000 Subject: [PATCH] no message --- stepmania/src/ActorFrame.cpp | 126 +++++++++++++++++++++++++++++++++++ stepmania/src/ActorFrame.h | 93 ++++++++++++++++++++++++++ stepmania/src/Background.cpp | 2 +- 3 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 stepmania/src/ActorFrame.cpp create mode 100644 stepmania/src/ActorFrame.h diff --git a/stepmania/src/ActorFrame.cpp b/stepmania/src/ActorFrame.cpp new file mode 100644 index 0000000000..7b9706b636 --- /dev/null +++ b/stepmania/src/ActorFrame.cpp @@ -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 +#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; iSetTransform( 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; iUpdate(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; } + + diff --git a/stepmania/src/ActorFrame.h b/stepmania/src/ActorFrame.h new file mode 100644 index 0000000000..6a4eb2a718 --- /dev/null +++ b/stepmania/src/ActorFrame.h @@ -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 + +#include "Actor.h" + + +class ActorFrame +{ +protected: + CArray 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; iRestore(); }; + void Invalidate() { for(int i=0; iInvalidate(); }; + + 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; iSetDiffuseColor(colorDiffuse); }; + void SetAddColor( D3DXCOLOR colorAdd ) { for(int i=0; iSetAddColor(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 \ No newline at end of file diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index 024c3da994..0dbc0979b8 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -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 );