2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h" // testing updates
|
2001-12-11 11:44:26 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
2002-07-23 01:41:40 +00:00
|
|
|
Class: ActorFrame
|
2001-12-11 11:44:26 +00:00
|
|
|
|
2002-07-23 01:41:40 +00:00
|
|
|
Desc: See header.
|
2001-12-11 11:44:26 +00:00
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
2002-07-23 01:41:40 +00:00
|
|
|
Chris Danford
|
2001-12-11 11:44:26 +00:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ActorFrame.h"
|
|
|
|
|
|
2003-01-11 08:55:21 +00:00
|
|
|
void ActorFrame::AddChild( Actor* pActor )
|
2002-06-14 22:25:22 +00:00
|
|
|
{
|
2003-08-23 22:04:57 +00:00
|
|
|
#if _DEBUG
|
|
|
|
|
// check that this Actor isn't already added.
|
|
|
|
|
vector<Actor*>::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor );
|
|
|
|
|
ASSERT( iter == m_SubActors.end() ); // didn't find
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-07-23 01:41:40 +00:00
|
|
|
ASSERT( pActor );
|
|
|
|
|
ASSERT( (void*)pActor != (void*)0xC0000005 );
|
2002-10-31 04:23:39 +00:00
|
|
|
m_SubActors.push_back( pActor );
|
2002-06-14 22:25:22 +00:00
|
|
|
}
|
2001-12-11 11:44:26 +00:00
|
|
|
|
2003-01-20 05:08:35 +00:00
|
|
|
void ActorFrame::MoveToTail( Actor* pActor )
|
2003-01-11 08:55:21 +00:00
|
|
|
{
|
|
|
|
|
vector<Actor*>::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor );
|
|
|
|
|
if( iter == m_SubActors.end() ) // didn't find
|
|
|
|
|
{
|
|
|
|
|
ASSERT(0); // called with a pActor that doesn't exist
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_SubActors.erase( iter );
|
|
|
|
|
m_SubActors.push_back( pActor );
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-20 05:08:35 +00:00
|
|
|
void ActorFrame::MoveToHead( Actor* pActor )
|
2003-01-11 08:55:21 +00:00
|
|
|
{
|
|
|
|
|
vector<Actor*>::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor );
|
|
|
|
|
if( iter == m_SubActors.end() ) // didn't find
|
|
|
|
|
{
|
|
|
|
|
ASSERT(0); // called with a pActor that doesn't exist
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_SubActors.erase( iter );
|
|
|
|
|
m_SubActors.insert( m_SubActors.begin(), pActor );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
void ActorFrame::DrawPrimitives()
|
2001-12-11 11:44:26 +00:00
|
|
|
{
|
2003-05-15 06:09:19 +00:00
|
|
|
// Don't set Actor-defined render states because we won't be drawing
|
|
|
|
|
// any geometry that belongs to this object.
|
|
|
|
|
// Actor::DrawPrimitives();
|
|
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
// draw all sub-ActorFrames while we're in the ActorFrame's local coordinate space
|
2002-10-31 02:11:52 +00:00
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ ) {
|
2001-12-11 11:44:26 +00:00
|
|
|
m_SubActors[i]->Draw();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ActorFrame::Update( float fDeltaTime )
|
|
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
// LOG->Trace( "ActorFrame::Update( %f )", fDeltaTime );
|
2002-01-16 10:01:32 +00:00
|
|
|
Actor::Update( fDeltaTime );
|
2001-12-11 11:44:26 +00:00
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
// update all sub-Actors
|
2003-10-07 06:00:33 +00:00
|
|
|
for( vector<Actor*>::iterator it=m_SubActors.begin(); it!=m_SubActors.end(); it++ )
|
|
|
|
|
(*it)->Update(fDeltaTime);
|
2001-12-11 11:44:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-10-28 05:30:45 +00:00
|
|
|
void ActorFrame::SetDiffuse( RageColor c )
|
2001-12-11 11:44:26 +00:00
|
|
|
{
|
2002-09-02 21:59:58 +00:00
|
|
|
Actor::SetDiffuse( c );
|
2001-12-11 11:44:26 +00:00
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
// set all sub-Actors
|
2002-10-31 02:11:52 +00:00
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
2002-09-02 21:59:58 +00:00
|
|
|
m_SubActors[i]->SetDiffuse(c );
|
2001-12-11 11:44:26 +00:00
|
|
|
}
|
2003-01-01 09:05:21 +00:00
|
|
|
|
2003-05-15 06:09:19 +00:00
|
|
|
void ActorFrame::SetUseZBuffer( bool b )
|
|
|
|
|
{
|
|
|
|
|
Actor::SetUseZBuffer( b );
|
|
|
|
|
|
|
|
|
|
// set all sub-Actors
|
|
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
|
|
|
|
m_SubActors[i]->SetUseZBuffer( b );
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-20 01:32:42 +00:00
|
|
|
void ActorFrame::FinishTweening()
|
|
|
|
|
{
|
|
|
|
|
Actor::FinishTweening();
|
|
|
|
|
|
|
|
|
|
// set all sub-Actors
|
|
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
|
|
|
|
m_SubActors[i]->FinishTweening();
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-02 01:43:33 +00:00
|
|
|
float ActorFrame::GetTweenTimeLeft() const
|
2003-01-01 09:05:21 +00:00
|
|
|
{
|
2003-03-02 01:43:33 +00:00
|
|
|
float m = Actor::GetTweenTimeLeft();
|
2003-01-01 09:05:21 +00:00
|
|
|
|
|
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
2003-03-02 01:43:33 +00:00
|
|
|
m = max(m, m_SubActors[i]->GetTweenTimeLeft());
|
2003-01-01 09:05:21 +00:00
|
|
|
|
|
|
|
|
return m;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-20 23:07:45 +00:00
|
|
|
bool CompareActorsByZDesc(const Actor *p1, const Actor *p2)
|
2003-06-19 18:05:52 +00:00
|
|
|
{
|
2003-06-20 23:07:45 +00:00
|
|
|
return p1->GetZ() > p2->GetZ();
|
|
|
|
|
}
|
2003-06-19 18:05:52 +00:00
|
|
|
|
2003-06-20 23:07:45 +00:00
|
|
|
void ActorFrame::SortByZ()
|
|
|
|
|
{
|
|
|
|
|
// Preserve ordering of Actors with equal Z values.
|
|
|
|
|
stable_sort( m_SubActors.begin(), m_SubActors.end(), CompareActorsByZDesc );
|
2003-06-19 18:05:52 +00:00
|
|
|
}
|